Generative AI
Context Windows, Position Effects, and Effective Recall
Understand context-window capacity, position encoding, attention cost, truncation, distraction, and long-context evaluation.
By the end you can
- Distinguish nominal context capacity from effective use of relevant evidence
- Explain how position, masking, and attention design influence long-context behavior
- Identify truncation, distraction, stale history, and lost-in-the-middle failures
- Design long-context tests with controlled evidence placement and distractors
Availability is not utilization
Accepting a long sequence is not the same as using every part of it equally well. Relevant evidence can be diluted by distractors, placed where retrieval is weak, or contradicted by later context. Context length is therefore an interface limit, not a guarantee of recall or reasoning.
The gap opens early. FLenQA, a benchmark built for a 2024 paper called "Same Task, More Tokens", holds the reasoning problem fixed and pads it out: three tasks, 100 base instances each, at 250, 500, 1000, 2000 and 3000 tokens. Length was the only thing that changed. Across GPT-4, GPT-3.5-Turbo, Gemini Pro, Mistral Medium and Mixtral 8x7B, average accuracy fell from 0.92 at the shortest length to 0.68 at 3000 tokens. A quarter of the score, gone, at a length far below any of those models' advertised maximum. The abstract puts it plainly: “Our findings show a notable degradation in LLMs’ reasoning performance at much shorter input lengths than their technical maximum.”
Effective context depends on model training, position handling, prompt structure, and the application's selection policy. None of those is published on a specification sheet.
A token inside the window is available to the model, but its influence must still be demonstrated.
Visual
Four limits shape long-context performance
Increasing the outer limit does not remove the inner bottlenecks.
The architectural limit is the one most often treated as a label rather than a design decision. How a model represents position decides how far it can run beyond the lengths it was trained on. One method, ALiBi, adds no positional embeddings at all. It penalises query-key attention scores in proportion to distance. It arrived at ICLR 2022 under the title "Train Short, Test Long", and the abstract reports the result: “We show that this method trains a 1.3 billion parameter model on input sequences of length 1024 that extrapolates to input sequences of length 2048, achieving the same perplexity as a sinusoidal position embedding model trained on inputs of length 2048 but training 11% faster and using 11% less memory.” Doubling the usable input was a property of how position was represented. Not of how much data the model had seen.
- 01
Serialization limit
The application must fit instructions, history, evidence, tools, and output budget.
- 02
Architectural limit
Attention, positional method, masking, and model training constrain interactions.
- 03
Behavioral limit
The model may neglect, confuse, or overweigh parts of the available sequence.
- 04
Product limit
Latency, memory, cost, privacy, and source freshness restrict useful context.
Example
Long context creates new failure modes
These failures can occur long before the formal token limit is reached, and the price of the second one has been measured precisely.
GSM-IC takes arithmetic word problems from GSM8K and adds one irrelevant sentence to each: 58,052 examples in all. A single extra sentence, and: “The drop on macro accuracy is especially large, showing that fewer than 30% of the base problems are consistently solved after adding distractors.” That is from the ICML 2023 paper the benchmark was built for, "Large Language Models Can Be Easily Distracted by Irrelevant Context". The best macro accuracy among all the prompting techniques its authors investigated was 45%. The distracting sentence broke nothing in the model and removed nothing from the window. It was simply there.
- Lost in the middle: Evidence near the center is used less reliably than evidence near prominent boundaries.
- Distractor capture: A lexically similar passage overrides a more authoritative source — on GSM-IC one irrelevant sentence per problem left fewer than 30% of the base problems consistently solved.
- Instruction collision: Old conversation turns conflict with the current task and remain silently active.
- History poisoning: An earlier model error is copied into later answers because it remains in context.
- Privacy accumulation: Sensitive details persist across turns longer than users or policies expect.
Case
The middle scored below answering with no documents at all
Push the document that holds the answer into the middle of a stack and the system does worse than if you had handed it nothing. The experiment behind that sentence is "Lost in the Middle", published in 2024. Multi-document question answering, input contexts of 10, 20 and 30 total documents, and the one document containing the answer moved through the stack.
Two reference points bound the experiment. Given no documents at all, GPT-3.5-Turbo answered 56.1% of the questions correctly from its own parameters — the closed-book score. Given only the single document containing the answer, it reached 88.3% — the oracle score. Everything the retrieved context is worth lies between those two numbers. Moving the answer-bearing document to the middle spent most of it: “For example, GPT-3.5-Turbo’s multi-document QA performance can drop by more than 20%—in the worst case, performance in 20- and 30-document settings is lower than performance without any input documents (i.e., closed-book performance; 56.1%).”
Read the worst case twice. The correct passage was inside the window, and the system would have done better having been handed nothing.
Case
Half of seventeen models missed the length they advertised
RULER asks the question in its title: what's the real context size of your long-context language model? Built at NVIDIA and published in 2024, it benchmarked 17 long-context models on 13 tasks in 4 categories.
The design's useful move is its yardstick. Rather than pick a pass mark by taste, it takes a level a model has already demonstrated at short length — Llama-2-7B's 85.6% at 4K tokens — and asks which models still clear it at 32K. The benchmark's own README states the answer: “While all models claim context size of 32k tokens or greater, only half of them can effectively handle sequence length of 32K by exceeding a qualitative threshold, Llama-2-7b performance at 4K (85.6%).” Almost all of them fell below the threshold before reaching the length they claimed.
The leaderboard prints the consequence as two columns side by side: "Claimed Length" and "Effective Length". They are not the same column, and only one of them is a promise anybody made you.
Comparison
Adding context and selecting context solve different problems
The correct choice depends on whether missing information or excess information limits the task.
The third option — letting the conversation itself accumulate as state — is the one that looks free and is not. A 2025 study, "LLMs Get Lost In Multi-Turn Conversation", simulated more than 200,000 conversations. Each task was delivered either as one fully specified instruction or spread across turns. Nothing was removed in the multi-turn version. The same information simply arrived in pieces. “Our experiments confirm that all the top open- and closed-weight LLMs we test exhibit significantly lower performance in multi-turn conversations than single-turn, with an average drop of 39% across six generation tasks.” Its authors decompose that 39% into a small loss of aptitude and a large rise in unreliability. The model does not get much less able. It gets much less predictable. Compression and restatement are not merely a cost control. They are a correction to the shape history arrives in.
Longer raw context
Include more uncompressed material in one request.
- Reduces some truncation
- Preserves source detail
- Raises latency and attention burden
- Can increase distraction and privacy risk
Retrieval and selection
Choose a smaller evidence subset for the current query.
- Improves relevance density
- Can miss the required source
- Creates a retriever dependency
- Supports source-level diagnostics
Compression and state summaries
Transform earlier material into shorter representations.
- Controls recurring context cost
- Can preserve decisions and open issues
- May erase nuance or provenance
- Requires correction and version policy
Key idea
Position effects are empirical properties, not fixed folklore
Different models, prompts, and tasks exhibit different sensitivities to evidence placement. Heuristics such as placing crucial instructions near boundaries can help. But they are not universal laws. The degradation measured in "Lost in the Middle" appeared in models explicitly built for long contexts as well as in ones that were not.
Evaluate the deployed model with the actual serialization order. A provider or model upgrade can change long-context behavior even when the nominal limit remains the same.
Test position and distraction directly on the model version you plan to release.
Position
Plan against the length you measured, not the one you were sold
A model card publishes the length the interface will accept. It does not publish the length the model uses well. Those are different numbers.
Start with where a headline figure comes from. Google's Gemini 1.5 technical report gives synthetic needle-in-a-haystack recall above 99.7% up to 1M tokens, and 99.2% retained when the haystack is stretched to 10M. The haystack is concatenated Paul Graham essays with a sentence hidden in it. The announcement compressed that to one line: “1.5 Pro found the embedded text 99% of the time, in blocks of data as long as 1 million tokens.” The number is real, and the test is a literal string lookup. RULER shows that near-perfect vanilla needle-in-a-haystack accuracy coexists with large drops on harder long-context tasks: on its 13 tasks, only half of 17 models — all claiming 32K tokens or more — stayed above Llama-2-7B's 85.6% at 4K, and almost all fell below it before reaching their claimed length. The vendor number and the usable number are measuring different things.
Position is the second discount. "Lost in the Middle" found performance highest when the relevant passage sits at the beginning or the end of the input, and degrading when the model has to reach into the middle — in the worst case, below GPT-3.5-Turbo's own 56.1% closed-book score. Both results are measurements of particular models on particular tasks. That is exactly why neither an advertised figure nor a placement heuristic can stand in for one of your own. Read the published number as an upper bound on what will be accepted, then find the usable number yourself, on the version you are about to ship, with your own serialization order. A context budget taken from a specification sheet is a guess with a citation attached.
The only usable context length is the one you measured on the version you are shipping.
Steps
Build a controlled long-context evaluation
Vary one property at a time so failures are interpretable.
NoLiMa is a worked instance of the first four steps, and of what happens when one design flaw is removed. It rebuilds the needle-in-a-haystack test so that the question and the needle share minimal lexical overlap. The model has to associate rather than string-match. Its authors swept length across 13 models, all claiming at least 128K tokens, and reported at ICML 2025: “At 32K, for instance, 11 models drop below 50% of their strong short-length baselines. Even GPT-4o, one of the top-performing exceptions, experiences a reduction from an almost-perfect baseline of 99.3% to 69.7%.”
The lesson for your own harness is in the contrast with the 99%-at-1M headline. The same family of test gives a near-perfect score, or halves 11 models out of 13, depending on whether the needle repeats the question's wording. If your planted evidence shares vocabulary with your query, you are measuring your string matcher.
1. Plant answerable evidence
Create tasks with one authoritative supporting passage.
2. Sweep position
Move the passage across beginning, middle, and end regions.
3. Add distractors
Include related, stale, and contradictory material.
4. Vary context length
Separate position effects from total-load effects.
5. Score support and abstention
Check whether claims follow the controlling passage.
6. Repeat after upgrades
Treat context behavior as a release regression surface.
Long context is an evidence-management problem
A larger window can reduce truncation and support richer tasks. It can also cost more, crowd the evidence with material that distracts, keep stale state around, and hide a privacy exposure. The measurements in this lesson all point the same way: accuracy falling from 0.92 to 0.68 at 3000 tokens, fewer than 30% of problems solved consistently after one irrelevant sentence, 11 of 13 models halving at 32K, a middle position scoring below closed book, half of 17 models missing the length on their own label.
The next lesson focuses on context engineering: deciding what enters the window, how it is ordered, and what should be compressed, retrieved, or excluded.
Key takeaways
- Context capacity does not guarantee uniform evidence use: FLenQA held the task fixed and average accuracy still fell from 0.92 to 0.68 by 3000 tokens.
- Position, distraction, conflicting instructions, and accumulated history degrade long-context behavior — a middle-placed answer document can score below GPT-3.5-Turbo's 56.1% closed-book baseline.
- Longer raw context, retrieval, and compression solve different evidence-management problems, and unmanaged multi-turn history costs an average of 39% across six generation tasks.
- Position heuristics are model- and task-dependent and must be tested empirically on the deployed serialization order.
- Long-context evaluation should vary evidence position, distractors, length, and authority — and avoid lexical overlap between question and needle, which took 11 of 13 models below half their baseline once removed.
- Model upgrades require renewed tests even when the advertised limit is unchanged: "Claimed Length" and "Effective Length" are two different columns.