SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.19715 · EMNLP · 2025

Graceful Forgetting in Generative Language Models

Yike Guo, Wei Xue, Chi-Min Chan, Yiyang Cai, Yulong Liu, Chunyang Jiang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 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 6 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-24; 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/2505.19715.json · badge: /api/ran/2505.19715.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
rubickkcibur/LWF canonical (classifier label)
classifier basis not recorded on the link
6 ran · 1 no recorded run
FunctionStatusWhere it lives
build_model Ran
ran on a synthesized input
rubickkcibur/LWF/trainLM_tools.py
code served (permissive licence) · get_code("7a2798b6dec9fdba")
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
from dataclasses import dataclass

torch.manual_seed(0)

# Create mock logger
logger = Mock()
logger.info = Mock()

# Create mock model_args
model_args = Mock()
model_args.model_name_or_path = "gpt2"
model_args.peft_model_path = ""

# Create mock training_args
training_args = Mock()
training_args.cache_dir = None
training_args.model_max_length = 512
training_args.use_lora = False
training_args.gradient_checkpointing = False

# Create mock lora_args
lora_args = Mock()
lora_args.lora_r = 8
lora_args.lora_alpha = 16
lora_args.lora_dropout = 0.05
lora_args.lora_bias = "none"

# Mock the transformers functions to avoid actual model loading
import transformers

original_auto_config = transformers.AutoConfig.from_pretrained
original_auto_tokenizer = transformers.AutoTokenizer.from_pretrained
original_auto_model = transformers.AutoModelForCausalLM.from_pretrained

def mock_config(*args, **kwargs):
    config = Mock()
    config.use_cache = True
    return config

def mock_tokenizer(*args, **kwargs):
    tokenizer = Mock()
    tokenizer.eos_token_id = 50256
    tokenizer.pad_token_id = 50256
    return tokenizer

def mock_model(*args, **kwargs):
    model = Mock(spec=nn.Module)
    model.gradient_checkpointing_enable = Mock()
    model.enable_input_require_grads = Mock()
    model.print_trainable_parameters = Mock()
    return model

transformers.AutoConfig.from_pretrained = mock_config
transformers.AutoTokenizer.from_pretrained = mock_tokenizer
transformers.AutoModelForCausalLM.from_pretrained = mock_model

ARGS = {
    "model_args": model_args,
    "training_args": training_args,
    "lora_args": lora_args,
    "logger": logger,
}
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
metric Ran
ran on a synthesized input
rubickkcibur/LWF/dataset_processor/gsm8k.py
code served (permissive licence) · get_code("613767452ccfb987")
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 float, 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 re

def metric(output_text, ground):

    def derive_num_from_output(output_text):
        new_text = output_text.lower()
        if 'the answer is' not in new_text:
            return None
        new_text = new_text.split('question:')[0]
        suffix = new_text.split('the answer is')
        if len(suffix) > 2:
            suffix = suffix[1]
        else:
            suffix = suffix[-1]
        suffix = suffix.strip()
        if '=' in suffix:
            suffix = suffix.split('=')[-1].strip()
        if len(suffix) <= 0:
            return None
        pattern = '(\\D*?)(\\d+\\.?\\d*)'
        ret = re.search(pattern, suffix.replace(',', ''))
        if ret is None:
            return None
        num = ret.group(2)
        if len(num) > 40:
            return None
        return num
    preds = [derive_num_from_output(txt) for txt in output_text]
    assert len(preds) == len(ground)
    acc = [1 if preds[i] is not None and int(float(preds[i])) == int(float(ground[i])) else 0 for i in range(len(preds))]
    return sum(acc) / len(acc)


# Create valid arguments for the metric function
output_text = [
    "Question: What is 2+2? The answer is 4",
    "Question: What is 5+3? The answer is 8"
]

ground = [
    "4",
    "8"
]

ARGS = {
    "output_text": output_text,
    "ground": ground
}
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 float, 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
metric Ran
ran on a synthesized input
rubickkcibur/LWF/dataset_processor/gsm8k_es.py
code served (permissive licence) · get_code("0229ae5a5851afa2")
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 float, 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 re

def metric(output_text, ground):

    def derive_num_from_output(output_text):
        new_text = output_text
        new_text = new_text.split('Pregunta:')[0]
        suffix = new_text.split('La respuesta es')
        if len(suffix) > 2:
            suffix = suffix[1]
        else:
            suffix = suffix[-1]
        suffix = suffix.strip()
        if '=' in suffix:
            suffix = suffix.split('=')[-1].strip()
        if len(suffix) <= 0:
            return None
        pattern = '(\\D*?)(\\d+\\.?\\d*)'
        ret = re.search(pattern, suffix.replace(',', ''))
        if ret is None:
            return None
        num = ret.group(2)
        if len(num) > 40:
            return None
        return num
    preds = [derive_num_from_output(txt) for txt in output_text]
    assert len(preds) == len(ground)
    acc = [1 if preds[i] is not None and int(float(preds[i])) == int(float(ground[i])) else 0 for i in range(len(preds))]
    return sum(acc) / len(acc)


# Setup code
output_text = [
    "La respuesta es 42",
    "Calcular: 5 + 3 = 8 La respuesta es 8",
]

ground = ["42", "8"]

ARGS = {
    "output_text": output_text,
    "ground": ground,
}
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 float, 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
metric Ran
ran on a synthesized input
rubickkcibur/LWF/dataset_processor/gsm8k_it.py
code served (permissive licence) · get_code("30c7c57bcdd3cbfd")
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 float, 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 re

def metric(output_text, ground):

    def derive_num_from_output(output_text):
        new_text = output_text
        new_text = new_text.split('Domanda:')[0]
        suffix = new_text.split('La risposta è')
        if len(suffix) > 2:
            suffix = suffix[1]
        else:
            suffix = suffix[-1]
        suffix = suffix.strip()
        if '=' in suffix:
            suffix = suffix.split('=')[-1].strip()
        if len(suffix) <= 0:
            return None
        pattern = '(\\D*?)(\\d+\\.?\\d*)'
        ret = re.search(pattern, suffix.replace(',', ''))
        if ret is None:
            return None
        num = ret.group(2)
        if len(num) > 40:
            return None
        return num
    preds = [derive_num_from_output(txt) for txt in output_text]
    assert len(preds) == len(ground)
    acc = [1 if preds[i] is not None and int(float(preds[i])) == int(float(ground[i])) else 0 for i in range(len(preds))]
    return sum(acc) / len(acc)


# Setup code
output_text = [
    "La risposta è 42 Domanda: next question",
    "Calcolo: 2 + 2 = 4 La risposta è 4"
]

ground = [
    "42",
    "4"
]

ARGS = {
    "output_text": output_text,
    "ground": ground
}
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 float, 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
metric Ran
ran on a synthesized input
rubickkcibur/LWF/dataset_processor/gsm8k_tr.py
code served (permissive licence) · get_code("a4dfc117d1bf8efc")
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 float, 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 re

# Analyze the function:
# - metric(output_text, ground)
# - output_text: list of strings that are processed to extract numbers
# - ground: list of strings/numbers that are compared against extracted numbers
# - The function extracts numbers from Turkish text containing "Cevabın" and "Soru:"
# - It compares int(float(pred)) == int(float(ground[i]))

# Create test data
output_text = [
    "Cevabın = 42. Soru: next question",
    "Cevabın 100 Soru: another one"
]

ground = [
    "42",
    "100"
]

ARGS = {
    "output_text": output_text,
    "ground": ground
}
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 float, 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
mix_multi_data Ran
ran on a synthesized input
rubickkcibur/LWF/utils.py
code served (permissive licence) · get_code("e2df12ca1a63a0c7")
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 torch
import numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - It takes an 'input' parameter which is expected to be a list/sequence of iterables
# - It accesses len(input) to get the number of kinds
# - It accesses len(arr) for each arr in input
# - It iterates through input[i][i_pointer] to access individual elements
# - It appends these elements to total_data
# The function interleaves elements from multiple input sequences

# Create several small lists with different data types to test mixing
list1 = [1, 2, 3]
list2 = ['a', 'b']
list3 = [10.5, 20.5, 30.5, 40.5]

input_data = [list1, list2, list3]

ARGS = {
    "input": input_data
}
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 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
qa_preprocess Not yet run
unverified (harvested, no recorded run)
rubickkcibur/LWF/trainLM_tools.py
code served (permissive licence) · get_code("3e29e308b7d77163")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 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, 0 later) and 6 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
qa_preprocess 1 other paper
1 dated earlier
2408.09849 (2024-08)
Importance Weighting Can Help Large Language Models Self-Improve

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-24.

Repositories linked to this paper

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

Abstract

Recently, the pretrain-finetune paradigm has become a cornerstone in various deep learning areas. While in general the pre-trained model would promote both effectiveness and efficiency of downstream tasks fine-tuning, studies have shown that not all knowledge acquired during pre-training is beneficial. Some of the knowledge may actually bring detrimental effects to the fine-tuning tasks, which is also known as negative transfer. To address this problem, graceful forgetting has emerged as a promising approach. The core principle of graceful forgetting is to enhance the learning plasticity of the target task by selectively discarding irrelevant knowledge. However, this approach remains underexplored in the context of generative language models, and it is often challenging to migrate existing forgetting algorithms to these models due to architecture incompatibility. To bridge this gap, in this paper we propose a novel framework, Learning With Forgetting (LWF), to achieve graceful forgetting in generative language models. With Fisher Information Matrix weighting the intended parameter updates, LWF computes forgetting confidence to evaluate selfgenerated knowledge regarding the forgetting task, and consequently, knowledge with high confidence is periodically unlearned during fine-tuning. Our experiments demonstrate that, although thoroughly uncovering the mechanisms of knowledge interaction remains challenging in pre-trained language models, applying graceful forgetting can contribute to enhanced fine-tuning performance.

For agents

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

get_harvested_code_for_paper("2505.19715")
get_code_for_paper("2505.19715")
have("2505.19715")

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

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

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

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

Connect an agent — have() is free.