SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.01920 · 2024

To Forget or Not? Towards Practical Knowledge Unlearning for Large Language Models

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 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; 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/2407.01920.json · badge: /api/ran/2407.01920.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
zjunlp/knowundo canonical (classifier label)
classifier basis: census
6 ran · 3 no recorded run
FunctionStatusWhere it lives
add_dataset_index Ran
ran; our contract draft was wrong, not the code
zjunlp/knowundo/pretrain/config.py
code served (permissive licence) · get_code("669009a59e41c2c9")
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 Mock. 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 numpy as np
from unittest.mock import Mock

# Create a mock dataset object that has the required methods
mock_dataset = Mock()

# The function calls len(dataset) and dataset.add_column('index', indexing)
# So we need to mock these behaviors
mock_dataset.__len__ = Mock(return_value=5)
mock_dataset.add_column = Mock(return_value=mock_dataset)

ARGS = {
    'dataset': mock_dataset
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Mock — a Mock 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
compute_cosine_similarity Ran
ran; our contract draft was wrong, not the code
zjunlp/knowundo/pretrain/localization.py
pointer only (licence: MIT); the stored copy get_code serves, from AIFrontierLab/KnowledgeSmith, is pointer only (licence: NONE) · get_code("835be88a656b57c2")
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 AIFrontierLab/KnowledgeSmith, 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. A run is recorded.

compute_info Ran
ran; our contract draft was wrong, not the code
zjunlp/knowundo/pretrain/localization.py
code served (permissive licence) · get_code("b07fba5194f89d4c")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 with lora parameters
class MinimalModelWithLoRA(nn.Module):
    def __init__(self):
        super().__init__()
        self.lora_linear = nn.Linear(4, 3)
        self.other_linear = nn.Linear(3, 2)
    
    def forward(self, input_ids, labels, attention_mask):
        x = self.lora_linear(input_ids)
        x = self.other_linear(x)
        loss = torch.mean((x - labels) ** 2)
        
        class Output:
            pass
        
        output = Output()
        output.loss = loss
        return output

# Create a minimal dataloader
def create_dataloader():
    dataset_size = 4
    batch_size = 2
    
    # Create dummy data: (input_ids, labels, attention_mask)
    data = []
    for i in range(dataset_size // batch_size):
        input_ids = torch.randn(batch_size, 4)
        labels = torch.randn(batch_size, 2)
        attention_mask = torch.ones(batch_size, 4)
        data.append((input_ids, labels, attention_mask))
    
    # Add dataset size attribute
    class DataLoaderWithDataset:
        def __init__(self, data):
            self.data = data
            self.dataset = type('Dataset', (), {'__len__': lambda self: 4})()
        
        def __iter__(self):
            return iter(self.data)
        
        def __len__(self):
            return len(self.data)
    
    return DataLoaderWithDataset(data)

model = MinimalModelWithLoRA()
dataloader = create_dataloader()
device = 'cpu'

ARGS = {
    'model': model,
    'dataloader': dataloader,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
compute_kl Ran
ran, honoured the contract we drafted
zjunlp/knowundo/llm_unlearn/methods/ascent_plus_KLdivergence.py
code served (permissive licence) · get_code("798c7fa0566c9a0c")
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):
    def __init__(self, vocab_size=100, hidden_size=4):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.lm_head = nn.Linear(hidden_size, vocab_size)
        self.device = 'cpu'
    
    def forward(self, input_ids, attention_mask=None, labels=None):
        embeddings = self.embedding(input_ids)
        logits = self.lm_head(embeddings)
        
        # Create a simple output object with logits attribute
        class ModelOutput:
            pass
        
        output = ModelOutput()
        output.logits = logits
        return output

# Create models
pretrained_model = SimpleLanguageModel(vocab_size=100, hidden_size=4)
pretrained_model.device = 'cpu'

current_model = SimpleLanguageModel(vocab_size=100, hidden_size=4)
current_model.device = 'cpu'

# Create a batch dictionary 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))
}

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
find_all_linear_names Ran
ran; our contract draft was wrong, not the code
zjunlp/knowundo/pretrain/pretrain.py
code served (permissive licence) · get_code("649fc48067a48529")
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 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal model with Linear layers
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 3)
        self.layer2 = nn.Sequential(
            nn.Linear(3, 2),
            nn.ReLU()
        )
        self.lm_head = nn.Linear(2, 5)
        self.other_linear = nn.Linear(5, 4)
    
    def forward(self, x):
        x = self.layer1(x)
        x = self.layer2(x)
        x = self.lm_head(x)
        x = self.other_linear(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — 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
replicate_samples Ran
ran; our contract draft was wrong, not the code
zjunlp/knowundo/pretrain/data_module.py
code served (permissive licence) · get_code("0d97632222d2ac81")
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)

# Analyze the function:
# - examples: a dict with keys, and values that are iterables
# - num_copies: an int (default 2)
# The function iterates over keys and values, replicating each value num_copies times

# Create a simple examples dict with lists as values
examples = {
    "input_ids": [1, 2, 3],
    "attention_mask": [1, 1, 0],
    "labels": [0, 1, 0]
}

num_copies = 2

ARGS = {
    "examples": examples,
    "num_copies": num_copies
}
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
convert_raw_data_to_model_format Not yet run
unverified (harvested, no recorded run)
zjunlp/knowundo/pretrain/data_module.py
pointer only (licence: MIT); the stored copy get_code serves, from wujwyi/CMC, is pointer only (licence: NONE) · get_code("7dec325d088c0b76")
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 wujwyi/CMC, 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.

convert_to_model_format_with_random_label Not yet run
unverified (harvested, no recorded run)
zjunlp/knowundo/pretrain/data_module.py
code served (permissive licence) · get_code("6f99db2c45b39255")
How it ran

no invocation recorded.

get_model_identifiers_from_yaml Not yet run
unverified (harvested, no recorded run)
zjunlp/knowundo/pretrain/config.py
pointer only (licence: MIT); the stored copy get_code serves, from safolab-wisc/fiubench, is pointer only (licence: NONE) · get_code("06448b0513272463")
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 safolab-wisc/fiubench, 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 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 2 the same month, 5 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
find_all_linear_names 22 other papers
10 dated earlier, 1 the same month, 10 later, 1 same year, order not determinable
2308.09936 (2023-08)
BLIVA: A Simple Multimodal LLM for Better Handling of Text-Rich Visual Questions
2310.13023 (2023-10)
GraphGPT: Graph Instruction Tuning for Large Language Models
2311.13194 (2023-11)
Towards Improving Document Understanding: An Exploration on Text-Grounding via MLLMs
and 19 more not named here
get_model_identifiers_from_yaml 9 other papers
3 dated earlier, 1 the same month, 5 later
2401.06121 (2024-01)
TOFU: A Task of Fictitious Unlearning for LLMs
2406.11614 (2024-06)
Intrinsic Test of Unlearning Using Parametric Knowledge Traces
2406.13356 (2024-06)
UNLEARNING OR OBFUSCATING? JOGGING THE MEM-ORY OF UNLEARNED LLMS VIA BENIGN RELEARNING CONTENT WARNING: THIS MANUSCRIPT CONTAINS EXAMPLES OF HARMFUL/HAZARDOUS TEXT
and 6 more not named here
convert_raw_data_to_model_format 5 other papers
1 dated earlier, 4 later
2401.06121 (2024-01)
TOFU: A Task of Fictitious Unlearning for LLMs
2410.07163 (2024-10)
Simplicity Prevails: Rethinking Negative Preference Optimization for LLM Unlearning
2410.08109 (2024-10)
A Closer Look at Machine Unlearning for Large Language Models
and 2 more not named here
compute_cosine_similarity 2 other papers
2 later
2502.11190 (2025-02)
ReLearn: Unlearning via Learning for Large Language Models
2510.02392 (2025-10)
KnowledgeSmith: Uncovering Knowledge Updating in LLMs with Model Editing and Unlearning
add_dataset_index 1 other paper
1 later
2410.15153 (2024-10)
Evaluating Deep Unlearning in Large Language 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

Large Language Models (LLMs) trained on extensive corpora inevitably retain sensitive data, such as personal privacy information and copyrighted material. Recent advancements in knowledge unlearning involve updating LLM parameters to erase specific knowledge. However, current unlearning paradigms are mired in vague forgetting boundaries, often erasing knowledge indiscriminately. In this work, we introduce KnowUnDo, a benchmark containing copyrighted content and user privacy domains to evaluate if the unlearning process inadvertently erases essential knowledge. Our findings indicate that existing unlearning methods often suffer from excessive unlearning. To address this, we propose a simple yet effective method, MemFlex, which utilizes gradient information to precisely target and unlearn sensitive parameters. Experimental results show that MemFlex is superior to existing methods in both precise knowledge unlearning and general knowledge retaining of LLMs. Code and dataset are released at https://github.com/zjunlp/KnowUnDo.

For agents

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

get_harvested_code_for_paper("2407.01920")
get_code_for_paper("2407.01920")
have("2407.01920")

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

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

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

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

Connect an agent — have() is free.