SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2506.07899 · NeurIPS · 2025

MEMOIR: Lifelong Model Editing with Minimal Overwrite and Informed Retention for LLMs

Pascal Frossard, Ke Wang, Alessandro Favero, Yiming Qin

arXiv · PDF · Open in the Atlas

Code that ran

2 of 4 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 2 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2506.07899.json · badge: /api/ran/2506.07899.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
qym7/MEMOIR community
Papers with Code archive
2 ran · 2 no recorded run
FunctionStatusWhere it lives
EarlyStopMeter Ran
ran on a synthesized input
qym7/MEMOIR/easyeditor/models/memoir/MEMOIR.py
code served (permissive licence) · get_code("9bfbc4c3715c1766")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned NoneType. 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

class EarlyStopMeter:
    """Computes and stores the average and current value"""

    def __init__(self):
        self.reset()

    def reset(self):
        self.avg = 0
        self.pre = 0
        self.val = 1000000000.0
        self.sum = 0
        self.count = 0

    def update(self, val):
        self.pre = self.val
        self.val = val
        self.sum += val
        self.count += 1
        self.avg = self.sum / self.count

    def stop(self):
        return abs(self.val - self.pre) <= 0.0001 and self.val <= 0.02


INIT_ARGS = {}

ARGS = {
    'val': 0.015
}

METHOD = 'update'


if __name__ == '__main__':
    meter = EarlyStopMeter(**INIT_ARGS)
    meter.update(**ARGS)
    print(f"avg: {meter.avg}, val: {meter.val}, pre: {meter.pre}, count: {meter.count}")
    
    meter.update(0.016)
    print(f"avg: {meter.avg}, val: {meter.val}, pre: {meter.pre}, count: {meter.count}")
    
    should_stop = meter.stop()
    print(f"should_stop: {should_stop}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NoneType — a NoneType output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NoneType 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
TopHasher Ran
ran on a synthesized input
qym7/MEMOIR/easyeditor/models/memoir/MEMOIR.py
code served (permissive licence) · get_code("e195d33398cec7fd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 1, dtype family int, shape (3,) 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 torch import Tensor

class TopHasher:
    """
    Top-k hashing algorithm for sparse feature selection.
    
    Selects the top-k indices with highest absolute values from input features,
    then applies a permutation to ensure diversity in selection.
    
    Attributes:
        top_k (int): Number of top indices to select
        input_dim (int): Dimension of input features
        permutation (torch.Tensor): Random permutation of input dimensions
    """

    def __init__(self, input_dim: int, top_k: int):
        """
        Initialize TopHasher.
        
        Args:
            input_dim: Dimension of input features
            top_k: Number of top indices to select
        """
        self.top_k = top_k
        self.input_dim = input_dim
        self.permutation = torch.randperm(input_dim)
        print(f'TopHasher: selecting {top_k} feature indices from {input_dim} dimensions')

    def get_active_indices(self, x: Tensor) -> Tensor:
        """
        Select top-k active indices based on absolute values, and apply permutation to ensure diversity.
        
        Args:
            x: Input features of shape (input_dim)
            
        Returns:
            Selected indices of shape (top_k)
            after applying the permutation
        """
        assert x.shape[0] == self.input_dim, 'Input dimension must match the input dimension of the TopHasher'
        _, indices = torch.topk(x.abs(), self.top_k)
        indices = self.permutation[indices.to(self.permutation.device)]
        return indices.detach().cpu()


INIT_ARGS = {
    'input_dim': 8,
    'top_k': 3,
}

ARGS = {
    'x': torch.randn(8),
}

METHOD = 'get_active_indices'

if __name__ == '__main__':
    hasher = TopHasher(**INIT_ARGS)
    result = hasher.get_active_indices(**ARGS)
    print(f"Result shape: {result.shape}")
    print(f"Result: {result}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 1, dtype family int, shape (3,) — shape (3,) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MEMOIR Not yet run
unverified (harvested, no recorded run)
qym7/MEMOIR/easyeditor/models/memoir/MEMOIR.py
code served (permissive licence) · get_code("dcd59724aa487a06")
How it ran

no invocation recorded.

MEMOIRAdapter Not yet run
unverified (harvested, no recorded run)
qym7/MEMOIR/easyeditor/models/memoir/MEMOIR.py
code served (permissive licence) · get_code("919cfbb43215ffca")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 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 3 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
EarlyStopMeter
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2405.14768 (2024-05)
WISE: Rethinking the Knowledge Memory for Lifelong Model Editing of 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-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

Language models deployed in real-world systems often require post-hoc updates to incorporate new or corrected knowledge. However, editing such models efficiently and reliably-without retraining or forgetting previous information-remains a major challenge. Existing methods for lifelong model editing either compromise generalization, interfere with past edits, or fail to scale to long editing sequences. We propose MEMOIR, a novel scalable framework that injects knowledge through a residual memory, i.e., a dedicated parameter module, while preserving the core capabilities of the pre-trained model. By sparsifying input activations through sample-dependent masks, MEMOIR confines each edit to a distinct subset of the memory parameters, minimizing interference among edits. At inference, it identifies relevant edits by comparing the sparse activation patterns of new queries to those stored during editing. This enables generalization to rephrased queries by activating only the relevant knowledge while suppressing unnecessary memory activation for unrelated prompts. Experiments on question answering, hallucination correction, and out-of-distribution generalization benchmarks for LLaMA-3 and Mistral backbones demonstrate that MEMOIR achieves state-of-the-art performance across reliability, generalization, and locality metrics, scaling to thousands of sequential edits with minimal forgetting. 2 * Equal contribution. 2 Code at https://github.com/qym7/MEMOIR 39th Conference on Neural Information Processing Systems (NeurIPS 2025).

For agents

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

get_harvested_code_for_paper("2506.07899")
get_code_for_paper("2506.07899")
have("2506.07899")

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

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

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

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

Connect an agent — have() is free.