今年 6 月,Karpathy 发布一条篇推文,正式提出了 context engineering:“filling an LLM’s context window with just the right information for the next step(在大语言模型的上下文窗口中放入正好适合它执行下一步所需的信息)”,这个概念迅速引起了众多开发者的共鸣。核心在于每次调用 LLM 时明确哪些信息需要放入 context window,这其实包含了两个循环:

 内循环(inner loop):即时筛选,明确当前结果生成所需的 context;

 外循环(outer loop):长期优化,通过迭代确保 context window 始终只包含相关信息。

起因:context rot

Chroma 在 7 月发布的报告 Context Rot: How Increasing Input Tokens Impacts LLM Performance 显示,随着 context 长度增加,模型的注意力会分散,推理能力也会随之下降。

解决办法

offload