Catastrophic forgetting means that training on a new task damages old skills. It's worst with full fine-tuning, many epochs, and a high learning rate. LoRA usually forgets less, because the original weights never change.
We load our ticket model. Then we ask two general questions, with no system message. Disable adapter switches LoRA off for a moment, so we see the model before fine-tuning. Then we ask again, with LoRA switched on. Run it. The model still knows Paris, and can still write about rain. But notice the extra quotation marks. Our JSON training left a small habit.
app.pypython
from transformers import AutoTokenizer, AutoModelForCausalLMfrom peft import PeftModelNAME = "HuggingFaceTB/SmolLM2-135M-Instruct"tok = AutoTokenizer.from_pretrained(NAME)model = PeftModel.from_pretrained(AutoModelForCausalLM.from_pretrained(NAME), "ticket-lora").eval()def chat(question): ids = tok.apply_chat_template([{"role": "user", "content": question}], add_generation_prompt=True, return_dict=True, return_tensors="pt") out = model.generate(**ids, max_new_tokens=25, do_sample=False) return tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True)for q in ["What is the capital of France?", "Write a haiku about rain."]: with model.disable_adapter(): print("before:", chat(q).replace("\n", " / ")[:75]) print("after: ", chat(q).replace("\n", " / ")[:75])
Output
before: The capital of France is Paris.
after: "Paris" is the capital of France.
before: In the dawn's early light, / Rain falls like a gentle breeze, / A soothing
after: "Rain falls like a gentle breeze, / A soothing melody that whispers softly,
To protect old skills, use LoRA, with few epochs, and a modest learning rate. Mix in some general examples with your task data. And always test a few general questions after training, just like we did.
Let's recap. Fine-tuning can damage old skills. LoRA forgets much less. Mix in general data, and test general questions. Next, comparing training runs.