C.W.K.
Stream
Lesson 03 of 06 · published

Reading Loss Curves

~20 min · loss-curve, overfitting, underfitting, early-stopping

Level 0Observer
0 XP0/43 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Healthy training

  • Training loss decreases steadily.
  • Validation loss decreases, then plateaus.
  • Both curves stay relatively close.

Overfitting signs

  • Training loss keeps decreasing.
  • Validation loss starts rising.
  • The model memorizes training data instead of learning patterns.

Fixes: reduce epochs, increase dropout, add diverse training data, reduce rank (r), enable early stopping.

Underfitting signs

  • Both losses high and plateau early.
  • Model hasn't learned enough.

Fixes: increase epochs, increase learning rate, increase rank (r), more training data, check data quality.

Epochs vs steps

An epoch = one full pass through training data. With 1,000 examples and batch 8 → one epoch = 125 steps. Small datasets (< 1,000): 3–5 epochs. Large datasets (> 10,000): 1–2 epochs is often enough.

Code

Early stopping callback in TRL·python
from transformers import EarlyStoppingCallback
from trl import SFTTrainer

trainer = SFTTrainer(
    model=model,
    args=args,
    train_dataset=dataset,
    eval_dataset=eval_dataset,
    processing_class=tokenizer,
    peft_config=peft_config,
    callbacks=[
        EarlyStoppingCallback(early_stopping_patience=3),
    ],
)
# Stops if validation loss doesn't improve for 3 evaluation rounds.

External links

Exercise

Find a published training run with a clear overfitting curve (W&B has many public runs). Identify the exact step where validation loss starts rising. Then look at training loss at the same step — what is the gap? This calibrates your eye for spotting overfitting in your own runs.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.