Debug a GPT training pipeline
Applied IntuitionMachine Learning Engineer · Technical ScreenLast updated
This question evaluates debugging and implementation skills for transformer-based training pipelines, specifically attention masking, training-loop correctness, positional encoding integration, and the ability to design unit tests that catch such bugs.
Given a Colab notebook containing a minimal GPT-style language model with training and inference code, identify and fix three issues so that the training loss drops below a specified threshold on a small dataset: (
- incorrect attention masking (e.g., causal mask or padding mask mishandled); (
- a bug in the training loop (e.g., missing optimizer.zero_grad(), not calling model.train(), misaligned input/target token shift, wrong device placement, or incorrect loss reduction); and (
- missing positional encoding integration. Provide concrete code changes, unit tests that would have caught these bugs, and a brief rationale for each fix.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.