Find the bug: a Llama deployment serves traffic without prepending the BOS token.
Click any words you think contain an error. Click again to unmark.
BOS acts as the learned attention sink. Drop it and the first real token inherits the sink role, distorting its hidden state and degrading the opening tokens of generation.
Imagine a sports team where one player is designated to catch every ball nobody else can field. Lose that player and someone else has to do their job on top of their own. The replacement player tries to play their normal position and catch random balls at the same time, doing both badly. The first token of every prompt (called BOS) is that designated catcher for the model. The system always has to put its leftover focus somewhere, and during training it learns to dump it on BOS because that slot carries no real content to protect. Skip BOS at runtime and the first real word of your prompt has to play two positions at once. Quality drops, especially on the first few words the model writes back.
Detailed answer & concept explanation~6 min readEverything 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. 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-8 min: softmax sum-to-1 invariant + attention sink phenomenon + BOS as learned sink + what happens when BOS is missing + symptoms in production + fix + connection to StreamingLLM.
Real products, models, and research that use this idea.
- Llama 2, 3, and 4 Maverick tokenizers all prepend BOS through Hugging Face's add_special_tokens flag.
- The StreamingLLM paper (Xiao et al., MIT 2023) introduced the 'attention sink' terminology and showed the first 4 tokens carry the sink role.
- Mistral 7B and Mistral Large require explicit BOS handling in some serving configurations; mishandled BOS is a documented production issue.
- vLLM, TensorRT-LLM, and SGLang all handle BOS correctly through their tokenizer wrappers, while custom 'tokenize and run' stacks frequently miss it.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does the attention sink concept connect to StreamingLLM?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating BOS as a no-op marker. It is a learned attention sink whose absence forces the first real token to absorb softmax's leftover weight, degrading the opening of generation.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.