SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.18290 · NeurIPS · 2023

Direct Preference Optimization: Your Language Model is Secretly a Reward Model

Chelsea Finn, Stefano Ermon, Christopher Manning, Eric Mitchell, Rafael Rafailov, Archit Sharma

arXiv · PDF · Open in the Atlas

Code that ran

25 of 31 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 19 have no contract verdict; 6 failures of our instrument; 6 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/2305.18290.json · badge: /api/ran/2305.18290.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
kidist-amde/ddro-direct-document-relevance-optimization community (classifier label)
classifier basis not recorded on the link
12 ran · 0 no recorded run
padlex/trl community (classifier label)
classifier basis not recorded on the link
7 ran · 5 no recorded run
kidist-amde/ddro community
Papers with Code archive
2 ran · 0 no recorded run
sauc-abadal/alt community
Papers with Code archive
1 ran · 1 no recorded run
OctopusMind/DPO community
Papers with Code archive
1 ran · 0 no recorded run
sunzeyeah/rlhf community
Papers with Code archive
1 ran · 0 no recorded run
icip-cas/Word-Deed-Consistency-Test community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
DPO Ran
ran on a synthesized input
OctopusMind/DPO/dpo.py
code served (permissive licence) · get_code("be7453ec96f94038")
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 torch.nn as nn
import torch.optim as optim

# Minimal mock model
class MockModel(nn.Module):
    def __init__(self, vocab_size=10, hidden_size=4):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.linear = nn.Linear(hidden_size, vocab_size)
    
    def forward(self, input_ids, attention_mask):
        x = self.embedding(input_ids)
        logits = self.linear(x)
        return logits

# Mock config
class Config:
    def __init__(self, beta=0.5, dpo_epochs=2):
        self.beta = beta
        self.dpo_epochs = dpo_epochs

# Import the DPO class
import torch.nn.functional as F

class DPO:

    def __init__(self, model, model_opt, config):
        self.model = model
        self.model_opt = model_opt
        self.beta = config.beta
        self.dpo_epochs = config.dpo_epochs

    def train(self, inputs_ids, attention_mask, ref_logits, labels_mask):
        ref_token_logps = self.probs_from_logits(torch.tensor(ref_logits)[:, :-1, :], inputs_ids[:, 1:])
        ref_logps = self.filter_mask(ref_token_logps, labels_mask)
        for dpo_epoch in range(self.dpo_epochs):
            logits = self.model(inputs_ids, attention_mask)
            policy_token_logps = self.probs_from_logits(logits[:, :-1, :], inputs_ids[:, 1:])
            policy_logps = self.filter_mask(policy_token_logps, labels_mask)
            loss = self.dpo_loss(policy_logps, ref_logps)
            self.model_opt.zero_grad()
            loss.backward()
            self.model_opt.step()
            print(loss)

    def dpo_loss(self, policy_logps, ref_logps):
        def concat_probs(logps):
            len_chosen = int(len(logps) / 2)
            rejected_data = torch.cat(logps[:len_chosen])
            chosen_data = torch.cat(logps[len_chosen:])
            return (rejected_data, chosen_data)
        policy_rejected_logps, policy_chosen_logps = concat_probs(policy_logps)
        ref_rejected_logps, ref_chosen_logps = concat_probs(ref_logps)
        pi_logratios = policy_chosen_logps - policy_rejected_logps
        ref_logratios = ref_chosen_logps - ref_rejected_logps
        logits = pi_logratios - ref_logratios
        loss = -F.logsigmoid(self.beta * logits)
        return loss.mean()

    @staticmethod
    def probs_from_logits(logits, labels):
        log_probs = F.log_softmax(logits, dim=2)
        probs = torch.gather(log_probs, 2, labels.unsqueeze(2)).squeeze(-1)
        return probs

    @staticmethod
    def filter_mask(values, labels_masks):
        return [value[one_response_ids_mask[:-1] == 1].sum().unsqueeze(0) for value, one_response_ids_mask in zip(values, labels_masks)]


# Setup
INIT_ARGS = {
    'model': MockModel(vocab_size=10, hidden_size=4),
    'model_opt': optim.Adam(MockModel(vocab_size=10, hidden_size=4).parameters(), lr=0.001),
    'config': Config(beta=0.5, dpo_epochs=2)
}

ARGS = {
    'inputs_ids': torch.randint(0, 10, (4, 6)),
    'attention_mask': torch.ones(4, 6),
    'ref_logits': torch.randn(4, 6, 10),
    'labels_mask': torch.tensor([[1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0]])
}

METHOD = 'train'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
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)
PairWiseLoss Ran
ran on a synthesized input
sunzeyeah/rlhf/src/models/loss.py
pointer only (licence: NONE) · get_code("d69bfa3e1e60a92b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, sunzeyeah/rlhf 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.

Policy Ran
ran on a synthesized input · constructed an object; no result was computed
sauc-abadal/alt/alt/trainer/alt_trainer.py
code served (permissive licence) · get_code("0a800ad29eb472ac")
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 an instance of its own class, Policy: the run constructed the object and did not call it, so no result was computed. 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 torch.nn as nn
from transformers import AutoTokenizer, GenerationConfig

torch.manual_seed(0)

# Create a minimal stand-in tokenizer
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0
        self.eos_token_id = 2
    
    def batch_decode(self, token_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True):
        # Return dummy text for each sequence in batch
        return ["generated text one", "generated text two"]

# Create a minimal causal LM model
class MinimalCausalLM(nn.Module):
    def __init__(self):
        super().__init__()
        self.vocab_size = 100
        self.embedding = nn.Embedding(100, 16)
        self.lm_head = nn.Linear(16, 100)
    
    def forward(self, input_ids, attention_mask=None, labels=None, return_dict=True, output_hidden_states=False, output_attentions=False):
        hidden_states = self.embedding(input_ids)
        logits = self.lm_head(hidden_states)
        
        loss = None
        if labels is not None:
            loss_fn = nn.CrossEntropyLoss()
            shift_logits = logits[..., :-1, :].contiguous()
            shift_labels = labels[..., 1:].contiguous()
            loss = loss_fn(shift_logits.view(-1, self.vocab_size), shift_labels.view(-1))
        
        class Output:
            def __init__(self, logits, loss):
                self.logits = logits
                self.loss = loss
            def __getitem__(self, key):
                if key == 'logits':
                    return self.logits
                elif key == 'loss':
                    return self.loss
        
        return Output(logits, loss)
    
    def generate(self, input_ids, attention_mask, generation_config):
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        max_new_tokens = 3
        
        # Generate dummy token ids
        new_tokens = torch.randint(1, 99, (batch_size, max_new_tokens))
        sequences = torch.cat([input_ids, new_tokens], dim=1)
        
        class GenerateOutput:
            def __init__(self, sequences):
                self.sequences = sequences
            def __getitem__(self, key):
                if key == 'sequences':
                    return self.sequences
        
        return GenerateOutput(sequences)

# Mock AutoModelForCausalLM.from_pretrained
original_from_pretrained = None
def mock_from_pretrained(checkpoint_name):
    return MinimalCausalLM()

# Monkey patch
import transformers
transformers.AutoModelForCausalLM.from_pretrained = mock_from_pretrained

device = torch.device('cpu')
tokenizer = MinimalTokenizer()
model_checkpoint_name = "mock-model"

ARGS = {
    'model_checkpoint_name': model_checkpoint_name,
    'device': device,
    'tokenizer': tokenizer,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Policy — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Policy 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: none by the harness; any seed is in the setup block
T5ForPretrain Ran
ran on a synthesized input
kidist-amde/ddro/src/pretrain/T5ForPretrain.py
code served (permissive licence) · get_code("88b1660f36f94aca")
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 Seq2SeqLMOutput. 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 torch.nn as nn
from transformers import T5ForConditionalGeneration, T5Config
from transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput

class T5ForPretrain(T5ForConditionalGeneration):

    def __init__(self, t5_model, args):
        super().__init__(t5_model.config)
        self.args = args
        self.config = t5_model.config
        self.shared = t5_model.shared
        self.encoder = t5_model.encoder
        self.decoder = t5_model.decoder
        if self.args.use_origin_head == 'True':
            self.lm_head = t5_model.lm_head
            print('Using original LM head')
        else:
            self.lm_head = nn.Linear(self.config.d_model, self.config.vocab_size, bias=False)
        print('LM head shape:', self.lm_head.weight.shape)
        self.loss_fct = nn.CrossEntropyLoss(ignore_index=-100)

    def forward(self, input_ids=None, attention_mask=None, decoder_input_ids=None, decoder_attention_mask=None, head_mask=None, decoder_head_mask=None, cross_attn_head_mask=None, encoder_outputs=None, past_key_values=None, inputs_embeds=None, decoder_inputs_embeds=None, labels=None, use_cache=None, output_attentions=None, output_hidden_states=None, return_dict=None, **kwargs):
        if encoder_outputs is None:
            encoder_outputs = self.encoder(input_ids=input_ids, attention_mask=attention_mask, inputs_embeds=inputs_embeds, head_mask=head_mask, output_attentions=output_attentions, output_hidden_states=output_hidden_states, return_dict=return_dict)
        elif return_dict and (not isinstance(encoder_outputs, BaseModelOutput)):
            encoder_outputs = BaseModelOutput(last_hidden_state=encoder_outputs[0], hidden_states=encoder_outputs[1] if len(encoder_outputs) > 1 else None, attentions=encoder_outputs[2] if len(encoder_outputs) > 2 else None)
        hidden_states = encoder_outputs[0]
        if labels is not None and decoder_input_ids is None and (decoder_inputs_embeds is None):
            decoder_input_ids = self._shift_right(labels)
        decoder_outputs = self.decoder(input_ids=decoder_input_ids, attention_mask=decoder_attention_mask, encoder_hidden_states=hidden_states, encoder_attention_mask=attention_mask, inputs_embeds=decoder_inputs_embeds, head_mask=decoder_head_mask, past_key_values=past_key_values, use_cache=use_cache, output_attentions=output_attentions, output_hidden_states=output_hidden_states, return_dict=return_dict)
        sequence_output = decoder_outputs[0]
        if self.config.tie_word_embeddings:
            sequence_output = sequence_output * self.model_dim ** (-0.5)
        lm_logits = self.lm_head(sequence_output)
        loss = None
        if labels is not None:
            loss = self.loss_fct(lm_logits.view(-1, lm_logits.size(-1)), labels.view(-1))
        if not return_dict:
            return loss
        return Seq2SeqLMOutput(loss=loss, logits=lm_logits, past_key_values=decoder_outputs.past_key_values, decoder_hidden_states=decoder_outputs.hidden_states, decoder_attentions=decoder_outputs.attentions, cross_attentions=decoder_outputs.cross_attentions, encoder_last_hidden_state=encoder_outputs.last_hidden_state, encoder_hidden_states=encoder_outputs.hidden_states, encoder_attentions=encoder_outputs.attentions)


class Args:
    def __init__(self):
        self.use_origin_head = 'False'


config = T5Config(
    vocab_size=100,
    d_model=4,
    d_kv=2,
    d_ff=8,
    num_layers=2,
    num_decoder_layers=2,
    num_heads=2,
    relative_attention_num_buckets=32,
    dropout_rate=0.1,
    layer_norm_epsilon=1e-6,
    initializer_factor=1.0,
    feed_forward_proj="relu",
    is_encoder_decoder=True,
    tie_word_embeddings=True,
)

t5_model = T5ForConditionalGeneration(config)
args = Args()

INIT_ARGS = {
    't5_model': t5_model,
    'args': args,
}

ARGS = {
    'input_ids': torch.randint(0, 100, (2, 5)),
    'attention_mask': torch.ones(2, 5),
    'decoder_input_ids': torch.randint(0, 100, (2, 5)),
    'decoder_attention_mask': torch.ones(2, 5),
    'labels': torch.randint(0, 100, (2, 5)),
    'return_dict': True,
}

model = T5ForPretrain(**INIT_ARGS)
output = model(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Seq2SeqLMOutput — a Seq2SeqLMOutput output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Seq2SeqLMOutput 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)
T5ForPretrainDPO Ran
ran on a synthesized input
kidist-amde/ddro/src/pretrain/T5ForPretrain.py
code served (permissive licence) · get_code("9fc13a517d28b68e")
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 Seq2SeqLMOutput. 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 torch.nn as nn
from transformers import T5Config, T5ForConditionalGeneration
from transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput

# Create a minimal T5 model for testing
config = T5Config(
    d_model=4,
    d_kv=2,
    d_ff=8,
    num_layers=2,
    num_decoder_layers=2,
    num_heads=2,
    vocab_size=32,
    decoder_start_token_id=0,
    pad_token_id=0,
    eos_token_id=1,
)

t5_model = T5ForConditionalGeneration(config)

# Create args object
class Args:
    def __init__(self):
        self.use_origin_head = 'False'

args = Args()

INIT_ARGS = {
    't5_model': t5_model,
    'args': args,
}

ARGS = {
    'input_ids': torch.randint(0, 32, (2, 5)),
    'attention_mask': torch.ones(2, 5, dtype=torch.long),
    'decoder_input_ids': torch.randint(0, 32, (2, 4)),
    'decoder_attention_mask': torch.ones(2, 4, dtype=torch.long),
    'labels': torch.randint(0, 32, (2, 4)),
    'return_dict': True,
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Seq2SeqLMOutput — a Seq2SeqLMOutput output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Seq2SeqLMOutput 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)
average_precision Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/utils/evaluate.py
code served (permissive licence) · get_code("99d26fdcc1af5b62")
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 float, 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

# Set seed for reproducibility
torch.manual_seed(0)

# Define arguments for average_precision function
# truth: set of ground-truth elements
# pred: list of predicted elements

ARGS = {
    "truth": {"item_a", "item_b", "item_c", "item_d"},
    "pred": ["item_a", "item_x", "item_b", "item_y", "item_c"]
}
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 float, 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
compare_metrics Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/utils/compare_models.py
code served (permissive licence) · get_code("9169d5b42acf842a")
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 DataFrame. 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 pandas as pd
import numpy as np
from scipy.stats import ttest_rel, wilcoxon

# Create sample DataFrames with per-query metrics
np.random.seed(0)

# Model 1 metrics DataFrame
metrics_df_1 = pd.DataFrame({
    'accuracy': np.random.rand(10),
    'precision': np.random.rand(10),
    'recall': np.random.rand(10),
    'f1_score': np.random.rand(10)
})

# Model 2 metrics DataFrame (with slight variations)
metrics_df_2 = pd.DataFrame({
    'accuracy': np.random.rand(10) + 0.01,
    'precision': np.random.rand(10) + 0.02,
    'recall': np.random.rand(10) - 0.01,
    'f1_score': np.random.rand(10)
})

# List of metrics to compare
metrics_list = ['accuracy', 'precision', 'recall', 'f1_score']

# Statistical test to use
test = 'ttest'

ARGS = {
    'metrics_df_1': metrics_df_1,
    'metrics_df_2': metrics_df_2,
    'metrics_list': metrics_list,
    'test': test
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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: none by the harness; any seed is in the setup block
conversations_formatting_function Ran
ran on a synthesized input
padlex/trl/trl/extras/dataset_formatting.py
code served (permissive licence) · get_code("e491afec66bfd582")
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 function. 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.

from transformers import AutoTokenizer
from unittest.mock import MagicMock

# Create a minimal mock tokenizer that has apply_chat_template method
mock_tokenizer = MagicMock(spec=AutoTokenizer)

def mock_apply_chat_template(messages, tokenize=False):
    """Mock implementation of apply_chat_template"""
    if isinstance(messages, list):
        return f"formatted: {str(messages)}"
    return f"formatted: {str(messages)}"

mock_tokenizer.apply_chat_template = mock_apply_chat_template

ARGS = {
    "tokenizer": mock_tokenizer,
    "messages_field": "messages"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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: none by the harness; any seed is in the setup block
convert_state_dict Ran
ran; our contract draft was wrong, not the code
padlex/trl/trl/models/sd_utils.py
code served (permissive licence) · get_code("8f1ce89b816a0734")
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 dict. 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

torch.manual_seed(0)

# Construct state_dict with some sample tensors
state_dict = {
    'model.processor.layer1': torch.randn(2, 4),
    'model.processor.layer2': torch.randn(3, 5),
    'encoder.weight': torch.randn(4, 4),
    'decoder.bias': torch.randn(2),
}

# Construct mapping for pattern replacement
mapping = {
    'model.': 'transformed_model.',
    'encoder': 'new_encoder',
}

ARGS = {
    'state_dict': state_dict,
    'mapping': mapping,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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: none by the harness; any seed is in the setup block
convert_to_scalar Ran
ran; our contract draft was wrong, not the code
padlex/trl/trl/core.py
code served (permissive licence) · get_code("c32b636f13ed9ee5")
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 dict. 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

torch.manual_seed(0)

ARGS = {
    "stats": {
        "loss": torch.tensor(0.5),
        "accuracy": torch.tensor([0.95]),
        "batch_size": 32,
        "learning_rate": 0.001,
        "numpy_metric": np.array(0.87),
        "numpy_array_metric": np.array([0.92]),
        "string_value": "test",
        "multi_dim_tensor": torch.randn(2, 3),
    }
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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: none by the harness; any seed is in the setup block
get_all_parameters Ran
ran; our contract draft was wrong, not the code
padlex/trl/trl/models/utils.py
code served (permissive licence) · get_code("2f5119732e8dbd63")
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 chain. 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 torch.nn as nn
import itertools

torch.manual_seed(0)

class MockSubModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.conv = nn.Conv1d(2, 5, 3)
    
    def ds_external_parameters(self):
        # Return an iterable of (name, parameter) tuples
        # simulating external parameters like those from DeepSpeed
        external_param1 = nn.Parameter(torch.randn(2, 4))
        external_param2 = nn.Parameter(torch.randn(3))
        return [("external_param_1", external_param1), ("external_param_2", external_param2)]

sub_module = MockSubModule()

ARGS = {
    "sub_module": sub_module,
    "recurse": 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 chain — a chain output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a chain 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: none by the harness; any seed is in the setup block
hit_at_k Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/utils/evaluate.py
code served (permissive licence) · get_code("e9ac5f8dce946d2f")
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 float, 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

torch.manual_seed(0)

# Analyzing the function:
# hit_at_k(truth, pred, k)
# - truth: needs to support 'in' operator, so it should be a container (list, set, tuple)
# - pred: needs to support slicing with [:k], so it should be a sequence (list, tuple)
# - k: needs to be an integer for slicing
# The function checks if any item from pred[:k] is in truth

ARGS = {
    "truth": [1, 2, 3, 4, 5],
    "pred": [5, 6, 7, 8, 9, 10],
    "k": 3
}
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 float, 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
instructions_formatting_function Ran
ran on a synthesized input
padlex/trl/trl/extras/dataset_formatting.py
code served (permissive licence) · get_code("875b816ac9842673")
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 function. 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.

from transformers import AutoTokenizer
from unittest.mock import Mock

# Create a mock tokenizer that implements the required interface
class MockTokenizer:
    def apply_chat_template(self, messages, tokenize=False):
        """Mock implementation that formats chat messages"""
        formatted = ""
        for msg in messages:
            formatted += f"[{msg['role']}]: {msg['content']}\n"
        return formatted

# Create a simple tokenizer instance
tokenizer = MockTokenizer()

ARGS = {
    "tokenizer": tokenizer,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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: none by the harness; any seed is in the setup block
iter_params Ran
ran; our contract draft was wrong, not the code
padlex/trl/trl/models/utils.py
code served (permissive licence) · get_code("48685a350888e505")
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. 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 torch.nn as nn
import itertools

torch.manual_seed(0)

class MockSubModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.conv = nn.Conv1d(2, 5, 3)
    
    def named_parameters(self, recurse=False):
        if recurse:
            return super().named_parameters(recurse=True)
        else:
            return super().named_parameters(recurse=False)
    
    def ds_external_parameters(self):
        external_param = nn.Parameter(torch.randn(7, 2))
        yield ('external_param', external_param)

module = MockSubModule()

ARGS = {
    'module': module,
    'recurse': 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 list — a list output has no array shape of its own; none is 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: none by the harness; any seed is in the setup block
load_checkpoint Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/train_ddro_encoder_decoder.py
code served (permissive licence) · get_code("0f3aeaf1bff007f2")
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 dict. 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 tempfile
import os

torch.manual_seed(0)

# Create a temporary checkpoint file
temp_dir = tempfile.mkdtemp()
checkpoint_path = os.path.join(temp_dir, "checkpoint.pt")

# Create a sample state dict with some tensors and parameters
# Include both 'module.*' prefixed keys and regular keys
sample_state = {
    'module.layer1.weight': torch.randn(4, 3),
    'module.layer1.bias': torch.randn(4),
    'module.layer2.weight': torch.randn(5, 4),
    'layer3.weight': torch.randn(2, 5),
    'layer3.bias': torch.randn(2),
}

# Save the checkpoint
torch.save(sample_state, checkpoint_path)

# Define ARGS with the path parameter
ARGS = {
    'path': checkpoint_path
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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: none by the harness; any seed is in the setup block
load_data Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/eval_ddro_docid_ranking.py
code served (permissive licence) · get_code("4099bb8045c005b6")
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 os
import tempfile

# Create temporary directory and files for testing
temp_dir = tempfile.mkdtemp()
test_file_1 = os.path.join(temp_dir, "data1.txt")
test_file_2 = os.path.join(temp_dir, "data2.txt")

# Write some dummy data to the files
with open(test_file_1, 'w') as f:
    f.write("sample data 1")

with open(test_file_2, 'w') as f:
    f.write("sample data 2")

# Test with directory path
ARGS = {
    "file_path": temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
load_doc_offsets Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/train_ddro_encoder_decoder.py
code served (permissive licence) · get_code("01a7e0dc6f29f042")
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 dict. 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 csv
import gzip
import tempfile
import os

# Create a temporary gzip-compressed CSV file with tab-separated values
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test_offsets.tsv.gz")

# Write sample data: docid, _, offset
sample_data = [
    ["doc1", "unused_field1", "0"],
    ["doc2", "unused_field2", "1024"],
    ["doc3", "unused_field3", "2048"],
]

with gzip.open(temp_file, 'wt', encoding='utf8') as f:
    writer = csv.writer(f, delimiter='\t')
    for row in sample_data:
        writer.writerow(row)

ARGS = {
    "path": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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: none by the harness; any seed is in the setup block
load_encoded_docid Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/utils/generate_demo.py
code served (permissive licence) · get_code("9c879833332cded9")
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. 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 tempfile
import os

# Create a temporary file with sample encoded docid data
temp_dir = tempfile.mkdtemp()
docid_path = os.path.join(temp_dir, 't5_url_msmarco.txt')

# Write sample data to the temporary file
with open(docid_path, 'w') as fw:
    fw.write("doc1\t101,102,103,104\n")
    fw.write("doc2\t201,202,203,204\n")
    fw.write("doc3\t101,102,103,104\n")
    fw.write("doc4\t301,302,303,304\n")

ARGS = {
    'docid_path': docid_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: none by the harness; any seed is in the setup block
load_metrics Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/utils/compare_models.py
code served (permissive licence) · get_code("1233495c1bf99438")
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 DataFrame. 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 pandas as pd
import tempfile
import os

# Create a temporary CSV file with sample metrics data
temp_dir = tempfile.mkdtemp()
file_path = os.path.join(temp_dir, "metrics.csv")

# Create sample metrics DataFrame and save it
metrics_data = {
    'query_id': [1, 2, 3],
    'precision': [0.95, 0.87, 0.92],
    'recall': [0.88, 0.91, 0.85],
    'f1_score': [0.91, 0.89, 0.88]
}
metrics_df = pd.DataFrame(metrics_data)
metrics_df.to_csv(file_path, index=False)

ARGS = {
    'file_path': file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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: none by the harness; any seed is in the setup block
load_query_texts Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/train_ddro_encoder_decoder.py
code served (permissive licence) · get_code("8c68bf8c060f4814")
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 dict. 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 gzip
import tempfile
import os

# Create a temporary gzip file with sample query data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "queries.txt.gz")

with gzip.open(temp_file, 'wt') as f:
    f.write("1\tWhat is machine learning?\n")
    f.write("2\tHow does deep learning work?\n")
    f.write("3\tExplain neural networks\n")

ARGS = {
    "path": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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: none by the harness; any seed is in the setup block
preference_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
icip-cas/Word-Deed-Consistency-Test/dpo/trainers.py
pointer only (licence: NONE) · get_code("c79211fc0225a27f")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, icip-cas/Word-Deed-Consistency-Test 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.

prepare_dataset Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/finetune_docTTTTTquery_NQ.py
code served (permissive licence) · get_code("19b1210f13924026")
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 Dataset. 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 pandas as pd
from datasets import Dataset
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal tokenizer mock that supports the tokenizer API
class MinimalTokenizer:
    def __call__(self, text, max_length=512, truncation=True, padding='max_length'):
        # Return a dict with input_ids and attention_mask
        # Simulate tokenization by returning fixed-size tensors
        batch_size = len(text) if isinstance(text, list) else 1
        return {
            'input_ids': [[101, 2054, 2003, 102] + [0] * (max_length - 4)] * batch_size,
            'attention_mask': [[1, 1, 1, 1] + [0] * (max_length - 4)] * batch_size
        }

# Create a temporary gzip-compressed TSV file content
import gzip
import io
import tempfile
import os

# Create temporary directory and file
temp_dir = tempfile.mkdtemp()
data_path = os.path.join(temp_dir, 'test_data.tsv.gz')

# Write sample data as gzip-compressed TSV
sample_data = "1\tWhat is AI?\tArtificial intelligence overview\n2\tWhat is ML?\tMachine learning basics\n"
with gzip.open(data_path, 'wt') as f:
    f.write(sample_data)

tokenizer = MinimalTokenizer()
max_length = 512

ARGS = {
    'data_path': data_path,
    'tokenizer': tokenizer,
    'max_length': max_length
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Dataset — a Dataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Dataset output the recorded ndim 1 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: none by the harness; any seed is in the setup block
recall_at_k Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/utils/evaluate.py
code served (permissive licence) · get_code("a05d09685378cdb9")
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 float, 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 numpy as np

torch.manual_seed(0)

# recall_at_k function expects:
# - truth: a collection (list, set, etc.) of relevant documents
# - pred: a list of predicted documents (ordered by relevance)
# - k: optional integer to limit predictions to top-k

# Create sample data: documents represented as simple identifiers
truth = {1, 3, 5, 7}  # set of relevant document IDs
pred = [1, 2, 3, 4, 5, 6, 7, 8]  # predicted documents in order
k = 5  # consider only top-5 predictions

ARGS = {
    "truth": truth,
    "pred": pred,
    "k": k
}
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 float, 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
split_dataset Ran
ran on a synthesized input
kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/finetune_docTTTTTquery_NQ.py
code served (permissive licence) · get_code("bdad0f787751d773")
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. 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
from datasets import Dataset

torch.manual_seed(0)

# Create a simple dataset using huggingface datasets library
data = {
    'text': ['hello world', 'foo bar', 'test example', 'sample data'],
    'label': [0, 1, 0, 1]
}

dataset = Dataset.from_dict(data)

ARGS = {
    'dataset': dataset,
    'test_size': 0.2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: none by the harness; any seed is in the setup block
top_k_top_p_filtering Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
padlex/trl/trl/core.py
code served (permissive licence) · get_code("5bcf8e086423cf6b")
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 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
from transformers.generation import TopKLogitsWarper, TopPLogitsWarper

torch.manual_seed(0)

# Create small logits tensor: batch_size=2, vocab_size=4
logits = torch.randn(2, 4, dtype=torch.float32)

ARGS = {
    "logits": logits,
    "top_k": 2,
    "top_p": 0.9,
    "filter_value": -float('Inf'),
    "min_tokens_to_keep": 1,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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
ALTTrainer_noKL Not yet run
unverified (harvested, no recorded run)
sauc-abadal/alt/alt/trainer/alt_trainer.py
code served (permissive licence) · get_code("68d8bd0d51b34185")
How it ran

no invocation recorded.

convert_state_dict_to_diffusers Not yet run
unverified (harvested, no recorded run)
padlex/trl/trl/models/sd_utils.py
code served (permissive licence) · get_code("fa59c920caf016e6")
How it ran

no invocation recorded.

flatten_dict Not yet run
unverified (harvested, no recorded run)
padlex/trl/trl/core.py
code served (permissive licence) · get_code("a51ae45a1f6c0b5b")
How it ran

no invocation recorded.

is_transformers_greater_than Not yet run
unverified (harvested, no recorded run)
padlex/trl/trl/import_utils.py
code served (permissive licence) · get_code("2a9ca02cb6e196ff")
How it ran

no invocation recorded.

scheduler_step Not yet run
unverified (harvested, no recorded run)
padlex/trl/trl/models/modeling_sd_base.py
code served (permissive licence) · get_code("ade247252fd2d3db")
How it ran

no invocation recorded.

setup_chat_format Not yet run
unverified (harvested, no recorded run)
padlex/trl/trl/models/utils.py
code served (permissive licence) · get_code("ccaedb0c5f904b0b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 31 samples lifted from this paper's linked repositories, 31 carry a function identity and 0 do not. Of the 31 distinct functions with an identity, 12 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 1 the same month, 12 later) and 19 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
top_k_top_p_filtering 21 other papers
1 the same month, 20 later
2305.12191 (2023-05)
Pointwise Mutual Information Based Metric and Decoding Strategy for Faithful Generation in Document Grounded Dialogs
2311.17911 (2023-11)
OPERA: Alleviating Hallucination in Multi-Modal Large Language Models via Over-Trust Penalty and Retrospection-Allocation
2402.15708 (2024-02)
Query Augmentation by Decoding Semantics from Brain Signals
and 18 more not named here
convert_to_scalar 18 other papers
18 later
2406.11280 (2024-06)
ISR-DPO: Aligning Large Multimodal Models for Videos by Iterative Self-Retrospective DPO
2406.19371 (2024-06)
Suri: Multi-constraint Instruction Following for Long-form Text Generation
2410.06101 (2024-10)
Coevolving with the Other You: Fine-Tuning LLM with Sequential Cooperative Multi-Agent Reinforcement Learning
and 15 more not named here
flatten_dict 18 other papers
18 later
2406.11280 (2024-06)
ISR-DPO: Aligning Large Multimodal Models for Videos by Iterative Self-Retrospective DPO
2406.19371 (2024-06)
Suri: Multi-constraint Instruction Following for Long-form Text Generation
2410.06101 (2024-10)
Coevolving with the Other You: Fine-Tuning LLM with Sequential Cooperative Multi-Agent Reinforcement Learning
and 15 more not named here
preference_loss
brick of this paper's assembly: entry
5 other papers
5 later
2401.13275 (2024-01)
Can AI Assistants Know What They Don't Know?
2405.20304 (2024-05)
Group Robust Preference Optimization in Reward-free RLHF
2407.07880 (2024-07)
Towards Robust Alignment of Language Models: Distributionally Robustifying Direct Preference Optimization
and 2 more not named here
scheduler_step 4 other papers
4 later
2410.06101 (2024-10)
Coevolving with the Other You: Fine-Tuning LLM with Sequential Cooperative Multi-Agent Reinforcement Learning
2501.06911 (2025-01)
Risk-Averse Fine-tuning of Large Language Models
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
and 1 more not named here
is_transformers_greater_than 3 other papers
3 later
2406.19371 (2024-06)
Suri: Multi-constraint Instruction Following for Long-form Text Generation
2507.04976 (2025-07)
Can Video LLMs Refuse to Answer? Alignment for Answerability in Video Large Language Models
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
convert_state_dict 2 other papers
2 later
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
2605.11974 (2026-05)
Towards Order Fairness: Mitigating LLMs Order Sensitivity through Dual Group Advantage Optimization
convert_state_dict_to_diffusers 2 other papers
2 later
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
2605.11974 (2026-05)
Towards Order Fairness: Mitigating LLMs Order Sensitivity through Dual Group Advantage Optimization
get_all_parameters 2 other papers
2 later
2502.12853 (2025-02)
S 2 R: Teaching LLMs to Self-verify and Self-correct via Reinforcement Learning
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
iter_params 2 other papers
2 later
2502.12853 (2025-02)
S 2 R: Teaching LLMs to Self-verify and Self-correct via Reinforcement Learning
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
Policy
brick of this paper's assembly: model
1 other paper
1 later · 1 only as an assembly brick
2407.16970 (2024-07)
Towards Aligning Language Models with Textual Feedback
setup_chat_format 1 other paper
1 later
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time

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

While large-scale unsupervised language models (LMs) learn broad world knowledge and some reasoning skills, achieving precise control of their behavior is difficult due to the completely unsupervised nature of their training. Existing methods for gaining such steerability collect human labels of the relative quality of model generations and fine-tune the unsupervised LM to align with these preferences, often with reinforcement learning from human feedback (RLHF). However, RLHF is a complex and often unstable procedure, first fitting a reward model that reflects the human preferences, and then fine-tuning the large unsupervised LM using reinforcement learning to maximize this estimated reward without drifting too far from the original model. In this paper we introduce a new parameterization of the reward model in RLHF that enables extraction of the corresponding optimal policy in closed form, allowing us to solve the standard RLHF problem with only a simple classification loss. The resulting algorithm, which we call Direct Preference Optimization (DPO), is stable, performant, and computationally lightweight, eliminating the need for sampling from the LM during fine-tuning or performing significant hyperparameter tuning. Our experiments show that DPO can fine-tune LMs to align with human preferences as well as or better than existing methods. Notably, fine-tuning with DPO exceeds PPO-based RLHF in ability to control sentiment of generations, and matches or improves response quality in summarization and single-turn dialogue while being substantially simpler to implement and train.

For agents

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

get_harvested_code_for_paper("2305.18290")
get_code_for_paper("2305.18290")
have("2305.18290")

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

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

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

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

Connect an agent — have() is free.