SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.03523 · ICLR · 2025

A Probabilistic Perspective on Unlearning and Alignment for Large Language Models

Stephan Ünnemann, Yan Scholten, Leo Schwinn

arXiv · PDF · Open in the Atlas

Code that ran

5 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 3 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/2410.03523.json · badge: /api/ran/2410.03523.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
yascho/probabilistic-unlearning canonical (classifier label)
classifier basis: census
5 ran · 3 no recorded run
FunctionStatusWhere it lives
create_model Ran
ran; our contract draft was wrong, not the code
yascho/probabilistic-unlearning/models.py
code served (permissive licence) · get_code("97ff4e87d047ea7f")
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 unittest.mock import Mock, MagicMock

torch.manual_seed(0)

# Create a minimal mock tokenizer
class MockTokenizer:
    def __init__(self):
        self.padding_side = 'right'
        self.pad_token = None
    
    def add_special_tokens(self, special_tokens_dict):
        if 'pad_token' in special_tokens_dict:
            self.pad_token = special_tokens_dict['pad_token']

# Create a minimal mock model
class MockCausalLM(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def to(self, device):
        super().to(device)
        return self

# Create mock for AutoTokenizer.from_pretrained
def mock_tokenizer_from_pretrained(model_name):
    return MockTokenizer()

# Create mock for AutoModelForCausalLM.from_pretrained
def mock_model_from_pretrained(model_name, use_flash_attention_2=False, torch_dtype='auto', revision=None):
    return MockCausalLM()

# Patch the imports
import transformers
transformers.AutoTokenizer.from_pretrained = mock_tokenizer_from_pretrained
transformers.AutoModelForCausalLM.from_pretrained = mock_model_from_pretrained

# Define hparams dict
hparams = {
    'tokenizer': 'gpt2',
    'model': 'gpt2',
    'checkpoint': 'main',
    'device': 'cpu'
}

ARGS = {
    'hparams': hparams
}
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 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
data_collator_unlearning Ran
ran; our contract draft was wrong, not the code
yascho/probabilistic-unlearning/unlearning/dataloader.py
code served (permissive licence) · get_code("2e3349e4cd7e6e7d")
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

torch.manual_seed(0)

# Each sample is a tuple of (forget_sample, forget_question, forget_answer, retain_sample)
# Where forget_sample and retain_sample are dicts with 'input_ids', 'labels', 'attention_mask'

samples = [
    (
        {
            'input_ids': [1, 2, 3, 4],
            'labels': [0, 1, 0, 1],
            'attention_mask': [1, 1, 1, 1]
        },
        "What is this?",
        "This is an answer.",
        {
            'input_ids': [5, 6, 7, 8],
            'labels': [1, 0, 1, 0],
            'attention_mask': [1, 1, 1, 0]
        }
    ),
    (
        {
            'input_ids': [9, 10, 11, 12],
            'labels': [1, 1, 0, 0],
            'attention_mask': [1, 1, 0, 0]
        },
        "What is that?",
        "That is another answer.",
        {
            'input_ids': [13, 14, 15, 16],
            'labels': [0, 0, 1, 1],
            'attention_mask': [1, 0, 1, 1]
        }
    )
]

ARGS = {
    'samples': samples
}
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
encode_finetune Ran
ran; our contract draft was wrong, not the code
yascho/probabilistic-unlearning/unlearning/encoding.py
code served (permissive licence) · get_code("a71ae147e6732756")
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
from transformers import AutoTokenizer

# Create a minimal stand-in tokenizer
class MockTokenizer:
    def __init__(self):
        self.padding_side = 'left'
        self.eos_token = '</s>'
        self.pad_token_id = 0
        self.vocab_size = 1000
        
    def __call__(self, text, truncation=False, padding=None, max_length=None, add_special_tokens=False):
        # Simulate tokenization
        tokens = text.split()
        input_ids = [hash(token) % self.vocab_size for token in tokens]
        
        if add_special_tokens:
            input_ids = [101] + input_ids + [102]
        
        if padding == 'max_length' and max_length:
            if len(input_ids) < max_length:
                input_ids = input_ids + [self.pad_token_id] * (max_length - len(input_ids))
            else:
                input_ids = input_ids[:max_length]
        
        attention_mask = [1 if token_id != self.pad_token_id else 0 for token_id in input_ids]
        
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

# Create hparams dict
hparams = {
    'question_start_tag': '<Q>',
    'question_end_tag': '</Q>',
    'answer_tag': '<A>',
    'max_length': 64
}

# Create tokenizer
tokenizer = MockTokenizer()

# Create example input
x = {
    'question': 'What is the capital of France?',
    'answer': 'Paris'
}

ARGS = {
    'hparams': hparams,
    'tokenizer': tokenizer,
    'x': x,
    'add_tags': True
}
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 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
preprocess Ran
ran; our contract draft was wrong, not the code
yascho/probabilistic-unlearning/finetuning/preprocessing.py
code served (permissive licence) · get_code("b14c8a1dbd34e6e8")
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
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
        self.pad_token_id = 0
        self.pad_token = "[PAD]"
    
    def __call__(self, text, truncation=False, padding=None, max_length=None, add_special_tokens=False):
        # Simple mock tokenization: split text and assign token ids
        tokens = text.split()
        token_ids = [101] + [i + 102 for i in range(len(tokens))] + [102]  # [CLS] + tokens + [SEP]
        
        if max_length and len(token_ids) > max_length:
            token_ids = token_ids[:max_length]
        
        if padding == 'max_length' and max_length:
            while len(token_ids) < max_length:
                token_ids.append(self.pad_token_id)
        
        attention_mask = [1 if token_id != self.pad_token_id else 0 for token_id in token_ids]
        
        return {
            'input_ids': token_ids,
            'attention_mask': attention_mask
        }

# Create hparams dict
hparams = {
    'question_start_tag': '[Q]',
    'question_end_tag': '[/Q]',
    'answer_tag': '[A]',
    'max_length': 64
}

# Create tokenizer
tokenizer = MinimalTokenizer()

# Create sample input
x = {
    'question': 'What is the capital of France?',
    'answer': 'Paris'
}

ARGS = {
    'hparams': hparams,
    'tokenizer': tokenizer,
    'x': x
}
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
preprocess_dataset Ran
ran; our contract draft was wrong, not the code
yascho/probabilistic-unlearning/finetuning/preprocessing.py
code served (permissive licence) · get_code("d701c28cf7e2b3bf")
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 torch.nn as nn
from datasets import Dataset

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
        self.pad_token_id = 0
        self.vocab_size = 100
    
    def __call__(self, text, truncation=False, padding=None, max_length=None, add_special_tokens=False):
        tokens = text.split()
        input_ids = [i % self.vocab_size for i in range(len(tokens))]
        
        if max_length and len(input_ids) > max_length:
            input_ids = input_ids[:max_length]
        
        if padding == 'max_length' and max_length:
            while len(input_ids) < max_length:
                input_ids.append(self.pad_token_id)
        
        attention_mask = [1 if token != self.pad_token_id else 0 for token in input_ids]
        
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

dataset_dict = {
    'question': ['What is AI?', 'How does ML work?'],
    'answer': ['AI is artificial intelligence', 'ML learns from data']
}

hparams = {
    'question_start_tag': '<q>',
    'question_end_tag': '</q>',
    'answer_tag': '<a>',
    'max_length': 64
}

tokenizer = MockTokenizer()

dataset = Dataset.from_dict(dataset_dict)

ARGS = {
    'dataset': dataset,
    'tokenizer': tokenizer,
    'hparams': hparams
}
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 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
create_model Not yet run
unverified (harvested, no recorded run)
yascho/probabilistic-unlearning/unlearning/model.py
code served (permissive licence) · get_code("0b7e2114f9a0ecab")
How it ran

no invocation recorded.

create_model Not yet run
unverified (harvested, no recorded run)
yascho/probabilistic-unlearning/finetuning/model.py
code served (permissive licence) · get_code("71b115a35fd345f5")
How it ran

no invocation recorded.

load_datasets Not yet run
unverified (harvested, no recorded run)
yascho/probabilistic-unlearning/unlearning/dataloader.py
code served (permissive licence) · get_code("6aaff75e95232315")
How it ran

no invocation recorded.

Also present in other papers' code

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

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

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

Repositories linked to this paper

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

Abstract

Comprehensive evaluation of Large Language Models (LLMs) is an open research problem. Existing evaluations rely on deterministic point estimates generated via greedy decoding. However, we find that deterministic evaluations fail to capture the whole output distribution of a model, yielding inaccurate estimations of model capabilities. This is particularly problematic in critical contexts such as unlearning and alignment, where precise model evaluations are crucial. To remedy this, we introduce the first formal probabilistic evaluation framework for LLMs. Namely, we propose novel metrics with high probability guarantees concerning the output distribution of a model. Our metrics are application-independent and allow practitioners to make more reliable estimates about model capabilities before deployment. Our experimental analysis reveals that deterministic evaluations falsely indicate successful unlearning and alignment, whereas our probabilistic evaluations better capture model capabilities. We show how to overcome challenges associated with probabilistic outputs in a case study on unlearning by introducing (1) a novel loss based on entropy optimization, and (2) adaptive temperature scaling. We demonstrate that our approach significantly enhances unlearning in probabilistic settings on recent benchmarks. Overall, our proposed shift from point estimates to probabilistic evaluations of output distributions represents an important step toward comprehensive evaluations of LLMs. 1

For agents

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

get_harvested_code_for_paper("2410.03523")
get_code_for_paper("2410.03523")
have("2410.03523")

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

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

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

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

Connect an agent — have() is free.