SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.08847 · ICLR · 2025

Unintentional Unalignment: Likelihood Displacement in Direct Preference Optimization

Sanjeev Arora, Sadhika Malladi, Boris Hanin, Danqi Chen, Noam Razin, Adithya Bhaskar

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 0 failures of our instrument; 0 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/2410.08847.json · badge: /api/ran/2410.08847.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
princeton-nlp/unintentional-unalignment canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
get_and_log_hidden_embedding_based_pref_similarities Ran
ran, honoured the contract we drafted
princeton-nlp/unintentional-unalignment/compute_preference_similarity_per_example.py
code served (permissive licence) · get_code("00c93484ecc0d685")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned 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 as nn
from unittest.mock import MagicMock

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
        self.vocab = {
            "</s>": 0,
            "a": 1,
            "b": 2,
            "c": 3,
        }

# Create a minimal model that returns hidden states
class MinimalModel(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.hidden_size = hidden_size
        self.embedding = nn.Embedding(4, hidden_size)
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, input_ids, output_hidden_states=False):
        # input_ids shape: (batch_size, seq_len)
        embedded = self.embedding(input_ids)
        hidden = self.linear(embedded)
        
        # Create a mock output object
        output = MagicMock()
        if output_hidden_states:
            # hidden_states is a tuple of tensors, one per layer
            # We'll create a simple 2-layer model representation
            output.hidden_states = (embedded, hidden)
        return output

# Create a minimal logger
class MinimalLogger:
    def info(self, msg):
        pass
    
    def warn(self, msg):
        pass

# Create dataset with proper structure
tokenizer = MinimalTokenizer()
eos_id = tokenizer.vocab[tokenizer.eos_token]

# Create input tensors with padding
# query: 5 tokens (indices 1,2,3,1,0 where 0 is padding/eos)
# text_w (preferred): 8 tokens total (5 query + 3 output)
# text_l (dispreferred): 8 tokens total (5 query + 3 output)
query_tokens = torch.tensor([1, 2, 3, 1, eos_id])
preferred_tokens = torch.tensor([1, 2, 3, 1, eos_id, 2, 3, 1])
dispreferred_tokens = torch.tensor([1, 2, 3, 1, eos_id, 1, 1, 2])

dataset = [
    {
        'query': [query_tokens],
        'text_w': [preferred_tokens],
        'text_l': [dispreferred_tokens],
    },
    {
        'query': [query_tokens],
        'text_w': [preferred_tokens],
        'text_l': [dispreferred_tokens],
    }
]

model = MinimalModel(hidden_size=4)
logger = MinimalLogger()
device = 'cpu'

ARGS = {
    'logger': logger,
    'dataset': dataset,
    'model': model,
    'device': device,
    'tokenizer': tokenizer,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, tqdm — 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_and_log_preferred_dispreferred_normalized_edit_distance Ran
ran, honoured the contract we drafted
princeton-nlp/unintentional-unalignment/compute_preference_similarity_per_example.py
code served (permissive licence) · get_code("adcb81212551f6d7")
How it ran

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

import torch
from unittest.mock import Mock

torch.manual_seed(0)

# Create a mock logger that has an info method
logger = Mock()
logger.info = Mock()

# Create a dataset with the expected structure
# Each example needs:
# - 'query': list with one element that is a tensor
# - 'text_w': list with one element that is a tensor (preferred)
# - 'text_l': list with one element that is a tensor (dispreferred)

dataset = [
    {
        'query': [torch.tensor([1, 2])],  # query_len = 2
        'text_w': [torch.tensor([3, 4, 5, 6])],  # preferred tokens after query
        'text_l': [torch.tensor([3, 7, 8, 9])],  # dispreferred tokens after query
    },
    {
        'query': [torch.tensor([1, 2, 3])],  # query_len = 3
        'text_w': [torch.tensor([4, 5, 6, 7, 8])],  # preferred tokens after query
        'text_l': [torch.tensor([4, 9, 10, 11, 12])],  # dispreferred tokens after query
    },
]

ARGS = {
    'logger': logger,
    'dataset': dataset,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

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

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

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

Direct Preference Optimization (DPO) and its variants are increasingly used for aligning language models with human preferences. Although these methods are designed to teach a model to generate preferred responses more frequently relative to dispreferred responses, prior work has observed that the likelihood of preferred responses often decreases during training. The current work sheds light on the causes and implications of this counterintuitive phenomenon, which we term likelihood displacement. We demonstrate that likelihood displacement can be catastrophic, shifting probability mass from preferred responses to responses with an opposite meaning. As a simple example, training a model to prefer No over Never can sharply increase the probability of Yes. Moreover, when aligning the model to refuse unsafe prompts, we show that such displacement can unintentionally lead to unalignment, by shifting probability mass from preferred refusal responses to harmful responses (e.g., reducing the refusal rate of Llama-3-8B-Instruct from 74.4% to 33.4%). We theoretically characterize that likelihood displacement is driven by preferences that induce similar embeddings, as measured by a centered hidden embedding similarity (CHES) score. Empirically, the CHES score enables identifying which training samples contribute most to likelihood displacement in a given dataset. Filtering out these samples effectively mitigated unintentional unalignment in our experiments. More broadly, our results highlight the importance of curating data with sufficiently distinct preferences, for which we believe the CHES score may prove valuable. 1

For agents

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

get_harvested_code_for_paper("2410.08847")
get_code_for_paper("2410.08847")
have("2410.08847")

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

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

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

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

Connect an agent — have() is free.