Home / Insights / AI in Practice
Context Windows: What a Model Can Hold in Mind
Why input length is limited, why longer is not always better, and how systems handle memory.
A language model reads a limited number of tokens at a time. Everything it can use for an answer, including instructions, documents, earlier conversation and the reply itself, must fit within this context window.
Why there is a limit
Standard attention relates each token to every other, so computation rises roughly with the square of the length, and the stored attention states also grow. Techniques such as FlashAttention reduced memory traffic and made longer inputs practical, and windows have grown greatly. The cost has not vanished.
Diagram by O&O Consulting.
Longer is not the same as better
Accepting a very long document does not guarantee using it well. The "Lost in the Middle" study found performance depended on where relevant information sat, often worse in the middle. Irrelevant material can also distract. Each extra token adds to price and delay.
Where memory comes from
The model itself does not remember your last conversation. Applications create memory by saving information and putting it back into later prompts:
- keeping recent turns verbatim and summarising older ones;
- storing facts in a database and retrieving what is relevant;
- maintaining a short structured record, such as a customer's preferences.
Each method decides what to keep, and a summary can lose or distort detail.
Privacy and control
Stored memory is personal data when it concerns people. Users should know what is retained, be able to correct or delete it, and not have one customer's information surface in another's session. Retention periods should be deliberate.
Limitations and open questions
How to evaluate long-context use remains unsettled: finding a single planted sentence is much easier than reasoning across a whole contract. Test the actual task at realistic length, including cases where the answer depends on two distant passages.
References
- Dao, T. et al. (2022). "FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness." arxiv.org/abs/2205.14135
- Liu, N. F. et al. (2023). "Lost in the Middle: How Language Models Use Long Contexts." arxiv.org/abs/2307.03172
- Vaswani, A. et al. (2017). "Attention Is All You Need." arxiv.org/abs/1706.03762
This article is general information, not financial, legal or investment advice. AI research and rules change quickly; check the cited sources for the current position.