SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.10216 · NeurIPS · 2024

Regularizing Hidden States Enables Learning Generalizable Reward Model for LLMs

Huan Zhang, Tong Zhang, Rui Yang, Yong Lin, Ruomeng Ding

arXiv · PDF · Open in the Atlas

Code that ran

2 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 1 failure of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2406.10216.json · badge: /api/ran/2406.10216.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
yangrui2015/generalizable-reward-model canonical (classifier label)
classifier basis: census
2 ran · 5 no recorded run
FunctionStatusWhere it lives
is_lora_model Ran
ran, violated the contract we drafted
yangrui2015/generalizable-reward-model/reward_models/utils.py
code served (permissive licence) · get_code("f8e7d855924e7e64")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a model with lora in state_dict keys
class LoRAModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.lora_a = nn.Parameter(torch.randn(4, 2))
        self.lora_b = nn.Parameter(torch.randn(2, 3))
    
    def forward(self, x):
        return self.linear(x)

model = LoRAModel()

ARGS = {
    "model": model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
model_withhead_forward Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
yangrui2015/generalizable-reward-model/reward_models/grm_utils.py
code served (permissive licence) · get_code("95f86f1f81b6917f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class MockModelWithHead(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.vocab_size = vocab_size
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.head = nn.Linear(hidden_dim, vocab_size)
        self.reward_head = nn.Linear(hidden_dim, 1)
    
    def forward(self, input_ids, attention_mask=None):
        embeddings = self.embedding(input_ids)
        hidden = embeddings.mean(dim=1, keepdim=True)
        logits = self.head(embeddings)
        reward_tensors = self.reward_head(hidden)
        return logits, hidden, reward_tensors

batch_size = 2
seq_length = 5
vocab_size = 100
hidden_dim = 4

model = MockModelWithHead(vocab_size=vocab_size, hidden_dim=hidden_dim)
input_ids = torch.randint(0, vocab_size, (batch_size, seq_length))
attention_mask = torch.ones(batch_size, seq_length)
device = torch.device('cpu')
labels = torch.randint(0, vocab_size, (batch_size, seq_length))
labels[0, 2] = -100

ARGS = {
    'model': model,
    'input_ids': input_ids,
    'attention_mask': attention_mask,
    'device': device,
    'forward_type': 'dpo',
    'labels': labels
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_dataset Not yet run
unverified (harvested, no recorded run)
yangrui2015/generalizable-reward-model/reward_models/load_datasets.py
code served (permissive licence) · get_code("6a00527237189ca7")
How it ran

no invocation recorded.

build_dataset_SK Not yet run
unverified (harvested, no recorded run)
yangrui2015/generalizable-reward-model/reward_models/load_datasets.py
code served (permissive licence) · get_code("d186fa53dffbe25e")
How it ran

no invocation recorded.

build_dataset_UF Not yet run
unverified (harvested, no recorded run)
yangrui2015/generalizable-reward-model/reward_models/load_datasets.py
code served (permissive licence) · get_code("e3bb952a00849fc6")
How it ran

no invocation recorded.

get_trainable_weights Not yet run
unverified (harvested, no recorded run)
yangrui2015/generalizable-reward-model/reward_models/utils.py
code served (permissive licence) · get_code("aed395f45af87c9c")
How it ran

no invocation recorded.

unwrap_model Not yet run
unverified (harvested, no recorded run)
yangrui2015/generalizable-reward-model/rlhf/ppo/model_utils.py
code served (permissive licence) · get_code("54b2d55aa476a3bc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
unwrap_model 6 other papers
3 dated earlier, 3 later
2201.11147 (2022-01)
OntoProtein: Protein Pretraining With Gene Ontology Embedding
2311.13435 (2023-11)
PG-Video-LLaVA: Pixel Grounding Large Video-Language Models
2312.06739 (2023-12)
SmartEdit: Exploring Complex Instruction-based Image Editing with Multimodal Large Language Models
and 3 more not named here
get_trainable_weights 2 other papers
2 later
2510.10963 (2025-10)
APLOT: Robust Reward Modeling via Adaptive Preference Learning with Optimal Transport
2512.23461 (2025-12)
Eliminating Inductive Bias in Reward Models with Information-Theoretic Guidance
is_lora_model 2 other papers
2 later
2510.10963 (2025-10)
APLOT: Robust Reward Modeling via Adaptive Preference Learning with Optimal Transport
2512.23461 (2025-12)
Eliminating Inductive Bias in Reward Models with Information-Theoretic Guidance

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Reward models trained on human preference data have been proven to effectively align Large Language Models (LLMs) with human intent within the framework of reinforcement learning from human feedback (RLHF). However, current reward models have limited generalization capabilities to unseen prompts and responses, which can lead to an unexpected phenomenon known as reward over-optimization, resulting in a decline in actual performance due to excessive optimization of rewards. While previous research has advocated for constraining policy optimization, our study introduces a novel approach to enhance the reward model's generalization ability against distribution shifts by regularizing the hidden states. Specifically, we retain the base model's language model head and incorporate a suite of text-generation losses to preserve the hidden states' text-generation capabilities, while concurrently learning a reward head behind the same hidden states. Our experimental results demonstrate that the introduced regularization technique markedly improves the accuracy of learned reward models across a variety of out-of-distribution (OOD) tasks and effectively alleviates the over-optimization issue in RLHF, offering a more reliable and robust preference learning paradigm 1 .

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2406.10216")
get_code_for_paper("2406.10216")
have("2406.10216")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2406.10216.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2406.10216.svg)](https://syntology.ai/paper/2406.10216)

Connect an agent — have() is free.