Skip to content

Context Windows: Advertised vs. Effective

A context limit is not a task score
Accepted length
How many input and output tokens the model and serving API allow.
Task performance
How often the model finds, combines and uses the required evidence at that length.

Measure performance across lengths, evidence positions and question types. There is no universal conversion from an advertised window to effective memory.

Compare accepted input length with the evidence demands of a particular task.

A context window tells you what the system can accept. It does not tell you how reliably the model will find a fact, combine two distant passages, or summarize everything you supplied. Those tasks need different evaluations.

This distinction matters when choosing between retrieval and a large prompt. A short retrieved context can remove irrelevant material and reduce cost. It can also omit the only passage that answers the question. A full document set avoids that retrieval miss if it fits, while asking more of the model’s ability to find and use evidence.

What the limit means

Check the model and API’s input, output and total-token limits. A headline context length may include output capacity rather than describing an input-only allowance. Tokenization, tool definitions and message framing also consume space.

Within that limit, define effective context for a particular task and acceptance threshold. For example: the greatest tested length where at least 90% of questions are answered correctly across uniformly sampled evidence positions. Change the task, threshold or position distribution and that number may change. Report those choices with the result.

The relevant prerequisites are attention, positional encoding and the retrieval methods earlier in this arc. They explain how the model processes positions and how retrieval selects its inputs.

What softmax does and does not imply

For a standard softmax attention head, weights over the allowed keys sum to one:

∑j=1Nαij=1.\sum_{j=1}^{N}\alpha_{ij}=1.

The mean weight is therefore 1/N1/N. But an average says nothing by itself about the weight on the answer-bearing key. Attention can stay sharply concentrated while the number of nearly ignored keys grows.

Give one relevant key logit Δ\Delta and all N−1N-1 distractor keys logit zero. Its attention weight is

αrelevant=eΔeΔ+N−1.\alpha_{\mathrm{relevant}}=\frac{e^\Delta}{e^\Delta+N-1}.

At a fixed gap, more distractors reduce this weight. To retain weight pp, the required gap is log⁡((N−1)p/(1−p))\log((N-1)p/(1-p)). A real model can change its logits, uses many heads and layers, and transforms the resulting representations further. The example isolates competition between one key and equal-logit distractors.

Softmax competition under explicit assumptions

One relevant key has logit Δ; every other key has logit 0.

α = exp(Δ) / (exp(Δ) + N − 1)
Relevant-key mass: 63.8%
Mean across all keys: 0.03125
Δ needed for 90% mass: 5.63

At a fixed logit gap, adding distractors lowers this weight. Increasing the gap can preserve concentration. Normalization alone does not prove that a model must lose the fact.

An exact softmax calculation with one relevant key and equal-logit distractors. Adjust both length and logit gap; the mean and selected-key weight are distinct quantities.

Lost in the middle

Liu and colleagues varied the position of relevant material in multi-document question answering and key–value retrieval. In their evaluated models, performance was often better when evidence appeared near the beginning or end than in the middle. The result concerns task accuracy, not a direct measurement of attention mass.

constructed recall profiles
profile A · mean recall 75%
0.000.250.500.751.00recall accuracystart25%middle75%endneedle position in the document
Three constructed position-sensitivity profiles, for comparing possible shapes of an evaluation result.

For an application, move the same answer-bearing passage through the context while holding the question and distractors fixed. Measure the fraction of correct answers over repeated examples at each position.

Needle retrieval and harder tasks

A needle-in-a-haystack test inserts a fact into a long input and asks for it back. Sweep length and depth to expose failures hidden by one average score.

Needle-in-a-haystack recall
Profile A: position-sensitive

Constructed recall profiles. Compare context lengths across columns and insertion depths down rows.

document depth (% of context)5%15%25%35%45%55%65%75%85%95%1k2k4k8k16k32k64k128kcontext length (tokens, k = 1,000)8888887944171717676767713610101051515163284444141416025222363636582322236363657222224141415520222515151541922267676752172228888885116222recall %0100
Two constructed recall profiles, with length and evidence position varied independently. Select cells to compare their assumed values.

Lexically distinctive needles may be easier to locate than ordinary evidence surrounded by similar material. Multi-hop reasoning and synthesis require additional tests that ask the model to combine or summarize evidence.

RULER adds controlled task families including multiple needles, variable tracking, aggregation and question answering. Its 2024 study found substantial differences between claimed lengths and evaluated performance for several tested models.

constructed task-score profiles
context length (log scale)
0.000.250.500.751.00task accuracy4k8k16k32k64k128k256k512k1Mcontext length (tokens)single-needle retrievalmulti-needle retrievalvariable trackingaggregation / multi-hop
Authored curves illustrate task-dependent profiles. They are not RULER results or a measured ordering of task difficulty; consult the paper for the actual model/task tables.

How position sampling changes a score

Suppose an authored profile has edge recall 0.85 and a 0.30 middle-depth drop:

r(p)=0.85−0.30(1−4(p−0.5)2),p∈[0,1]. r(p)=0.85-0.30\left(1-4(p-0.5)^2\right),\qquad p\in[0,1].

This is a function chosen for the example, not a fitted model result. Averaging it at different positions gives different headline numbers.

import numpy as np
 
def recall_at(p, edge=0.85, depth_drop=0.30):
    return edge - depth_drop * (1 - 4 * (p - 0.5) ** 2)
 
depths = np.linspace(0.025, 0.975, 20)
r = recall_at(depths)
print(f"boundary-only:   {r[[0, -1]].mean():.2f}")
print(f"middle-only:     {r[8:12].mean():.2f}")
print(f"uniform average: {r.mean():.2f}")
# boundary-only:   0.82
# middle-only:     0.55
# uniform average: 0.65

For measured results, document the positions, sample count, scoring rule and uncertainty so the average can be interpreted against its sampling protocol.

Retrieval or a longer prompt?

The question is whether the supplied evidence is sufficient and usable. Retrieval can focus a factual question on a few passages; a summary may need coverage across the whole document. Hybrid approaches can retrieve broadly before selecting or summarizing.

Compare the evidence each strategy receives
Retrieve a short context
Can be sufficient if retrieval finds the answer-bearing passage.
Include the full document set
Contains the passage if the corpus fits; the model must locate it among distractors.

Compare quality, total latency and token cost on the same questions.

Compare which passages are needed for one-fact, two-hop and summary questions.

Li and colleagues’ 2024 comparison found that sufficiently resourced long-context models outperformed RAG on average in their evaluated setting, while RAG offered lower cost. Their comparison illustrates a quality–cost tradeoff to measure in the intended deployment.

Test both approaches with the same model, questions and source corpus. Account for retrieval misses, answer correctness, source support, latency and input cost. For large corpora that cannot fit, some selection or compression is unavoidable.

Adding material can change performance

Longer prompts can introduce distractors, contradictions or extra dependencies. They can also supply missing evidence and improve answers. “Context rot” is a useful name for observed degradation in particular evaluations; it is not a law that every added token reduces reasoning quality.

Prompt caching changes the work of processing repeated prefixes and, depending on the provider, their billed cost. It does not shorten the logical input or automatically improve the model’s ability to use it. Likewise, compaction can reduce input size while losing the detail needed for a later question.

The next post, context engineering, examines those choices over a growing conversation: what to preserve, summarize, clear and retrieve.

Additional reading (and watching)