Skip to content

Context Window LLM

Коротко:

Context Window — максимальное число токенов (input + output), которое LLM может обработать за один вызов. 2026: Claude Opus 4.7 — 1M (200k stable), Gemini 2.5 — 2M, GPT-5 — 1M, Llama 3 — 128k-1M. 1 token ≈ 0.75 слова. 1M tokens ≈ 750k слов ≈ весь Harry Potter × 4 книги. Trade-off: больше context = больше стоимость + slower + potential "lost in the middle".

Ниже: подробности, пример, смежные термины, FAQ.

Попробовать бесплатно →

Подробности

  • Tokens: Byte Pair Encoding (BPE) — ~0.75 слова per token в English, 0.5 в русском
  • Context budget: input + output ≤ window. При output = 4k, input max = (window - 4k)
  • Pricing: per-token. 1M context × $3 per 1M = $3 за вызов
  • Lost in the middle: LLMs хуже помнят middle of long context (2023 Stanford research)
  • Caching: Anthropic prompt cache, OpenAI automatic cache — reduce cost для repeat context

Пример

# Claude 1M context in Claude Agent SDK
from anthropic import Anthropic
client = Anthropic()

# Full codebase в context
with open('codebase.txt') as f:
  codebase = f.read()  # 500k tokens

response = client.messages.create(
  model='claude-opus-4-7[1m]',  # 1M context variant
  max_tokens=4096,
  system='You review code.',
  messages=[{'role':'user','content':f'Review:
{codebase}'}]
)

Смежные термины

Больше по теме

Часто задаваемые вопросы

Long context vs RAG?

RAG: cheaper, extensible к infinite data, but lose semantics на chunk boundaries. Long context: simpler код, but $$ cost + latency. Hybrid обычно best.

Нужен 2M токенов?

Для code review whole repo, book summary, long document analysis — да. Для chat — 32k-200k достаточно.

Как оптимизировать?

Prompt caching: 10× cheaper для repeat prefixes. Streaming для UX. Только необходимый context — not whole history.