Fine-tuning, RLHF & Alignment·Question 45 of 61Advanced

Your fine-tuned model's training loss looked great, but outputs in production are worse than the base model. Walk me through your debugging process.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Structured triage, ordered by base-rate of the bug:

1. Chat template / tokenization mismatch (the #1 culprit). Compare, token-by-token, what training rendered vs. what serving renders for the same conversation: same special tokens, same system-prompt placement, same whitespace, same generation prompt suffix. Check EOS handling - was the end-of-turn token in training targets, and is serving using the right stop tokens? Symptoms diagnostic of this class: rambling past the answer, never stopping, leaking template markup, ignoring the system prompt.

Full worked answer with diagram

Structured triage, ordered by base-rate of the bug:

1. Chat template / tokenization mismatch (the #1 culprit). Compare, token-by-token, what training rendered vs. what serving renders for the same conversation: same special tokens, same system-prompt placement, same whitespace, same generation prompt suffix. Check EOS handling - was the end-of-turn token in training targets, and is serving using the right stop tokens? Symptoms diagnostic of this class: rambling past the answer, never stopping, leaking template markup, ignoring the system prompt.

2. Loss masking bugs. Decode a training batch and print which tokens carry labels ≠ -100. If prompt tokens got loss, the model learned to imitate prompts; if masking ate the response or the EOS, it learned nothing useful. "Training loss looked great" is consistent with both bugs - low loss on the wrong tokens.

3. Serving configuration. Wrong adapter loaded (or none - base model silently served); adapter attached to a different base version/revision than trained on; quantization at serve time the model was never evaled under; sampling params (temperature/top_p/penalties) different from eval; max_tokens truncation.

4. Eval-vs-production distribution gap. If offline held-out metrics were also good, prod inputs must differ: longer contexts, messier formatting, different language mix, adversarial users, upstream prompt changes by the app team. Pull real failing traffic, run it offline, and see if failures reproduce - if they do, your eval set wasn't representative; fix the eval before the model.

5. Overfitting / forgetting (if training loss was great but held-out was never checked): eval-loss divergence, regurgitation on paraphrased training prompts, general-capability regressions.

6. Data pipeline: silent truncation of long examples, duplicated or mislabelled examples, train/serve system prompts differing.

The meta-answer interviewers want: reproduce a concrete failing example end-to-end, diff training-time vs serve-time token sequences exactly, and change one variable at a time - most "the model got worse" incidents are pipeline bugs, not learning failures.

Worth sketching. ordering the branches by base rate gives you the order you would actually debug in.

flowchart TD
    A["Prod worse than base"] --> B{"Training tokens match<br/>serving tokens exactly?"}
    B -->|"no"| C["Chat template or<br/>EOS mismatch"]
    B -->|"yes"| D{"Labels only on<br/>assistant spans?"}
    D -->|"no"| E["Loss masking bug"]
    D -->|"yes"| F{"Right adapter, base revision,<br/>quantization, sampling params?"}
    F -->|"no"| G["Serving configuration"]
    F -->|"yes"| H["Replay real failing traffic:<br/>the eval set was not representative"]

What a good answer covers

  • Chat template / tokenization mismatch (the #1 culprit)
  • Compare, token-by-token, what training rendered vs
  • Check EOS handling - was the end-of-turn token in training targets, and is serving using the right stop…
  • Symptoms diagnostic of this class
  • Decode a training batch and print which tokens carry labels ≠ -100

Key terms: 2. Loss masking bugs · 3. Serving configuration · 4. Eval-vs-production distribution gap · 5. Overfitting / forgetting · 6. Data pipeline

Interviewer follow-ups to expect

  1. What single artefact would you log at training time to make this debugging trivial later?

  2. How do you catch template mismatch in CI before deploy?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep