Model

Context Window

Why You Need to Understand Context Window

LLMs aren't infinitely memory. They have an upper limit on how much they can process in a single request.

This limit determines:

  • How long a document you can process at once
  • Whether multi-turn conversations can retain full history
  • How much RAG retrieval results can be拼接

Context Window defines this "upper limit" — understanding it lets you know what fits and what overflows.


What Is Context Window

One-line definition: Context Window is the maximum number of tokens a model can process in a single request, including input content, conversation history, system prompts — with space typically reserved for output as well.

Analogy: Context Window is the model's "workbench" — if there's too much stuff, there's no room, either things won't fit or you have to move some out first.

Common ranges:

  • Early models: 4K - 8K tokens
  • Modern models: 32K - 128K tokens
  • Ultra-long context: 200K+ tokens

How to Do It: When to Care About Context Window

Long document analysis: Contracts, reports, and knowledge base articles that are too long can't be fed in whole — need to be split, summarized, or retrieved incrementally.

Long conversations: More conversation turns mean historical messages keep accumulating. Exceeding the window may cause the model to "forget" key information from earlier in the conversation.

RAG systems: Retrieval isn't about finding as many documents as possible — you still need to fit the retrieved chunks back into the window. With limited window, both the number of retrieval results and the length of each chunk need careful management.

Common pitfalls:

  • Larger window doesn't mean smarter: it's just more capacity, not necessarily better reasoning
  • Fits in doesn't mean used well: in ultra-long contexts, models often pay less attention to middle sections ("Lost in the Middle")
  • Only counting input, not output: generating responses also uses window budget
  • Larger window means higher cost: long contexts usually mean higher costs and slower latency

Remember this: Context Window is the model's "workbench" — knowing how big it is tells you what fits, what needs to be truncated, and what needs to be compressed.

Related terms: Token · RAG