ctx
In 2023, researchers at Stanford gave a model an exam. They handed it a question and twenty Wikipedia documents, one of which contained the answer. When the right document came first, the model answered correctly in three cases out of four. But when it sat right in the middle, the result was worse than with no documents at all, when it had to recall the answer from memory. Why does an extra hint hurt, and where is the window’s “blind spot”? Test it yourself in the lab.
Context length is how many tokens a language model sees at once: the instruction, the whole conversation, pasted documents and the answer it is writing. Whatever does not fit does not exist for it. Windows have grown from 512 tokens in 2017 to millions, but every token is paid for in GPU memory, time and money. This sheet offers a “will the document fit” calculator, a KV-cache memory counter, experiments on the lost middle and the cost of attention, and a workshop that shows how a short-context model is stretched to long texts.
Calculator
How much room your text takes in the window
Pick a model and a language, enter the number of pages, the length of the instruction, the number of turns in the conversation and how many tokens you leave for the answer. The same page gives a different number of tokens in different languages, so one and the same contract in Russian or Hindi will take up more room than in English.
How much GPU memory a long context will eat
So as not to reread the whole conversation for every new word, the model stores keys and values for every token in all layers — this is the KV cache. It grows in direct proportion to the context length and the number of users, and easily outgrows the weights themselves. Pick a model, a length and a storage format.
Etymology
Woven, window and stash
Three words without which no talk about long texts is possible came from a weaver’s workshop, a village hut and a gold prospector’s stash. Context is what is woven together with a word. A window is a slit one looks through. And a cache is a supply hidden for later so as not to have to get it again.
01 · Definition and the conversation window
A model with no memory but with a sheet of paper
Imagine a conversation partner who remembers nothing for longer than a second, but before every phrase rereads a sheet with the record of the whole conversation. This is how a chatbot works: between your messages the model stores nothing, and the service sends it the entire dialogue each time — the instruction, all the turns and pasted files. Context length is the size of this sheet. When the conversation does not fit, the oldest turns have to be thrown out or briefly summarised.
The model’s answer is written on the same sheet: each new token is added at the end and also takes space. That is why the window limit is shared between the prompt and the answer, and a separate limit on the answer is usually much smaller than the window. Move the slider on the right and see which turns the model stops seeing.
What the model still sees
Lab · three experiments with the window
Blind spot, memory and the square
In “Middle” you hide the needed document among others and see how often the model finds it — using data from the Stanford experiment. In “Memory” a long context fills the GPU until it overflows. “Attention” shows why a long prompt gets more expensive faster than it grows: every token looks at all the previous ones.
03 · Window-stretching workshop
How a short-context model is taught to read long text
Modern models learn where a token stands by a rotation: each pair of numbers in its vector is rotated by an angle proportional to the position number — this is RoPE, invented in 2021 by the Chinese researcher Jianlin Su. The pairs spin at different speeds, like clock hands: fast ones tell neighbours apart, slow ones tell distant places apart. If you feed the model text longer than it saw in training, the slow hands move to angles it has never seen — and the model gets confused. Below you can see how this is fixed: squeeze all positions (PI), change the base (NTK) or squeeze only the slow hands (YaRN).
04 · The window in code
Where the length is set and why it is sometimes less than promised
A model has a limit built in during training, and the program that runs it has its own. A common trap: the model can do 128K, but a local run by default gives it a few thousand tokens, and a long document is silently cut off. Touch a line to read the details.
Trim the conversation history by tokens, keeping the instruction; run Qwen2.5 at 128K with YaRN in vLLM; raise the window of a local model in Ollama and llama.cpp.
05 · Writing rules
06 · Neighbouring units
07 · Historical section
In November 2023 the enthusiast Greg Kamradt devised a simple test: insert one foreign sentence into a long collection of essays — “the best thing to do in San Francisco is eat a sandwich and sit in Dolores Park on a sunny day” — and ask the model about it. He ran the test at different lengths and depths and coloured the results into a table. Claude 2.1, with its window of 200 thousand tokens, in many cells answered that there was no such sentence, although it was right in front of it.
Developers at Anthropic found that the model did find the sentence but did not dare to name it: it stood out from the topic of the essays. Once the answer was started with the words “Here is the most relevant sentence from the text:”, accuracy rose, by their data, from 27 to 98 percent. The lesson is useful to everyone: a window is not only a size but also how you ask the question. Put the important thing at the beginning or the end and ask outright for a quote.
Series · AI
units of language modelsHow a neural network is measured
Context length stands at a crossroads: it is counted in tokens, its memory depends on the model’s design, its price is in FLOP, and quality inside the window is tested by perplexity. On the left is information about one long prompt, where each row leads to its own sheet; on the right are the sheets of the series.
Catalogue of quantities
the whole index →The seven SI base units
A drop of acid changes the colour of the juice, salt colours the flame, water freezes at a tap. Below them are all Simetrium sheets, by discipline and alphabetically.
Open the index →





