Context Length and Efficiency
Context length is the maximum amount of information a single prompt can include, so it acts as a budget that every prompt spends from.
Packing a Prompt Into a Fixed Ceiling
Every prompt you send to a foundation model has a ceiling on its size. Whatever you want the model to read, including instructions, background documents, examples, and the question itself, has to fit inside that ceiling. Practitioners call this ceiling the context length. Before you can write a good prompt for a long task, you need to know how large the ceiling is for the model you are using, because the ceiling decides how much material you can put in front of the model at once.
Keep one question in mind as you read this article: if you were handed a stack of documents to analyze, how would you decide whether they could all go into a single prompt? By the end, you should be able to answer that question with a token estimate and a comparison against a specific limit.
What do you think happens?
Could a book of about 120,000 words fit inside a context length of 1K tokens?
Reveal answer
No, it is far too large
The source equates about 120,000 words to about 160,000 tokens. A 1K limit is 1,000 tokens, so the book is roughly 160 times larger than that budget. Context length is measured in tokens, not words, so the comparison has to be made in tokens.
Context Length as a Shared Budget
The source defines context length as the maximum amount of information a single prompt can include. Think of it as a budget that every prompt spends from. The budget is the same size regardless of how short or long your question is, so every piece you add to the prompt takes away from what remains.
A long background document can use up most of the budget before you have written a single instruction. This is why context length is not only a property of the model. It is also a constraint that shapes how you choose and arrange your material. The diagram below shows one illustrative way a small budget could be spent.
In this illustration the background document takes most of the 1K budget, which leaves little room for anything else. The numbers are invented for teaching, but the logic is the one the source describes: material and budget are compared directly, and whatever you add is subtracted from what remains.
Why Tokens, Not Words, Set the Limit
Context length is measured in tokens. This matters because word counts and page counts are not the same as token counts, and comparing a word count directly against a context length limit gives the wrong answer. The source gives you a conversion to work with: a book of about 120,000 words is equated to about 160,000 tokens. That pair of figures lets you turn a word count into a token estimate.
Context length: the maximum amount of information a single prompt can include, measured in tokens. Everything you want the model to read, from instructions to background documents to the question, must fit inside it together.
- 1The numerator is the source's token estimate for the book, about 160,000 tokens.
- 2The denominator is the word count the source gives for the same book, about 120,000 words.
- 3The ratio is about 1.33 tokens per word, which you can use as a rough conversion for material of similar kind.
Reading the Growth From 1K to 2M
The first three generations of GPT models had context lengths of 1K, 2K, and 4K. The source describes 1K as a small budget, barely enough for a college essay and far too small for most legal documents or research papers. Expanding the context length quickly became a competitive goal for model providers and for the people who build applications on top of them.
Within about five years, the limit grew from GPT-2's 1K to Gemini-1.5 Pro's 2M. The source's figure traces this growth between February 2019 and May 2024. The timeline below lays out the endpoints and the intermediate generations so you can see the order of the steps.
- 1The numerator is the largest limit in the source, the 2M of Gemini-1.5 Pro.
- 2The denominator is the smallest limit in the source, the 1K of GPT-2.
- 3The ratio is 2,000, which is the roughly 2,000 times growth the source describes within about five years.
The increase is not gradual in the way a slow, steady project might be. The source describes it as rapid, and the factor of roughly 2,000 is what makes that description concrete. The practical meaning is that a prompt budget that once forced you to cut a document into pieces may now hold far more material in a single prompt.
Scale Reference Points
Numbers like 1K or 2M are hard to feel until they are attached to things you already know. The source ties several context lengths to familiar material. The table collects those reference points so you can compare them side by side.
| Context length | Reference point from the source |
|---|---|
| 1K | Barely enough for a college essay |
| 100K | Holds a moderate-sized book |
| 2M | Holds about 2,000 Wikipedia pages, or a codebase such as PyTorch |
Context length limits paired with the source's scale references
Read this table as a ladder. Each row is a budget, and each reference point tells you what that budget can hold. A 1K budget is a single short essay. A 100K budget is a moderate book. A 2M budget is a whole library-scale collection of text or a large software project.
Judging Whether Material Fits
Does a 120,000-word book fit within each budget?
A book of about 120,000 words is the material you want the model to read in one prompt. Using the source's figures, decide whether it fits within a 1K, a 100K, or a 2M context length.
- 1Convert words to tokens
The source equates about 120,000 words to about 160,000 tokens. The token estimate for the book is therefore 160,000, and comparisons must use this number, not the 120,000 word count.
- 2Compare against 1K
A 1K limit is 1,000 tokens. The book needs about 160,000 tokens, roughly 160 times that budget. It does not fit.
- 3Compare against 100K
A 100K limit is 100,000 tokens. The book needs 160,000 tokens, which is 60,000 tokens more than the budget. It does not fit.
- 4Compare against 2M
A 2M limit is 2,000,000 tokens. The book uses 160,000 of that, which is 8 percent of the budget, leaving the rest for instructions and the question. It fits.
The book does not fit in a 1K or 100K context length, but it fits comfortably within a 2M context length, using about 8 percent of the budget.
The same procedure works for any body of material. Estimate its token count, compare that estimate against the limit, and then decide what to do with the result. The flowchart below lays out those decisions.
The source states that everything you want the model to read has to fit inside the ceiling. When it does not fit, the flowchart shows the two possible outcomes of the check. The options for the no branch, shortening, splitting, or excluding material, are reasonable responses to an overflow, though the source does not prescribe a specific procedure for them.
Mistakes When Sizing Material
Common mistake Comparing a word count directly against the context length
What it looks likeA 120,000-word book is checked against a 100K limit and seems to fit.
Why it failsContext length is measured in tokens. The source equates the same book to about 160,000 tokens, which is larger than the 100K limit.
Do this insteadConvert the word count to a token estimate first, then compare the token estimate against the limit.
Common mistake Forgetting that the budget is shared by everything in the prompt
What it looks likeA 700-token background document is pasted in, and the author assumes the remaining 1K budget is still free for the instructions and question.
Why it failsInstructions, documents, examples, and the question all draw from the same budget, so each piece reduces what remains.
Do this insteadAdd up the token estimates for every piece of the prompt before deciding whether it fits.
Common mistake Treating the 2M figure as a reason to stop counting
What it looks likeBecause a 2M limit exists, a team stops estimating and sends whatever it has to the model.
Why it failsA large limit still has a ceiling, and an estimate is needed to know whether material fits under it.
Do this insteadKeep estimating token counts for each body of material, even when the limit is large.
Common mistake Assuming the 1.33 tokens-per-word ratio is exact for every text
Sizing a Document Set
You are given three documents of 30,000, 45,000, and 60,000 words. Using the source's ratio of about 160,000 tokens for 120,000 words, estimate the total token count of the three documents together. Then decide whether the set fits within a 100K context length and within a 2M context length.
Hints
- Add the three word counts first to get the total number of words.
- Multiply the total word count by 4/3, which is the same as 160,000 divided by 120,000.
- Compare the token estimate with 100,000 for one check and 2,000,000 for the other.
- Remember that the prompt also needs room for instructions and the question, so a set that barely fits on its own may not fit once those are added.
Key Takeaways
- Context length is the maximum amount of information a single prompt can include, and every prompt spends from that fixed budget, including instructions, documents, examples, and the question.
- Context length is measured in tokens, so word or page counts must be converted to a token estimate before they are compared with the limit. The source's figures give about 160,000 tokens for about 120,000 words.
- Context length grew from 1K for GPT-2 to 2M for Gemini-1.5 Pro, roughly 2,000 times within about five years, between February 2019 and May 2024.
- The scale references in the source are 1K for a college essay, 100K for a moderate-sized book, and 2M for about 2,000 Wikipedia pages or a codebase such as PyTorch.
- To judge fit, estimate the total tokens of all material, compare that estimate against the limit, and reduce or divide the material if it overflows.