Explain effective context for Mistral's 4096 sliding window over a 16k input
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Mistral 7B uses sliding window attention with a window of 4096 tokens. The model is fed a 16k-token input. What does the phrase 'effective context' mean for this configuration, and why is it larger than 4096?
Per-layer reach is 4096; cross-layer receptive field is L * 4096. For Mistral 7B (32 layers) that is 131k tokens, larger than the 16k input, so every position can influence the last token.
Picture a row of librarians, each only able to read books from the four shelves in front of them. The librarian at the far right cannot directly read books from the far left of the room. But if the librarian at position 5 writes a one-page summary of what she sees, and the librarian at position 9 reads that summary as part of her own shelf range, the signal hops forward. Stack enough librarians in a line and the rightmost one can hear about books from the very left of the room, even though no single librarian ever saw more than four shelves at once.
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.
Distinguish per-layer window W from cross-layer receptive field W * L, compute Mistral 7B's 131k bound, explain how the residual stream carries depth-hops, contrast cost with full attention, and flag the theoretical-vs-effective gap that motivates hybrid architectures.
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.
Treating 4096 as the model's maximum context. That is the per-layer window; the receptive field across 32 layers is 131k tokens.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.