explaingit

martin-marek/forgetting

15PythonAudience · researcherComplexity · 4/5Setup · hard

TLDR

Research code for a paper studying how AI language models forget old knowledge when trained on new data, and how mixing in synthetic self-generated examples can prevent most of that forgetting.

Mindmap

mindmap
  root((forgetting))
    Research focus
      Catastrophic forgetting
      Data replay techniques
      Self-generated replay
    Key findings
      Replay prevents forgetting
      Synthetic data works
      Low LR reduces forgetting
      Capacity matters
    Workflow
      Train tokenizer
      Convert datasets
      Pretrain model
      Fine-tune with replay
    Tech
      Python
      JAX
      Config files
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Reproduce the paper's forgetting experiments to verify that self-generated replay reduces catastrophic forgetting in language models

USE CASE 2

Use the configuration files as a starting point for your own continual learning experiments before scaling up

USE CASE 3

Study how training data recency and learning rate interact with forgetting to inform your own fine-tuning strategy

Tech stack

PythonJAX

Getting it running

Difficulty · hard Time to first run · 1h+

Requires JAX and familiarity with ML research workflows, GPU recommended for larger experiments.

In plain English

This repository holds the code for a research paper studying a problem that occurs when you train an AI language model on new information: the model tends to forget what it learned before. The paper is titled "Forgetting in Language Models: Capacity, Optimization, and Self-Generated Replay" and the repository accompanies the published work so others can reproduce the experiments. The core finding is that a technique called data replay, where you mix in examples from the original training data while teaching the model something new, greatly reduces how much the model forgets. The more interesting discovery is that when you do not have access to the original training data, you can instead ask the model to generate its own synthetic examples from memory, and those work nearly as well as the real data. The research also finds that forgetting gets worse when a model has little remaining learning capacity, meaning models that were trained very thoroughly on the original data have a harder time absorbing new knowledge without losing old knowledge. Learning rate settings also matter: lower learning rates cause less forgetting but require much more training time, while the replay technique removes that tradeoff. The code is written in Python and uses JAX, a library for numerical computing often used in machine learning research. The experiment workflow has four steps: train a text tokenizer, convert datasets into a binary format the trainer expects, run an initial pretraining phase on one dataset, then fine-tune on a different dataset while applying the forgetting-prevention technique. The repository includes configuration files and plotting scripts for reproducing the specific experiments shown in the paper's figures. This is a research codebase aimed at machine learning researchers studying how language models retain and lose knowledge during training. It is not a general-purpose tool or product, but the README includes a walkthrough with small example runs that are easy to try on a modest setup before scaling up to larger experiments.

Copy-paste prompts

Prompt 1
Walk me through the four-step workflow in the forgetting repo: tokenizer training, dataset conversion, pretraining, and fine-tuning with replay.
Prompt 2
Explain the key finding about self-generated replay in this paper: why does asking the model to generate its own training examples work nearly as well as real data?
Prompt 3
I want to run a small example from the forgetting repo before scaling up. What do the small example configurations cover and what hardware do I need?
Prompt 4
How does the forgetting repo implement data replay during fine-tuning, and where in the training loop does the mixing of old and new data happen?
Open on GitHub → Explain another repo

← martin-marek on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.