SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.15159 · ACL · 2024

Machine Unlearning of Pre-trained Large Language Models

Eli Chien, Tianhao Wang, Xiang Yue, Minxin Du, Xinyao Niu, Zezhou Cheng, Jin Yao

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 1 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/2402.15159.json · badge: /api/ran/2402.15159.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
yaojin17/unlearning_llm canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
adapter_load_dataset Ran
ran; our contract draft was wrong, not the code
yaojin17/unlearning_llm/llm_unlearn/utils/save_tokenized_dataset.py
code served (permissive licence) · get_code("ee7aee459bcbaaeb")
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 tempfile
import os
from datasets import Dataset

# Create a temporary directory to simulate a dataset
temp_dir = tempfile.mkdtemp()

# Create a simple dataset and save it to disk
sample_data = {
    'text': ['Hello world', 'This is a test', 'Another example'],
    'extra_column': [1, 2, 3],
    'another_column': ['a', 'b', 'c']
}
dataset = Dataset.from_dict(sample_data)
dataset_path = os.path.join(temp_dir, 'test_dataset')
dataset.save_to_disk(dataset_path)

ARGS = {
    'dataset_path': dataset_path
}
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 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
compute_kl Ran
ran, honoured the contract we drafted
yaojin17/unlearning_llm/llm_unlearn/methods/ascent_plus_KLdivergence.py
code served (permissive licence) · get_code("62345832792f7ce7")
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 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 torch.nn as nn

torch.manual_seed(0)

class SimpleLanguageModel(nn.Module):
    """Minimal language model that outputs logits."""
    def __init__(self, vocab_size=100, 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=None, labels=None):
        x = self.embedding(input_ids)
        logits = self.linear(x)
        
        class Output:
            pass
        
        output = Output()
        output.logits = logits
        output.loss = None
        if labels is not None:
            loss_fn = nn.CrossEntropyLoss()
            output.loss = loss_fn(logits.view(-1, logits.size(-1)), labels.view(-1))
        return output

# Create models
pretrained_model = SimpleLanguageModel(vocab_size=100, hidden_size=4)
current_model = SimpleLanguageModel(vocab_size=100, hidden_size=4)

# Create a batch with required keys
batch = {
    'input_ids': torch.randint(0, 100, (2, 5)),
    'attention_mask': torch.ones(2, 5, dtype=torch.long),
    'labels': torch.randint(0, 100, (2, 5))
}

# Set device to CPU
device = torch.device('cpu')

ARGS = {
    'pretrained_model': pretrained_model,
    'current_model': current_model,
    'batch': batch,
    'device': device
}
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 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
do_plot Ran
ran; our contract draft was wrong, not the code
yaojin17/unlearning_llm/llm_unlearn/utils/mia_eval.py
code served (permissive licence) · get_code("dcb359c213884c2b")
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 numpy as np
import matplotlib.pyplot as plt

# Set random seed for reproducibility
np.random.seed(0)

# Create mock prediction scores and answers
# prediction: array of continuous scores (e.g., model confidence)
prediction = np.array([0.1, 0.9, 0.3, 0.8, 0.2, 0.7, 0.15, 0.85])

# answers: array of binary labels (0 or 1)
answers = np.array([0, 1, 0, 1, 0, 1, 0, 1])

# Define the sweep function (using the default provided)
def sweep_fn(score, x):
    from sklearn.metrics import auc, roc_curve
    fpr, tpr, _ = roc_curve(x, -score)
    acc = np.max(1 - (fpr + (1 - tpr)) / 2)
    return (fpr, tpr, auc(fpr, tpr), acc)

# Build ARGS dictionary with all parameters for do_plot
ARGS = {
    'prediction': prediction,
    'answers': answers,
    'sweep_fn': sweep_fn,
    'metric': 'auc',
    'legend': 'Test Attack',
    'output_dir': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, sklearn — 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
load_jsonl Ran
ran; our contract draft was wrong, not the code
yaojin17/unlearning_llm/llm_unlearn/utils/mia_eval.py
code served (permissive licence) · get_code("df5028784e848964")
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 tempfile
import json
import os

# Create a temporary JSONL file with some test data
temp_dir = tempfile.mkdtemp()
input_path = os.path.join(temp_dir, "test_data.jsonl")

# Write some sample JSONL data
with open(input_path, 'w') as f:
    for i in range(5):
        f.write(json.dumps({"id": i, "text": f"sample {i}"}) + "\n")

ARGS = {
    "input_path": input_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tqdm — 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
sweep Not yet run
unverified (harvested, no recorded run)
yaojin17/unlearning_llm/llm_unlearn/utils/mia_eval.py
pointer only (licence: MIT); the stored copy get_code serves, from vlgiitr/confidence-is-all-you-need, is pointer only (licence: NONE) · get_code("18da2122420deb20")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from vlgiitr/confidence-is-all-you-need, and GitHub detected no licence in that repository 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. No invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 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
sweep 2 other papers
1 dated earlier, 1 later
2112.03570 (2021-12)
Membership Inference Attacks From First Principles
2407.01919 (2024-07)
A Method to Facilitate Membership Inference Attacks in Deep Learning Models

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

This study investigates the concept of the 'right to be forgotten' within the context of large language models (LLMs). We explore machine unlearning as a pivotal solution, with a focus on pre-trained models-a notably under-researched area. Our research delineates a comprehensive framework for machine unlearning in pretrained LLMs, encompassing a critical analysis of seven diverse unlearning methods. Through rigorous evaluation using curated datasets from arXiv, books, and GitHub, we establish a robust benchmark for unlearning performance, demonstrating that these methods are over 10 5 times more computationally efficient than retraining. Our results show that integrating gradient ascent with gradient descent on in-distribution data improves hyperparameter robustness. We also provide detailed guidelines for efficient hyperparameter tuning in the unlearning process. Our findings advance the discourse on ethical AI practices, offering substantive insights into the mechanics of machine unlearning for pretrained LLMs and underscoring the potential for responsible AI development. 1

For agents

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

get_harvested_code_for_paper("2402.15159")
get_code_for_paper("2402.15159")
have("2402.15159")

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

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

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

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

Connect an agent — have() is free.