continual-lm

Qwen2.5-0.5B-Instruct trained on a stream of four tasks one after another (short stories, questions about a passage, arithmetic, machine-learning abstracts), with techniques that reduce forgetting: replay of old examples, selection by "surprise", easy-to-hard ordering, a "sleep" phase, and replay of the model's own answers to general requests. All LoRA adapters are merged into the weights, so this is an ordinary Hugging Face model; the project's code is not needed to run it.

This is a research artifact, not a general-purpose assistant. The tasks are educational, the data is English, and the model has 0.5 B parameters. See "Limitations".

Code, configs, and the full experiment report: https://github.com/makltd123/continual-lm

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("makltd1/continual-lm")
model = AutoModelForCausalLM.from_pretrained("makltd1/continual-lm")
messages = [{"role": "user", "content": "What is 17 + 25? Reply with the answer only."}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))

It runs on a CPU (an answer takes from a few seconds to half a minute).

Keep teaching it: the learner state

The state/ folder is the learner state at checkpoint ckpt-000020 (20 portions, 2 sleep phases): the merged adapters, the current adapter, the replay buffer, the counters and the random states. The project's chat.py (a chat that learns from your corrections) and live.py (training on your own .jsonl files) continue from it. The code is at https://github.com/makltd123/continual-lm.

pip install huggingface_hub
python -c "from huggingface_hub import snapshot_download; snapshot_download('makltd1/continual-lm', allow_patterns='state/*', local_dir='download')"
git clone https://github.com/makltd123/continual-lm && cd continual-lm
pip install torch && pip install -r requirements.txt
python chat.py --state ../download/state --low-memory

The base model Qwen2.5-0.5B-Instruct is downloaded on first run. Write each chat message on one line; after an answer, /good learns it and /fix <right answer> learns the right one. The replay buffer (state/ckpt-000020/buffer.json) holds 640 examples per task: excerpts of the datasets listed below, under their licenses, and the model's own answers to Dolly prompts.

Results

Final configuration E5_final_v2, a single seed, measured on the test split after the whole stream A → B → C → D. The original model is measured on the validation split.

Stories, ppl ↓ Passage QA, EM ↑ Arithmetic, EM ↑ Abstracts, ppl ↓ Instruction following General text, ppl ↓
Qwen2.5-0.5B-Instruct (original) 5.74 0.37 0.41 14.96 0.579 25.9
continual-lm 4.84 0.598 0.795 13.60 0.553 (95% of the original) 27.75
  • Instruction following is the project's own set of 152 automatically checkable instructions (17 types, in the spirit of IFEval). One instruction is about 1% of the score, so the margin over the 90% acceptance threshold is small.
  • Perplexity on general text grew by about 7% (25.9 → 27.75): the model traded some general language breadth for the learned tasks.
  • Without replay of its own answers, training on narrow tasks always erodes instruction following (81–88% of the original remains).

Limitations

  • Small model, English-only data, educational tasks. A practical use needs a real scenario and probably a larger model.
  • Training was done once for the final model (one seed); the comparison experiments use three seeds.
  • The model does not follow format instructions such as "exactly N paragraphs", "in quotes", "start/end with a phrase", "no commas".
  • It forgets less than a plain fine-tune, but it still forgets. It is not "forgetting-free".

Training data and licenses

The datasets are not redistributed here; they were downloaded from the Hugging Face Hub at pinned revisions.

Role Dataset License
Task A, stories roneneldan/TinyStories CDLA-Sharing-1.0
Task B, passage QA rajpurkar/squad CC BY-SA 4.0
Task C, arithmetic generated by the project —
Task D, abstracts CShorten/ML-ArXiv-Papers AFL-3.0
Prompts for self-replay databricks/databricks-dolly-15k CC BY-SA 3.0

Evaluation only (never trained on): WikiText-2 (CC BY-SA 3.0 / GFDL). Several of these licenses carry attribution or share-alike conditions; how they apply to model weights is not settled, so check them before any commercial use.

The base model is released under Apache-2.0 by the Qwen team.

Author

Fedor Makovskiy, AI developer. Code and reports: https://github.com/makltd123/continual-lm

Downloads last month
576
Safetensors
Model size
0.5B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for makltd1/continual-lm

Adapter
(977)
this model

Datasets used to train makltd1/continual-lm