Plain-language definition
一句话定义
模型一次能「记住并处理」的最大文本量(按 token 计),相当于它一次对话的「脑容量」。
Original definition
英文原文定义
The context window is the maximum number of tokens a model can process in a single forward pass, encompassing both input (prompt) and output.
Two levels
分难度讲解
入门版
想象模型的「短期记忆」只有这么大。你塞进去的 prompt + 历史 + 它要生成的回复,总和不能超过这个窗口。窗口太小,前面的内容会被「忘掉」。
进阶版
上下文窗口从早期 GPT-2 的 1024 token,到 GPT-4 Turbo 的 128k、Gemini 1.5 的 1M+、Claude 200k。窗口扩大带来长文档分析、整本书理解、长视频理解等新能力,但也带来注意力稀释(lost in the middle)问题。
Real-world example
真实例子
把一份 100 页的 PDF 喂给 GPT-4 Turbo(128k 上下文)让它总结——只要总 token 数不超窗口,它就能一次读完。
Keep exploring