Where in a long prompt should you place the most critical context: at the start, the middle, or the end?
LLMs show a U-shape position bias on long prompts, attending most at the head and tail; put critical context in both regions and avoid the middle.
Imagine giving a friend a giant list of instructions before they help you. They will probably remember the first few things you said and the last few things you said, and forget the stuff in the middle. Long prompts work the same way. The model pays more attention to the start of the context and the end, right before the actual question, than to anything sandwiched between them. So you put the things that really matter at both ends, and you treat the middle as the part the model is most likely to overlook.
Detailed answer & concept explanation~5 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.
3 min: the U-shape empirical finding + RAG chunk reordering + long-context models do not flatten it + how to measure on your own prompts.
Real products, models, and research that use this idea.
- Anthropic's RAG guidance for Claude Opus 4.7 explicitly recommends placing the most relevant retrieved document closest to the user query, citing the U-shape effect.
- Perplexity orders retrieved web snippets so the strongest source lands just before the synthesis prompt, not in score descending dump order.
- GitHub Copilot Chat reorders open-file and project-context blocks based on relevance and recency, with the highest-signal block placed adjacent to the user query.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does this change your retrieval ordering in a RAG pipeline?
QDoes this still apply on Gemini 3.1 Pro's 1M-token context?
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.
Defaulting to 'put it at the top' or 'put it at the bottom', and ignoring that the middle of a long prompt is where models are measurably worst at retrieving information.
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.