SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.01967 · 2024

A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicity

arXiv · PDF · Open in the Atlas

Code that ran

12 of 14 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; 9 failures of our instrument; 2 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/2401.01967.json · badge: /api/ran/2401.01967.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
ajyl/dpo_toxic canonical (classifier label)
classifier basis: census
12 ran · 2 no recorded run
FunctionStatusWhere it lives
dpo_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ajyl/dpo_toxic/toxicity/train_dpo/trainers.py
code served (permissive licence) · get_code("6e420696373414b1")
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 2, 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.functional as F

torch.manual_seed(0)

# Create small batch tensors for DPO loss computation
batch_size = 2

# Policy model log probabilities for positive responses (batch_size,)
policy_pos_logps = torch.randn(batch_size, dtype=torch.float32)

# Policy model log probabilities for negative responses (batch_size,)
policy_neg_logps = torch.randn(batch_size, dtype=torch.float32)

# Reference model log probabilities for positive responses (batch_size,)
ref_pos_logps = torch.randn(batch_size, dtype=torch.float32)

# Reference model log probabilities for negative responses (batch_size,)
ref_neg_logps = torch.randn(batch_size, dtype=torch.float32)

# Beta temperature parameter
beta = 0.1

# Reference free flag
reference_free = False

ARGS = {
    "policy_pos_logps": policy_pos_logps,
    "policy_neg_logps": policy_neg_logps,
    "ref_pos_logps": ref_pos_logps,
    "ref_neg_logps": ref_neg_logps,
    "beta": beta,
    "reference_free": reference_free,
}
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 2, 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
get_gold Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/eval_interventions/generate_funcs.py
code served (permissive licence) · get_code("813d811b5f586d21")
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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal model (not actually used in the function, but required)
class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = DummyModel()

# Create data dict with required keys based on function body
data = {
    'gold_input_ids': torch.tensor([[101, 2054, 2003, 1045], [102, 2054, 2003, 2054]]),
    'gold': ['What is I', 'What is what']
}

# Create config (not used in function body, but required parameter)
config = {}

ARGS = {
    'model': model,
    'data': data,
    'config': config
}
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
get_intervene_vector Ran
ran, honoured the contract we drafted
ajyl/dpo_toxic/toxicity/eval_interventions/hook_utils.py
code served (permissive licence) · get_code("2eb9d77d720c2173")
How it ran

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

import torch
import torch.nn as nn
import tempfile
import os

torch.manual_seed(0)

# Build a minimal GPT-like model structure
class MLP(nn.Module):
    def __init__(self, d_model, d_ff):
        super().__init__()
        self.c_fc = nn.Linear(d_model, d_ff)
        self.c_proj = nn.Linear(d_ff, d_model)
    
    def forward(self, x):
        return self.c_proj(self.gelu(self.c_fc(x)))

class TransformerBlock(nn.Module):
    def __init__(self, d_model, d_ff):
        super().__init__()
        self.mlp = MLP(d_model, d_ff)
    
    def forward(self, x):
        return self.mlp(x)

class Transformer(nn.Module):
    def __init__(self, d_model, d_ff, n_layer):
        super().__init__()
        self.h = nn.ModuleList([TransformerBlock(d_model, d_ff) for _ in range(n_layer)])
    
    def forward(self, x):
        for block in self.h:
            x = block(x)
        return x

class MinimalGPT(nn.Module):
    def __init__(self, d_model, d_ff, n_layer):
        super().__init__()
        self.config = type('Config', (), {'n_layer': n_layer, 'd_model': d_model})()
        self.transformer = Transformer(d_model, d_ff, n_layer)
        self.device = 'cpu'
    
    def forward(self, x):
        return self.transformer(x)

# Create model
d_model = 4
d_ff = 8
n_layer = 2
model = MinimalGPT(d_model, d_ff, n_layer)

# Create toxic_vector
toxic_vector = torch.randn(d_model)

# Save toxic_vector to a temp file for testing
temp_dir = tempfile.gettempdir()
toxic_path = os.path.join(temp_dir, 'toxic_vector.pt')
torch.save(toxic_vector, toxic_path)

# Test different config types
config_mlp_w_out = {
    'type': 'mlp_w_out',
    'layer': 0,
    'idx': 0
}

config_mlp_w_in = {
    'type': 'mlp_w_in',
    'w_ins': [(0, 0)],
}

config_toxic_probe = {
    'type': 'toxic_probe',
    'datapath': toxic_path
}

config_svd = {
    'type': 'svd',
    'topk_sorted_score': 10,
    'idx': 0,
    'datapath': toxic_path
}

config_random = {
    'type': 'random'
}

ARGS = {
    'model': model,
    'config': config_random
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (8,) — shape (8,) 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
get_kl_div Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/train_dpo/trainers.py
code served (permissive licence) · get_code("9e84c0d9c78a5cad")
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
from torch.nn import KLDivLoss

torch.manual_seed(0)

# Create KLDivLoss criterion
kl_criterion = KLDivLoss(reduction='none')

# Create small logit tensors
# Shape: (batch_size=2, vocab_size=4)
pos_pi_logits = torch.randn(2, 4)
neg_pi_logits = torch.randn(2, 4)
pos_ref_logits = torch.randn(2, 4)
neg_ref_logits = torch.randn(2, 4)

ARGS = {
    'kl_criterion': kl_criterion,
    'pos_pi_logits': pos_pi_logits,
    'neg_pi_logits': neg_pi_logits,
    'pos_ref_logits': pos_ref_logits,
    'neg_ref_logits': neg_ref_logits
}
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
get_local_dir Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/train_dpo/dpo_utils.py
code served (permissive licence) · get_code("8ab43db002bf984d")
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 str. 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 os
import tempfile
import getpass

# Create a temporary directory that exists for testing
temp_dir = tempfile.mkdtemp()

# Create the ARGS dictionary with valid arguments for get_local_dir
ARGS = {
    'prefixes_to_resolve': [temp_dir, '/tmp', '/var/tmp']
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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_local_run_dir Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/train_dpo/dpo_utils.py
code served (permissive licence) · get_code("1df5ede8f8950a70")
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 str. 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 os
import tempfile
from typing import List

# Create a temporary directory to use as a base for local_dirs
temp_base = tempfile.gettempdir()

# Define arguments for get_local_run_dir
ARGS = {
    'exp_name': 'test_experiment_001',
    'local_dirs': [temp_base]
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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_prompts Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/eval_interventions/generate_funcs.py
code served (permissive licence) · get_code("d635938df605fbd3")
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 torch.nn as nn

torch.manual_seed(0)

# Build a minimal model (the function doesn't actually use the model)
class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = DummyModel()

# Build data dict with required keys
data = {
    'prompt_input_ids': torch.randint(0, 100, (2, 4)),  # batch=2, seq_len=4
    'prompts': ['This is prompt one', 'This is prompt two']
}

# Build a minimal config (the function doesn't use it)
config = {
    'model_name': 'dummy',
    'hidden_size': 768
}

ARGS = {
    'model': model,
    'data': data,
    'config': config
}
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
get_remote_file Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/train_dpo/dpo_utils.py
code served (permissive licence) · get_code("e7ce4c19888c6df6")
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 str. 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 os
import socket
import tempfile

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()

# Get the current hostname
current_hostname = socket.gethostname()

# Create a test local path
test_local_path = os.path.join(temp_dir, "test_file.txt")

# Create a remote path string - using local hostname to avoid actual SCP calls
# Format is "hostname:path"
remote_path = f"{current_hostname}:/tmp/test_remote_file.txt"

ARGS = {
    "remote_path": remote_path,
    "local_path": test_local_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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/eval_interventions/eval_utils.py
code served (permissive licence) · get_code("cba91edd374a3e28")
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 json
import tempfile
import os

# Create a temporary .jsonl file
temp_dir = tempfile.mkdtemp()
jsonl_path = os.path.join(temp_dir, "test_data.jsonl")

# Write some test data to the .jsonl file
test_data = [
    {"text": "Hello world", "label": 1},
    {"text": "Goodbye world", "label": 0}
]

with open(jsonl_path, 'w') as f:
    for item in test_data:
        f.write(json.dumps(item) + '\n')

# Define the data_config dictionary
data_config = {
    'datapath': jsonl_path
}

ARGS = {
    'data_config': data_config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets — 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
run_dummy Ran
ran, honoured the contract we drafted
ajyl/dpo_toxic/toxicity/eval_interventions/metric_funcs.py
code served (permissive licence) · get_code("f5813daae4f9b8f5")
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 int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = DummyModel()

data = [
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
    (torch.randn(2, 4), torch.randint(0, 3, (2,)))
]

intervene_results = {
    "intervention_1": torch.randn(2, 3),
    "intervention_2": torch.randn(2, 3)
}

config = {
    "learning_rate": 0.001,
    "batch_size": 2,
    "epochs": 10
}

ARGS = {
    "model": model,
    "data": data,
    "intervene_results": intervene_results,
    "config": config
}
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 int, ndim 0, dtype family int, 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
run_f1 Ran
ran, honoured the contract we drafted
ajyl/dpo_toxic/toxicity/eval_interventions/metric_funcs.py
code served (permissive licence) · get_code("044b24804e21d67d")
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 float64, ndim 0, 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
import numpy as np

torch.manual_seed(0)

# Stand-in tokenizer with pad_token_id
class StandInTokenizer:
    def __init__(self):
        self.pad_token_id = 0

# Stand-in model with tokenizer
class StandInModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.tokenizer = StandInTokenizer()

# Create model
model = StandInModel()

# Create data dict with gold_input_ids
# Shape: (batch_size=2, seq_len=4)
# Using pad_token_id=0 for some positions
data = {
    'gold_input_ids': torch.tensor([
        [1, 2, 3, 0],
        [2, 3, 4, 5]
    ], dtype=torch.long)
}

# Create intervene_results dict with pred_tokens
# Same shape as gold_input_ids
intervene_results = {
    'pred_tokens': torch.tensor([
        [1, 2, 3, 0],
        [2, 3, 5, 0]
    ], dtype=torch.long)
}

# Create config (can be empty or minimal)
config = {}

ARGS = {
    'model': model,
    'data': data,
    'intervene_results': intervene_results,
    'config': config
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
tokenize Ran
ran; our contract draft was wrong, not the code
ajyl/dpo_toxic/toxicity/eval_interventions/eval_utils.py
code served (permissive licence) · get_code("9727f348a587c477")
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 torch.nn as nn

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.padding_side = 'left'
    
    def __call__(self, texts, max_length=None, padding=False, truncation=False, return_tensors=None):
        batch_size = len(texts) if isinstance(texts, list) else 1
        seq_len = max_length if max_length else 8
        
        input_ids = torch.randint(0, 100, (batch_size, seq_len))
        attention_mask = torch.ones(batch_size, seq_len)
        
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

config = {
    'max_prompt_size': 16,
    'max_new_tokens': 8
}

data = [
    {'prompt': 'What is AI?', 'gold': 'Artificial Intelligence is...'},
    {'prompt': 'Explain ML', 'gold': 'Machine Learning is...'}
]

tokenizer = MockTokenizer()

ARGS = {
    'tokenizer': tokenizer,
    'data': data,
    'config': config
}
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
get_svd_u_vec Not yet run
unverified (harvested, no recorded run)
ajyl/dpo_toxic/toxicity/eval_interventions/hook_utils.py
code served (permissive licence) · get_code("0e4cc3ba12263f9d")
How it ran

no invocation recorded.

rank_value_vecs Not yet run
unverified (harvested, no recorded run)
ajyl/dpo_toxic/toxicity/eval_interventions/hook_utils.py
code served (permissive licence) · get_code("43d32c9d46ad3c9a")
How it ran

no invocation recorded.

Also present in other papers' code

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

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

FunctionAlso present inEarliest-datedOthers named
get_remote_file 15 other papers
2 dated earlier, 1 the same month, 12 later
2309.16240 (2023-09)
Beyond Reverse KL: Generalizing Direct Preference Optimization with Diverse Divergence Constraints
2312.00267 (2023-12)
Sample Efficient Preference Alignment in LLMs via Active Exploration
2401.13275 (2024-01)
Can AI Assistants Know What They Don't Know?
and 12 more not named here
get_local_dir 10 other papers
1 dated earlier, 1 the same month, 8 later
2309.16240 (2023-09)
Beyond Reverse KL: Generalizing Direct Preference Optimization with Diverse Divergence Constraints
2401.13275 (2024-01)
Can AI Assistants Know What They Don't Know?
2402.10571 (2024-02)
Direct Preference Optimization with an Offset
and 7 more not named here
dpo_loss 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
get_gold 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
get_intervene_vector 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
get_local_run_dir 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
get_prompts 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
load_data 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
run_dummy 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis
run_f1 1 other paper
1 later
2411.06424 (2024-11)
How Does DPO Reduce Toxicity? A Mechanistic Neuron-Level Analysis

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

While alignment algorithms are now commonly used to tune pre-trained language models towards a user's preferences, we lack explanations for the underlying mechanisms in which models become ``aligned'', thus making it difficult to explain phenomena like jailbreaks. In this work we study a popular algorithm, direct preference optimization (DPO), and the mechanisms by which it reduces toxicity. Namely, we first study how toxicity is represented and elicited in a pre-trained language model, GPT2-medium. We then apply DPO with a carefully crafted pairwise dataset to reduce toxicity. We examine how the resulting model averts toxic outputs, and find that capabilities learned from pre-training are not removed, but rather bypassed. We use this insight to demonstrate a simple method to un-align the model, reverting it back to its toxic behavior.

For agents

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

get_harvested_code_for_paper("2401.01967")
get_code_for_paper("2401.01967")
have("2401.01967")

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

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

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

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

Connect an agent — have() is free.