SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.14367 · ICML · 2024

Preference Fine-Tuning of LLMs Should Leverage Suboptimal, On-Policy Data

Chelsea Finn, Stefano Ermon, Jeff Schneider, Rafael Rafailov, Aviral Kumar, Archit Sharma, Tengyang Xie, Fahim Tajwar, Anikait Singh

arXiv · PDF · Open in the Atlas

Code that ran

3 of 8 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 0 failures 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/2404.14367.json · badge: /api/ran/2404.14367.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
Asap7772/understanding-rlhf canonical (classifier label)
classifier basis: census
3 ran · 5 no recorded run
FunctionStatusWhere it lives
dpo_action_logprob Ran
ran, honoured the contract we drafted
Asap7772/understanding-rlhf/bandit_experiment/dpo_utils.py
code served (permissive licence) · get_code("4fce913f89275282")
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 tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# Define a minimal agent model that has a log_prob method
class SimpleAgent(nn.Module):
    def __init__(self, state_dim=4, action_dim=3):
        super().__init__()
        self.state_dim = state_dim
        self.action_dim = action_dim
        self.linear = nn.Linear(state_dim, action_dim)
    
    def log_prob(self, state, action=None):
        # If only one argument provided (transformer mode), treat it as action
        if action is None:
            action = state
            logits = torch.randn(self.action_dim)
        else:
            logits = self.linear(state)
        
        log_probs = torch.log_softmax(logits, dim=-1)
        # Return log probability of the action
        if isinstance(action, torch.Tensor):
            action_idx = action.argmax(dim=-1) if action.dim() > 0 else action.item()
        else:
            action_idx = 0
        return log_probs[action_idx]

class TransformerAgent(nn.Module):
    def __init__(self, action_dim=3):
        super().__init__()
        self.action_dim = action_dim
    
    def log_prob(self, action):
        logits = torch.randn(self.action_dim)
        log_probs = torch.log_softmax(logits, dim=-1)
        if isinstance(action, torch.Tensor):
            action_idx = action.argmax(dim=-1) if action.dim() > 0 else action.item()
        else:
            action_idx = 0
        return log_probs[action_idx]

# Create a simple dataset
# Each item is (state, action, reward)
dataset = []
num_states = 2
N = 3  # number of samples per state

for state_idx in range(num_states):
    for sample_idx in range(N):
        state = torch.randn(4)  # state dimension 4
        action = torch.randn(3)  # action dimension 3
        reward = torch.tensor(float(state_idx * N + sample_idx + 1))  # varying rewards
        dataset.append((state, action, reward))

# Create agent and reference agent
agent = SimpleAgent(state_dim=4, action_dim=3)
ref_agent = SimpleAgent(state_dim=4, action_dim=3)

ARGS = {
    "dataset": dataset,
    "num_states": 2,
    "N": 3,
    "agent": agent,
    "ref_agent": ref_agent,
    "is_transformer": False
}
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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
dpo_decide_winner Ran
ran, honoured the contract we drafted
Asap7772/understanding-rlhf/bandit_experiment/dpo_utils.py
code served (permissive licence) · get_code("f748589a0dd675de")
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 tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

torch.manual_seed(0)

# The function accesses dataset[first_index] and dataset[second_index]
# Each item should be a tuple of (_, _, reward) where reward has .item() method
# This means reward should be a tensor

# Create a simple dataset as a list of tuples
# Each tuple is (dummy1, dummy2, reward_tensor)
dataset = [
    ("text1", "response1", torch.tensor(0.5)),
    ("text2", "response2", torch.tensor(0.8)),
    ("text3", "response3", torch.tensor(0.3)),
    ("text4", "response4", torch.tensor(0.9)),
]

first_index = 0
second_index = 1

ARGS = {
    "dataset": dataset,
    "first_index": first_index,
    "second_index": second_index,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
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
extract_entropy_list Ran
ran, honoured the contract we drafted
Asap7772/understanding-rlhf/bandit_experiment/compare_algorithms.py
code served (permissive licence) · get_code("9155f27e58509c90")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# entropy_type is a string key that will be used to index into dictionaries
entropy_type = "mutual_information"

# entropy_list is a list of dictionaries, where each dictionary has entropy_type as a key
entropy_list = [
    {"mutual_information": 0.5, "shannon_entropy": 0.3},
    {"mutual_information": 0.7, "shannon_entropy": 0.4},
    {"mutual_information": 0.6, "shannon_entropy": 0.35},
]

ARGS = {
    "entropy_type": entropy_type,
    "entropy_list": entropy_list,
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
calculate_dpo_logit Not yet run
unverified (harvested, no recorded run)
Asap7772/understanding-rlhf/bandit_experiment/dpo_utils.py
code served (permissive licence) · get_code("35b984bb0eee7392")
How it ran

no invocation recorded.

choose_action_config Not yet run
unverified (harvested, no recorded run)
Asap7772/understanding-rlhf/bandit_experiment/compare_algorithms.py
code served (permissive licence) · get_code("6bc77aa39da0e433")
How it ran

no invocation recorded.

choose_hyperparameters Not yet run
unverified (harvested, no recorded run)
Asap7772/understanding-rlhf/bandit_experiment/best_hyperparams.py
code served (permissive licence) · get_code("ad81a0b4199aa65b")
How it ran

no invocation recorded.

entropy Not yet run
unverified (harvested, no recorded run)
Asap7772/understanding-rlhf/bandit_experiment/metrics.py
code served (permissive licence) · get_code("806d61305979434e")
How it ran

no invocation recorded.

kl_divergence Not yet run
unverified (harvested, no recorded run)
Asap7772/understanding-rlhf/bandit_experiment/metrics.py
code served (permissive licence) · get_code("ed7aa020fea3c190")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 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.

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

Learning from preference labels plays a crucial role in fine-tuning large language models. There are several distinct approaches for preference fine-tuning, including supervised learning, on-policy reinforcement learning (RL), and contrastive learning. Different methods come with different implementation tradeoffs and performance differences, and existing empirical findings present different conclusions, for instance, some results show that online RL is quite important to attain good fine-tuning results, while others find (offline) contrastive or even purely supervised methods sufficient. This raises a natural question: what kind of approaches are important for fine-tuning with preference data and why? In this paper, we answer this question by performing a rigorous analysis of a number of fine-tuning techniques on didactic and full-scale LLM problems. Our main finding is that, in general, approaches that use on-policy sampling or attempt to push down the likelihood on certain responses (i.e., employ a "negative gradient") outperform offline and maximum likelihood objectives. We conceptualize our insights and unify methods that use on-policy sampling or negative gradient under a notion of mode-seeking objectives for categorical distributions. Mode-seeking objectives are able to alter probability mass on specific bins of a categorical distribution at a fast rate compared to maximum likelihood, allowing them to relocate masses across bins more effectively. Our analysis prescribes actionable insights for preference fine-tuning of LLMs and informs how data should be collected for maximal improvement.

For agents

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

get_harvested_code_for_paper("2404.14367")
get_code_for_paper("2404.14367")
have("2404.14367")

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

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

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

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

Connect an agent — have() is free.