Context window is the maximum tokens an LLM can process in one call. Frontier models: GPT-4o (128k), Claude 3.7 (200k), Gemini 1.5 Pro (2M). Larger contexts enable more information but have risks: "lost in the middle" (degraded attention to middle content), higher cost, higher latency. Strategies: RAG for selective retrieval, chunking for long documents, context compression (summarisation), and attention-aware placement (key information at start/end).
Research finding on LLM attention across context positions.
"Lost in the middle" is real — LLMs have degraded recall for content in the middle of long contexts. Critical instructions in the system prompt (start) and the user question (end) get the most attention.
Counterintuitively, retrieving 5 relevant chunks often produces more accurate answers than sending the entire 100-page document. Less noise, more focused context, lower cost, faster.
Processing a 100k-token document costs ~$0.25 per request with GPT-4o. For 1000 queries/day = $250/day. RAG with 3k-token retrieval = $7.50/day. Use long context only when the full document is truly necessary.
Sign in to share your feedback and join the discussion.