Back to tree

上下文窗口:模型的临时书桌Context Window: A Temporary Desk

小禾让助手写春游通知。他贴了整本班级日志,助手反而漏掉集合地点。资料越多越好吗?He pastes an entire class diary into an assistant to write a trip notice. It misses the meeting place. Is more context always better?

第 1 步:一次能摊开多少Step 1: How much fits at once?

先把临时书桌和长期知识分开。Separate the temporary desk from learned knowledge.

一次能摊开多少 / How much fits at once?
上下文是这次生成时可用的输入。里面可以有指令、对话和资料。模型用词元计量,词元不等于汉字或单词。窗口限制一次能处理的总量。模型训练出的参数像已有经验,上下文像当前摊开的纸。聊天出现过,不代表此刻仍在窗口中。Context is the material available for this generation: instructions, conversation and supplied documents. It is measured in tokens, not exactly characters or words. A context window limits how much can be processed at once. Learned parameters are like prior experience; context is like papers on the current desk. Something mentioned earlier may no longer be present.

第 2 步:给回答留地方Step 2: Leave room for the answer

资料放满了,回答放哪里?If documents fill the desk, where does the answer go?

给回答留地方 / Leave room for the answer
小禾先放任务,再放时间地点。无关聊天可以删去或做摘要。还要为输出预留容量。不同系统可能压缩、截断或拒绝过长输入。摘要也可能漏掉细节。重要数字应回到原资料核对。装得下只是第一步,不等于模型能准确利用每一处信息。He keeps the task and meeting details, removes unrelated chat, and reserves room for an answer. Systems may summarize, truncate or reject oversized input. Summaries can omit details, so important numbers should be checked against the original. Fitting within the limit does not guarantee that every detail will be used accurately.

第 3 步:按需取资料Step 3: Retrieve what is relevant

整本日志放不下,怎样查得准?How can a long diary still be useful?

按需取资料 / Retrieve what is relevant
先查与春游有关的几段,再连同问题交给模型。这叫检索增强:先找材料,再据材料作答。检索选错,回答也会受影响。小禾保留原文位置,让通知里的时间可追溯。长期保存的文件,需要被检索或重新放入,才会成为当前上下文。Retrieve the few relevant passages and supply them with the question. Retrieval augmentation combines finding material with answering from it. Poor retrieval still produces poor evidence. He keeps passage locations so the notice can be checked. A stored file becomes current context only when its relevant contents are retrieved or supplied.

🎮 给书桌装资料🎮 Pack the context desk

选择任务所需卡片,既不能漏关键信息,也不能挤掉回答空间。词元数为简化示例。Select relevant cards without losing essential evidence or the answer reserve. Token counts are simplified.

一句话记住它:Remember: 上下文窗口限制当次可用材料,资料要相关,也要留空间。The context window bounds current material: keep it relevant and reserve space.
上下文不等于永久记忆。Context is not permanent memory.词元不等于固定字数。A token is not a fixed number of characters.检索与摘要也需要核对。Retrieval and summaries also need checking.
来源与边界:Sources and scope: Anthropic: Context engineering · Anthropic: Contextual retrieval

把握度:基础机制较高。容量与截断行为因模型和产品而异,不使用固定型号数字。Confidence: high for the basic mechanism. Capacity and truncation differ across models and products.

AI 辅助制作与资料核对。插图和互动为教学示意。AI-assisted production and source checking. Illustrations and interactions are teaching models.