Topic 4 of 5 · 5 min read
Running and checking a LoRA run
Goal: Diagnose a LoRA run from its config and loss log and choose the single change most likely to fix it.
A good LoRA run is judged on data it never trained on, and on tasks it was not meant to change, so you can catch overfitting and forgetting before you ship.
Check yourself · 1 of 3
Train loss keeps falling while validation loss rises after step 400. What is the most likely cause?
Why it matters
Training loss almost always goes down. It tells you the adapter fits the training set, not that it works. A run can reach a low training loss, memorize its examples, and get worse at everything else. You want signals that are cheap to read and hard to fool.
How to run it
- Split the data first. Hold out 5 to 10 percent as validation, and keep it out of every training step. Remove duplicates before the split, or near-copies leak across it.
- Start with common settings. LoRA tolerates a higher learning rate than full tuning. Values around 1e-4 to 2e-4 are common starting points, with a warmup and a cosine or linear decay. Run 1 to 3 epochs. Small datasets overfit fast.
- Log both losses. Evaluate on the validation set every few hundred steps and save a checkpoint each time.
- Run a held-out task eval. Loss is a proxy. Write 30 to 100 real prompts with known good answers or a checklist, and score the base model and each checkpoint on them. Include a few general prompts unrelated to your task to check for forgetting.
- Pick the checkpoint by the eval, not by the last step.
Reading the log
- Train and validation loss both fall: keep going.
- Train falls while validation rises: overfitting. Cut epochs, lower the rank or learning rate, add data, or raise dropout.
- Both stay flat or are noisy: the learning rate may be too low or too high, or the data is inconsistent. Check formatting and labels before touching hyperparameters.
- Loss looks good but the task eval is poor: wrong chat template, wrong prompt format at inference, or the metric does not match the job.
Before and after
Weak: "Loss reached 0.2, ship it." Better: the log below shows what to do.
step train_loss val_loss
200 1.41 1.38
400 0.97 1.05
600 0.55 1.11
800 0.31 1.29
Validation bottomed out near step 400 and then rose while training loss kept falling. Use the step-400 checkpoint, and for the next run train for fewer epochs.
What goes wrong
- Judging by training loss. It always looks good on data the model has seen.
- Prompt format mismatch. Training with one chat template and serving with another can ruin a good adapter.
- No forgetting check. The adapter answers your task well and loses basic abilities such as following a plain instruction.
Examples
Choosing the single change
A 3-epoch run on 600 examples shows train loss 0.28 and validation loss rising since the end of epoch 1. The task eval of the final checkpoint scores below the epoch-1 checkpoint. The single most likely fix is to train for 1 epoch, or pick the epoch-1 checkpoint. Raising the rank would add capacity to a model that is already memorizing.
Loss fine, outputs poor
Validation loss is healthy, yet answers ignore the system prompt. The training data used the Llama chat template, and the serving code sends plain text. Fix the template at inference. No retraining is needed, and changing the learning rate would not help.
Key points
- Judge a run on a validation set and a held-out task eval, not on training loss.
- Validation loss rising while training loss falls is overfitting; use the earlier checkpoint and train less.
- LoRA commonly starts at a higher learning rate than full tuning, with warmup and decay and 1 to 3 epochs.
- Include general prompts in the eval to catch forgetting of abilities the adapter was not meant to change.
- Check the chat template and prompt format first when loss looks fine but outputs are poor.
Common mistakes
- Reporting training loss as the result and shipping the final checkpoint without a validation set.
- Letting near-duplicate examples sit on both sides of the train and validation split.
- Using one chat template for training and another for serving.
- Running only task prompts in the eval and missing that general ability dropped.
Check yourself · 2 of 3
Why should a LoRA eval include a few prompts unrelated to your task?
Check yourself · 3 of 3
Validation loss is healthy but the model ignores its system prompt after deployment. What do you check first?
Practice items, not counted towards your mastery.
Start here
- LoRA: Low-Rank Adaptation of Large Language Models (opens in a new tab)PaperFree
The original method: frozen weights, low-rank update matrices and why no inference latency is added.
- QLoRA: Efficient Finetuning of Quantized LLMs (Dettmers et al.) (opens in a new tab)PaperFree
Four-bit NF4 base weights, double quantization and paged optimizers, with the single-GPU memory results.
- PEFT documentation (Hugging Face) (opens in a new tab)DocsFree
LoraConfig fields, target modules, DoRA, merging and saving adapters.