SFT Sample Packing with Loss Masks
Asked at Microsoft · MLOps & Deployment · Difficulty: Medium · Last asked Apr 19, 2026
Supervised fine-tuning of a language model on short examples wastes compute if every example is padded to the full context length. Sample packing fixes this: several examples are concatenated into one fixed-length training sequence, and a loss mask makes sure the model is trained only on answer tokens. Implement the packing step.
Loading the problem…
More Microsoft interview questions
- LLM conceptual questions
- Tiny Next-Token Prediction Model (PyTorch Fill-In)
- Roofline Analysis and Mixed-Precision Gradients for Matmul
- Design Search Autocomplete / Typeahead
- Design a Chatbot Personalization / Memory System
- Design a Job Scheduler / ETL Pipeline