r/learnmachinelearning • • 29d ago

Help First time fine-tuning: my LoRA made a 2B model worse, and the mistakes taught me more than the wins

I'm not an ML engineer. I build a small desktop app that runs Gemma 4 E2B offline, and I wanted to teach it a few things it's bad at. So I tried LoRA with MLX on my MacBook. Writing down what happened in case it helps someone else starting out.

What I did right (by luck): before training I wrote a 23-question "sealed" exam that never goes into the training data. Same prompt, temperature 0, graded by hand. Without it I'd have fooled myself. The same model scored 7/10 on the trick questions in Ollama at temp 0.4 and 3/10 in MLX at temp 0, so numbers from different setups mean nothing.

Baseline: 6/23.

Run 1: 328 hand-written examples, lr 5e-5, 16 layers, 75 steps. Score dropped to 4/23. It started answering "2 + 2 × 2 = 4" (it was right before), and it used my "I don't know, I'm offline" template on a simple riddle. It copied the shape of my answers instead of learning anything new.

Run 2: lower lr (1e-5), 8 layers, fewer template answers, and "replay": I added the base model's own answers to 117 normal questions so it wouldn't forget. Score went back to 6/23. No forgetting, but no gain either.

What I took from it:

  • A few hundred examples change how a small model answers, not what it knows.
  • Template answers leak into everything.
  • Replay is a simple fix for forgetting.
  • Always keep a test set the model never sees.

If you've fine-tuned a model this small: did you manage to add knowledge, or only style? What would you change in my setup?

1 Upvotes

5 comments sorted by

1

u/No-Cherry-3308 29d ago

Your sealed exam is the most useful part of this post. Most first fine-tunes skip that step and end up reporting vibes.

On your question: a few hundred examples with LoRA on a 2B model mostly changes how it answers, not what it knows, which matches what you saw. If the goal is new facts, retrieval usually beats fine-tuning at this size. Put the relevant facts in the prompt at answer time and keep the fine-tune for tone and format. If you really want to push facts into the weights, you need many paraphrases of each fact rather than one example per fact, and recall on a model this small stays shaky.

Things I'd change in the setup. With 23 questions, a 6 vs 4 swing can be noise, so I'd grow the exam to 60 to 100 and split it into categories: the thing you're trying to teach, the trick questions, and general stuff you don't want to break. A single total hides a run that gained on the target and lost elsewhere. I'd also double check the chat template is identical between MLX training and inference, since chat models degrade badly on a template mismatch. For the "I don't know, I'm offline" leak, put examples where it should answer normally right next to the ones where it should decline, so it learns the boundary instead of the template. And save a few checkpoints and run the exam on each. At 5e-5 for 75 steps on 328 examples the final checkpoint may just be the overfit one.

1

u/Longjumping_Golf9903 28d ago

thanks, this is really useful. you were right about rag. i tried it after this thread, same small model, 12 questions about my app’s docs: 1/12 without docs → 10/12 with nomic-embed-text + bm25, and zero made-up answers. the two misses were russian word forms (no stemming) and “Alt+Enter” vs “Alt+↩” in the docs

the category split makes a lot of sense. the hard part with 100 questions for me is grading, i do it by hand, and with a few checkpoints and a few seeds that’s hundreds of answers to read. do you auto-grade the easy ones (exact match for numbers, names) and only hand-check the rest?

1

u/Nistivo 21d ago

This is a good first experiment, and the sealed exam is exactly the right way to judge it. With only 23 questions, a move from 6 to 4 is within noise, so I would grow the exam to at least 60 questions and split the results by topic before changing anything else. That way you can see whether a run helped the target skill and hurt general answers, or just wobbled. One other thing to check is the chat template. If the template used in MLX training differs at all from the one used at inference, even in spacing or special tokens, a small model can degrade fast, and it looks like forgetting. If you run another LoRA, I would keep the learning rate at 1e-5, train for fewer steps, save a checkpoint every 10 steps, and score each checkpoint on the sealed exam. The best checkpoint is often in the middle, not at the end.

1

u/Longjumping_Golf9903 18d ago

Thanks, this is really useful. You’re right that 6→4 on 23 questions is noise — I’ll grow the sealed exam to 60+ and score it by topic. The chat template is a great catch: I trained with mlx-lm’s template and served through Ollama’s Gemma template, so I’ll diff them token by token before the next run. Next LoRA: lr 1e-5, fewer steps, checkpoint every 10 and score each one. I’ll post the results.