Fine-Tuning, and When Not ToLesson 53 of 84

Module 6 · The mechanics of a run

Debugging a run

In this lesson

  • 10 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 6 of 10 in this chapter

This chapter’s goalConfigure and launch a fine-tuning job with the correct chat template, masking and tokenizer handling, and diagnose from the logs alone whether a run is not learning, diverging, or memorising.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

The four checks to run before every job

These take under a minute together and catch the majority of fine-tuning bugs.

1. Print one templated example.

Python
print(tok.apply_chat_template(train[0]["messages"], tokenize=False))

Read it. Every special token where you expect it, roles marked correctly, exactly one end-of-turn marker at the end.

2. Decode the unmasked labels of one real batch.

Python
b = next(iter(trainer.get_train_dataloader()))
lbl = b["labels"][0]
print(tok.decode([t for t in lbl if t != -100]))

This should print exactly the assistant’s answer: not the prompt, not the system message, not nothing. If it prints the whole conversation, your masking is off. If it prints nothing, your response template string does not match. If it prints the answer without a trailing end token, you have the pad-equals-eos problem.

This single check is the highest-value five seconds in applied fine-tuning.

3. Print the trainable parameter count.

Python
model.print_trainable_parameters()

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Running Models Yourself exam.

Stuck on something?Ask Rafael, your AI tutor

How to cite: Addaly (2026) ‘Debugging a run’, in Fine-Tuning, and When Not To. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/fine-tuning/debugging-a-run (Accessed: 29 November 2026).