Identify the attention-pattern difference between Mistral 7B and Llama-2 7B
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Mistral 7B uses sliding-window attention with a 4k window over 32k context; Llama-2 7B uses full causal attention over 4k. Same parameter count, different attention pattern.
Imagine two researchers asked to find connections in a thousand-page book. The first researcher reads page N by glancing at every page before it, a slow read but every page sees every prior page. The second researcher reads page N by glancing only at the last 100 pages, but does this many times in stacked passes; by the final pass, information from page 1 has hopped through enough intermediate pages to reach page N. The first researcher is Llama-2 7B with full attention; the second is Mistral 7B with sliding-window attention.
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.
5m: the full vs sliding-window pattern split, Mistral's 4k window inside 32k context, depth-stacking to grow effective receptive field, what GQA and RoPE do and don't change, and where sliding-window costs you on long-range lookup.
| Property | Llama-2 7B | Mistral 7B |
|---|---|---|
| Attention pattern | Full causal | Sliding window (4096) |
| Context length | 4096 | 32768 |
| KV head structure | MHA (32 query, 32 KV) | GQA (32 query, 8 KV) |
| Positional encoding | RoPE | RoPE |
| Per-token attention cost | O(seq) | O(window) |
| Per-layer receptive field | Full prior context | 4096 nearest tokens |
| Effective receptive field | Same as per-layer | L * window via stacking |
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.
Naming MQA, GQA, or RoPE as the headline difference. Mistral 7B and Llama-2 7B differ in attention PATTERN (full vs sliding window), not in head sharing or positional encoding.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.