All articles
prompt engineering · basic ·

The U-shaped attention curve and why context position matters more than context volume

LLMs don't pay equal attention across the context window — accuracy follows a U-shaped curve with a dead zone in the middle. Understanding this pattern changes how to structure prompts, place instructions, and think about 'more context.'

attentioncontext-windowsllmprompt-engineering
Resources
ResourceLink
Lost in the Middle (Liu et al., 2023)arxiv.org/abs/2307.03172
Anthropic — Context Degradation guidedocs.anthropic.com

Overview

The natural instinct with AI is to give it everything. Paste the entire document. Include every message. Add all the context available. More information means better answers.

It doesn’t. There is a structural limit to how much an LLM can hold in mind at once — and the things in the middle of the context window are the first to disappear.

The pattern is a U-shaped curve. Accuracy peaks at the beginning and end of the context window and drops in the middle — a 30%+ degradation when critical information lands in the dead zone. Understanding this pattern changes how to place instructions, structure long documents, and think about “just give it more context.”


The U-shaped curve

Psychologists have studied the serial position effect for over a century. Present someone with a list of words and ask them to recall as many as possible. The words at the beginning get remembered (the primacy effect — early items get rehearsed more). The words at the end get remembered (the recency effect — they’re still fresh). The words in the middle vanish.

In 2023, researchers at Stanford and UC Berkeley tested whether language models exhibit the same bias. The result: placing a key fact at different positions within a long context window produced a clear U-shaped accuracy curve. Accuracy was highest at the very beginning or very end — and dropped by more than 30% when the fact was buried in the middle.

This is not a quirk. It is structural. Transformer attention patterns weight the edges of the context window more heavily than the center. The same mechanism that lets models attend to relevant tokens across long distances creates an uneven landscape where position determines salience.

Loading diagram…

Why position matters more than volume

“Give it more context” is reasonable advice when the alternative is giving it none. But it carries a hidden cost. Every piece of context added pushes other pieces further into the middle — the attention dead zone.

Adding a 10-page appendix to a prompt does not just add information. It shifts the relative position of everything that came before it. Instructions that were at position 0.7 in the normalized window (still in the recency bump) slide to 0.5 (the trough). The model did not lose capacity. The instructions moved into weaker attention territory.

This is the tension at the core of context engineering: not just what to include, but where to put it and what to leave out. A well-placed single paragraph outperforms a poorly-structured ten-page document.


How to structure context for the U-shaped curve

The practical rule: put the most important instructions at the beginning and end of the context window. Everything in between is discounted.

Where to place different types of content
PositionWhat to put thereWhy
Start (primacy zone)System prompt, key constraints, output formatGets the most attention across the entire generation
Early-middleSupporting reference material, style guidesStill in elevated attention territory
Deep middleBackground context, exhaustive documentationHigh risk of being missed — don’t put critical instructions here
Late-middleSummaries of earlier content, context resetsPrepares the model to carry key points into the recency zone
End (recency zone)Current task, repeated key constraints, specific askStrongest influence on the immediate response

Two patterns work reliably:

Bookend critical instructions. State the constraint in the system prompt (primacy). Restate it near the end of the prompt, right before the specific ask (recency). If a format must be followed exactly or a constraint absolutely must hold, it belongs at both edges.

Front-load, don’t bury. In long documents, move executive summaries and key findings to the top. The model gives them more weight there than on page 11. If a fact is load-bearing, place it where attention is strongest.

Loading diagram…

Beyond position: what else helps

Position is the largest lever, but three other techniques reduce the dead-zone effect:

Chunk large work into passes. Instead of one 50-page upload with a complex query, break it into sequential passes. Each pass has a narrower scope and a shorter effective context window — less material ends up in the trough.

Resupply critical context in long conversations. A constraint stated in message 3 of a 20-message thread has long since drifted into the middle. When conversation length pushes key instructions into the dead zone, restate them. A fresh “Reminder: the output must follow X format” at the end of the thread pulls it back into the recency zone.

Use standing context features. Product features like Claude’s projects, Codex’s AGENTS.md, and memory systems keep stable instructions pinned at the start of the context window. They never drift into the middle because they are re-injected at the primacy position on every turn.


When the U-shaped curve interacts with other limitations

The curve rarely causes failures alone. It amplifies other limitations:

  • Hallucination + dead zone. A citation buried in the middle of a long document is both harder to attend to and harder to verify. The model may fabricate rather than retrieve — not because the fact isn’t there, but because it isn’t being read with enough weight.
  • Instruction drift + dead zone. A format constraint stated once, mid-context, in a long agent session. The agent follows it for a few turns, then drifts. The instruction didn’t change — its position moved further into the trough with each new turn.
  • Long-document QA + dead zone. A question about a fact on page 11 of a 20-page document tests both retrieval and position. The model may know the answer exists in context but fail to weight it correctly.

The fix in each case starts with position: move the critical information to an edge, then diagnose whether the underlying limitation (knowledge, instruction following, retrieval) still needs attention.


Takeaways

Attention follows a U-shaped curve across the context window

Accuracy peaks at the beginning and end, with a 30%+ drop in the middle. The same fact, same model, same query — only the position changes the result.

More context pushes existing content into the dead zone

Every addition shifts the relative position of everything before it. A well-placed single paragraph outperforms a poorly-structured ten-page document.

Bookend critical instructions at both edges

State key constraints in the system prompt (primacy) and restate near the end (recency). Instructions in the middle are structurally discounted.

Chunk, resupply, and use standing context

Break long work into passes with narrower scopes. Restate critical constraints when conversations run long. Pin stable instructions at the primacy position with project features.

Position interacts with every other limitation

Hallucination, instruction drift, and retrieval failures all get worse when the relevant information sits in the attention dead zone. Fix position first, then diagnose the rest.