How Large Language Model Context Windows Work
An explainer collected in the WeChat public account AngryCode describes the context window as the amount of text a language model can process at one time, measured in tokens rather than characters. It explains that system instructions, conversation history, the current prompt, pasted documents, and generated output share the same capacity, so older information may be dropped or summarized when the limit is reached. The article also offers practical guidance on retaining key facts, summarizing older conversations, including only relevant document sections, and leaving room for the response.
Understanding what a model can currently see helps explain apparent “forgetting” and makes context management a practical part of using long-document and long-conversation workflows.
你跟 ChatGPT 说"我叫小明",聊了一百轮之后再问"我叫什么",它答不上来。 不是它变笨了,是"小明"这两个字早就被挤出了它的视线。
本文收录于微信公众号:愤怒的代码 AngryCode
0x00、一句话定义
上下文窗口(Context Window)是模型在同一个时刻能"读进去并记住"的最大文本量,用 token 来衡量,而不是用字数。
它是模型的短期记忆。
你可以把它理解成一张固定大小的桌面:模型每回答一次,都要把你给的资料摊在桌面上读一遍,桌面之外的东西它一概看不见。桌面就这么大,东西太多,就得往下撤。
#ChatGPT#GPT-4o#DeepSeek#Llama 3.1#Claude#Gemini#Claude Code#OpenAI Codex#ChatGPT Memory#Multi-head Latent Attention