Tokens 是 LLMs 处理文本的单位(词的片段),context window 是 LLM 一次能够考虑的最大文本量(tokens)。理解它们对于有效使用 LLMs、管理成本和处理其限制很重要。
Tokens 是什么
TOKEN → the unit LLMs process text in (not words/characters, but PIECES):
→ text is split into tokens (roughly ~4 characters or ~0.75 words each in English)
→ e.g. 'unbelievable' might be 3 tokens; common words are often 1 token
→ the model processes and generates token by token
→ LLMs work in tokens (input and output are measured in tokens)
Context window
CONTEXT WINDOW → the maximum number of TOKENS an LLM can process at once (input + output):
→ everything the model 'sees' (your prompt + conversation + retrieved context) must FIT
→ ranges from thousands to millions of tokens (varies by model)
→ BEYOND the limit → the model can't consider it (truncated/doesn't fit)
→ a hard limit on how much context the model can work with at once
