Spot the bug: packed-sequence SFT where the model learns to copy across unrelated examples
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Click any words you think contain an error. Click again to unmark.
The plain lower-triangular mask lets attention cross example boundaries inside the pack, so the model learns to copy from unrelated earlier examples; the fix is a block-diagonal segment-causal mask.
Think of stuffing several short letters into one long envelope to save postage. That part is fine. The problem is the rule you gave the reader: read every previous word in the envelope before answering this question. The reader dutifully scans words from the unrelated letter above, sometimes finds something that sort of fits, and pastes it into the reply. Letters bleed into one another. The fix is not to stop sharing envelopes; it is to change the reading rule. Tell the reader: when you reach a sealed page divider, treat everything above as invisible. Each letter then stays a self-contained unit even though they all share the same envelope. The dividers are real, and the rule needs to respect them.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
6 min: identify the plain causal mask as the bug, explain how cross-segment attention leaks during training, prescribe block-diagonal mask plus position-id reset plus varlen kernel use, and verify with a two-example unit test.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Trusting the separator token to fix the leak. The token marks the boundary in the input but does nothing to block attention across it.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.