SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.00398 · NeurIPS · 2023

Preference-grounded Token-level Guidance for Language Model Fine-tuning

Mingyuan Zhou, Caiming Xiong, Yihao Feng, Shujian Zhang, Shentao Yang, Congying Xia

arXiv · PDF · Open in the Atlas

Code that ran

8 of 18 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 6 failures of our instrument; 10 no recorded run), measured 2026-11-23; 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/2306.00398.json · badge: /api/ran/2306.00398.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
shentao-yang/preference_grounded_guidance canonical (classifier label)
classifier basis: classifier_2025
2 ran · 2 no recorded run
yinyueqin/denserewardrlhf-ppo community
Papers with Code archive
6 ran · 8 no recorded run
FunctionStatusWhere it lives
Experience Ran
ran on a synthesized input
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("5017ac033cf345d5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned NoneType. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np

# Experience is a dataclass, so we construct it by passing all fields directly
B = 2  # batch size
S = 5  # sequence length
A = 3  # number of actions

INIT_ARGS = {
    'sequences': torch.randint(0, 100, (B, S)),
    'action_log_probs': torch.randn(B, A),
    'values': torch.randn(B, A),
    'returns': torch.randn(B, A),
    'advantages': torch.randn(B, A),
    'attention_mask': torch.ones(B, S, dtype=torch.long),
    'action_mask': torch.ones(B, A, dtype=torch.bool),
    'info': {'episode_length': [10, 12]}
}

# The main computation methods are to_device and pin_memory
# We'll test to_device since pin_memory requires specific memory setup
METHOD = 'to_device'
ARGS = {
    'device': torch.device('cpu')
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NoneType — a NoneType output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NoneType output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RewardModel Ran
ran on a synthesized input · constructed an object; no result was computed
shentao-yang/preference_grounded_guidance/sum_task/reward_model.py
pointer only (licence: NONE) · get_code("6fdf28a6230ef77d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, shentao-yang/preference_grounded_guidance when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

_build_one_layer_mlp Ran
ran; our contract draft was wrong, not the code
shentao-yang/preference_grounded_guidance/sum_task/reward_model.py
pointer only (licence: NONE) · get_code("e97b4f8302932235")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, shentao-yang/preference_grounded_guidance when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

compute_approx_kl Ran
ran; our contract draft was wrong, not the code
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("8572f73b51db94c4")
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) and returned Tensor, ndim 2, dtype family float, shape (2, 4) 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

torch.manual_seed(0)

# Create small tensors for log probabilities
# Shape: (batch_size=2, num_actions=4)
log_probs = torch.randn(2, 4)
log_probs_base = torch.randn(2, 4)

# Create action mask with same shape
action_mask = torch.ones(2, 4)

ARGS = {
    "log_probs": log_probs,
    "log_probs_base": log_probs_base,
    "action_mask": action_mask,
    "use_kl_estimator_k3": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
log_probs_from_logits Ran
ran; our contract draft was wrong, not the code
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("959df7824bf09cc1")
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) 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.functional as F

torch.manual_seed(0)

# Create small tensors for testing
# logits: shape (batch_size, num_classes) = (2, 4)
logits = torch.randn(2, 4)

# labels: shape (batch_size,) with class indices in range [0, num_classes)
labels = torch.tensor([0, 2])

ARGS = {
    "logits": logits,
    "labels": labels,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
masked_mean Ran
ran; our contract draft was wrong, not the code
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("bff9c1af0e65b23b")
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) and returned Tensor, ndim 1, dtype family float, shape (4,) 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

torch.manual_seed(0)

# Create a small tensor (batch=2, features=4)
tensor = torch.randn(2, 4)

# Create a mask with the same shape
mask = torch.ones(2, 4)
mask[0, 1] = 0  # Mask out one element to make it distinct

# Dimension to reduce over
dim = 0

ARGS = {
    "tensor": tensor,
    "mask": mask,
    "dim": dim,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 (4,) — shape (4,) 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
reset_position_ids Ran
ran; our contract draft was wrong, not the code
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("3e5662344a15cfae")
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) and returned Tensor, ndim 2, dtype family int, shape (2, 4) 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

torch.manual_seed(0)

# Create a small attention_mask tensor
# Shape: (batch_size=2, seq_length=4)
# Values represent sequence numbers (0 for padding, 1+ for actual sequences)
attention_mask = torch.tensor([
    [1, 1, 2, 2],
    [1, 2, 2, 0]
], dtype=torch.long)

ARGS = {
    "attention_mask": attention_mask
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family int, shape (2, 4) — shape (2, 4) 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
to Ran
ran; our contract draft was wrong, not the code
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("938b6f55326552be")
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) and returned Tensor, ndim 2, dtype family float, shape (2, 4) 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

torch.manual_seed(0)

# Create a small tensor
tensor_single = torch.randn(2, 4)

# Create a list of small tensors
tensor_list = [torch.randn(2, 4), torch.randn(3, 5)]

# Define device (CPU only)
device = 'cpu'

# Construct ARGS dict with all parameters
ARGS = {
    'tensor': tensor_single,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
Actor Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("2c1a919b8596c263")
How it ran

no invocation recorded.

NaiveExperienceMaker Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("832009e99448c415")
How it ran

no invocation recorded.

_init_weights Not yet run
unverified (harvested, no recorded run)
shentao-yang/preference_grounded_guidance/sum_task/reward_model.py
pointer only (licence: NONE) · get_code("8f83f8e37a1fc568")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, shentao-yang/preference_grounded_guidance when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

compute_reward Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("b96e5125bdaa4277")
How it ran

no invocation recorded.

convert_ring_attn_params Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("340cb12bdef03f95")
How it ran

no invocation recorded.

pin_memory Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("98181e9dfff64330")
How it ran

no invocation recorded.

prints Not yet run
unverified (harvested, no recorded run)
shentao-yang/preference_grounded_guidance/sum_task/reward_model.py
pointer only (licence: NONE) · get_code("891ce03e776aef13")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, shentao-yang/preference_grounded_guidance when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

reset_ring_attn_position_ids Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("e93117d99aa6b210")
How it ran

no invocation recorded.

retry Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("e930cb6424d6bb2d")
How it ran

no invocation recorded.

update_ring_attn_params Not yet run
unverified (harvested, no recorded run)
yinyueqin/denserewardrlhf-ppo/denserlhf/trainer/ppo_utils/experience_maker.py
code served (permissive licence) · get_code("74b9172d4d4d6e9c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 18 samples lifted from this paper's linked repositories, 18 carry a function identity and 0 do not. Of the 18 distinct functions with an identity, 4 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 4 later) and 14 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
reset_ring_attn_position_ids
brick of this paper's assembly: helper
15 other papers
15 later
2402.09345 (2024-02)
InfoRM: Mitigating Reward Hacking in RLHF via Information-Theoretic Reward Modeling
2404.18922 (2024-04)
DPO Meets PPO: Reinforced Token Optimization for RLHF
2412.01981 (2024-12)
Free Process Rewards without Process Labels
and 12 more not named here
convert_ring_attn_params
brick of this paper's assembly: helper
9 other papers
9 later
2402.09345 (2024-02)
InfoRM: Mitigating Reward Hacking in RLHF via Information-Theoretic Reward Modeling
2404.18922 (2024-04)
DPO Meets PPO: Reinforced Token Optimization for RLHF
2412.01981 (2024-12)
Free Process Rewards without Process Labels
and 6 more not named here
log_probs_from_logits
brick of this paper's assembly: helper
8 other papers
8 later
2404.18922 (2024-04)
DPO Meets PPO: Reinforced Token Optimization for RLHF
2410.20749 (2024-10)
Matryoshka Pilot: Learning to Drive Black-Box LLMs with LLMs
2412.01981 (2024-12)
Free Process Rewards without Process Labels
and 5 more not named here
compute_approx_kl
brick of this paper's assembly: helper
2 other papers
2 later
2504.08837 (2025-04)
VL-Rethinker: Incentivizing Self-Reflection of Vision-Language Models with Reinforcement Learning
2601.17671 (2026-01)
Align to the Pivot: Dual Alignment with Self-Feedback for Multilingual Math Reasoning

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-23.

Repositories linked to this paper

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

Abstract

Aligning language models (LMs) with preferences is an important problem in natural language generation. A key challenge is that preferences are typically provided at the sequence level while LM training and generation both occur at the token level. There is, therefore, a granularity mismatch between the preference and the LM training losses, which may complicate the learning problem. In this paper, we address this issue by developing an alternate training process, where we iterate between grounding the sequence-level preference into token-level training guidance, and improving the LM with the learned guidance. For guidance learning, we design a framework that extends the pairwise-preference learning in imitation learning to both variable-length LM generation and the utilization of the preference among multiple generations. For LM training, based on the amount of supervised data, we present two minimalist learning objectives that utilize the learned guidance. In experiments, our method performs competitively on two distinct representative LM tasks -discrete-prompt generation and text summarization. Source codes are released at https://github.com/Shentao-YANG/Preference_Grounded_Guidance. In our follow-up work [113], we developed new techniques to successfully scale up the token-level RLHF framework in this paper to PPO + LLMs. As in this paper, we observed strong gain over the classical bandit RLHF, as tabulated in the following Table 1. Table 1: Performance comparison between token-level RLHF and bandit RLHF on PPO-trained LM policy, with the 8B-parameter Llama-family backbone model. The judge model is GPT-4o. For each backbone model, the highest value of each column is in bold. See Section 4.1 of Yin et al. [113] for experimental details. Action Space Backbone Model AlpacaEval 2 (LC) Arena-Hard MT-Bench Token Llama-3.

For agents

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

get_harvested_code_for_paper("2306.00398")
get_code_for_paper("2306.00398")
have("2306.00398")

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

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

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

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

Connect an agent — have() is free.