Skip to content
Period 16 / 18

Context Windows and the Shape of Forgetting

Class 2 told you the context window is finite and degrading, and asked you to take both properties on trust. This unit pays that debt. You'll see mechanically why a window degrades as it fills, not just that it does, and you'll meet a specific, measured shape that finite degradation takes: information buried in the middle of a long context is the least reliably recalled, regardless of how capable the model is. That shape has a name, it has a cause you can actually reason about, and it has direct consequences for how you'll structure everything Xolo's organization reads from here on.

Class 4, Unit 2

The previous unit covered tokens and model economics. This unit covers what happens to those tokens once a lot of them are sitting in the window at once: the lost-in-the-middle effect, its mechanical cause in how attention actually works, and the 2025 research that shows the problem getting worse, not better, as tasks get longer. The next unit turns this into a live lab against Xolo's own data.

Attention has a budget, and softmax is how it's spent

Every token a model generates draws on every other token currently in the context window through a mechanism called attention: for each token being generated, the model computes a relevance weight against every token already present, then blends information from all of them, weighted by relevance. The mechanism that turns raw relevance scores into weights that sum to one, so the model is dividing a fixed budget of attention rather than an unlimited one, is called softmax.

That "sum to one" detail is the whole story, so it's worth sitting with. If a context window holds twenty tokens, attention has twenty slices of a fixed pie to hand out. If it holds twenty thousand, attention still has exactly one pie, now sliced twenty thousand ways. Nothing about softmax changes as the window grows except how thin each individual slice gets. A fact stated once in a ten-thousand-token document doesn't get less true as the document grows, but the fraction of the model's attention budget available to notice it, on any given generation step, shrinks every time something else gets added to the window. This is the literal mechanical cause of "the context window is degrading" from Class 2, not a metaphor for it.

A fixed attention budget, spread thinner as context grows

The U-shaped curve: lost in the middle

Attention dilution alone would predict output quality degrading smoothly as context grows. What researchers actually measured, in the paper that gave this effect its name, Liu et al.'s "Lost in the Middle," is stranger and more specific: recall accuracy across a long context doesn't degrade smoothly. It forms a U-shape. Information placed at the very start of a context and information placed at the very end are both recalled reliably, close to what a short context would achieve. Information placed in the middle is recalled measurably worse, sometimes dramatically so, even though nothing about the fact itself changed, only where it sat in the window.

The mechanism behind the two peaks has real names in the literature: primacy, an advantage for what appears early, echoing how attention patterns get established from the start of a sequence, and recency, an advantage for what appears last, closest to the point where generation is actually happening. Everything between those two peaks sits in the trough of the U, competing for a thinning attention budget without either advantage.

The U-shaped recall curve

Picture this against Xolo's own reconciliation report generation. If the currency-mismatch deposit sits on row 4 of a 200-row transaction log pasted into context, or on row 197, it has a real structural advantage over the same exact row sitting at row 100. Nothing about the deposit itself changed. Only its position in the window did. This is not a hypothetical worry, it's the direct, measured reason document position is a design decision in this course, not an afterthought, and it's the entire premise of the lab in the next unit.

Quick check — A seeded error sits at the exact midpoint of a 300-row transaction log pasted into a single prompt. What does the lost-in-the-middle research predict about a model's chance of catching it, compared to the same error at row 1 or row 300?

Context rot: the 2025 finding that makes this worse, not better

A reasonable hope, going into 2025, was that newer models with dramatically larger context windows would simply engineer this problem away, more room means less crowding, less crowding means less dilution. Research published in 2025 by Chroma Research, under the name context rot, found close to the opposite for a specific and important class of task. Treat the specific numbers in that report as measured for the models and tasks it tested, not as a universal constant for every model or every context length; what this course actually relies on is the direction of the effect, not any single figure. As tasks require reasoning across more of a long context rather than just retrieving one isolated fact from it, degradation doesn't merely persist at longer lengths, it compounds. A model asked to synthesize information scattered across many parts of a long document shows measurably worse reliability than the same model asked to retrieve one clearly-marked fact from a context of the same length. Bigger windows didn't dissolve the problem. They changed its shape: simple lookup got somewhat more forgiving over time, while actual multi-part reasoning across a long context stayed hard, and in some measured cases got relatively worse as length grew.

This matters directly for how Xolo's organization gets designed. A task like "does this one specific deposit exist in the bank file" is single-fact retrieval, and a large context window handles it with reasonable grace. A task like "reconcile every transaction across two hundred rows, cross-referencing invoice status, deposit currency, and contract terms simultaneously" is exactly the multi-part reasoning that context rot shows degrading hardest. That's the entire reason Class 3's skill for the reconciliation task didn't just paste both CSVs into one giant prompt and ask a single open-ended question, it broke the work into a five-part brief with explicit control totals, which is a context-engineering discipline this unit now gives a name and a research basis to, not just a habit that happened to work.

A bigger context window is not a substitute for a good brief

It's tempting to treat a larger context window as permission to be lazier about what goes into it, more room, less need to curate. Context rot research says the opposite: the tasks that suffer most from a crowded window are exactly the multi-part reasoning tasks a business like Xolo actually needs done, and they don't get meaningfully safer just because the window got bigger. Curating what enters the window remains the discipline. A bigger window buys you more room to be careless in, not permission to be.

What this predicts, concretely, before you see it happen

Put the two findings together, attention as a fixed, thinning budget, and the U-shaped curve it produces, and a specific, testable prediction falls out.

Position should matter independent of content

A fact's recall rate should shift measurably based on where it sits in a document, worse in the middle than at either edge, even when the fact itself, its wording, and its severity are held completely constant.

Model size should matter too

A weaker model has less capacity to fight attention dilution at any given position, so the same middle-of-document placement should hurt a small model more than it hurts a frontier one.

The effect should compound with document length

Per the context-rot findings above, a longer document shouldn't just dilute recall proportionally, it should make the multi-part reasoning case measurably worse than the single-fact-retrieval case, not just uniformly harder.

That's not a claim to take on faith. It's a claim built to be tested, and the next unit tests it directly: a real transaction log, a real seeded error, moved to different positions inside it, run against models of different sizes, with the actual recall rates measured rather than assumed.

python
# a minimal illustration of softmax dividing a fixed budget
# across a growing number of tokens, the mechanism section above
# describes in words

import math

def softmax(scores):
    exp_scores = [math.exp(s) for s in scores]
    total = sum(exp_scores)
    return [e / total for e in exp_scores]

# same relevance score, competing against a growing number of others
short_context = softmax([2.0, 1.0, 1.0])            # 3 tokens
long_context = softmax([2.0] + [1.0] * 50)           # 51 tokens

print(f"attention on the relevant token, short context: {short_context[0]:.3f}")
print(f"attention on the relevant token, long context:  {long_context[0]:.3f}")
# the relevant token's own score never changed — only its share of a fixed budget did

Where this leaves you

You now have a mechanical account of context degradation, not just the warning from two classes ago but the actual cause: attention is a fixed budget divided by softmax across everything in the window, which produces a measured U-shaped recall curve favoring the start and end of a context over its middle, and which 2025's context-rot research shows compounding rather than dissolving as windows grow, specifically for the multi-part reasoning tasks Xolo's own reconciliation work is built from. Position in a document is no longer an incidental detail. It's a variable you now know how to reason about deliberately.

The next unit stops describing this effect and runs it live: a real needle-in-a-haystack demo, hunting one of Xolo's own seeded errors inside a synthetic transaction log built specifically to test where recall breaks down.

Continue to the Needle-in-a-Haystack Lab

Run the U-shaped curve for real, against Xolo's own transaction log and one of its seeded errors, moved to different positions and tested against models of different sizes.

Have a question about this lesson?

Reply here and it goes straight to Rod. Same as replying to one of his emails.