大型語言模型上下文工程綜述
A Survey of Context Engineering for Large Language Models
July 17, 2025
作者: Lingrui Mei, Jiayu Yao, Yuyao Ge, Yiwei Wang, Baolong Bi, Yujun Cai, Jiazhi Liu, Mingyu Li, Zhong-Zhi Li, Duzhen Zhang, Chenlin Zhou, Jiayi Mao, Tianze Xia, Jiafeng Guo, Shenghua Liu
cs.AI
摘要
大型語言模型(LLMs)的性能根本上取決於推理過程中提供的上下文信息。本調查引入了上下文工程(Context Engineering),這是一門超越簡單提示設計的正式學科,旨在系統性地優化LLMs的信息負載。我們提出了一個全面的分類法,將上下文工程分解為其基礎組件以及將這些組件整合到智能系統中的複雜實現。我們首先考察基礎組件:上下文檢索與生成、上下文處理以及上下文管理。接著,我們探討這些組件如何通過架構整合來創建複雜的系統實現:檢索增強生成(RAG)、記憶系統與工具集成推理,以及多代理系統。通過對1300多篇研究論文的系統分析,本調查不僅為該領域建立了技術路線圖,還揭示了一個關鍵的研究缺口:模型能力之間存在根本性的不對稱。雖然當前模型在經過先進上下文工程的增強後,展現出理解複雜上下文的顯著能力,但在生成同等複雜的長篇輸出方面卻表現出明顯的局限性。解決這一缺口是未來研究的一個重要優先事項。最終,本調查為推進上下文感知AI的研究人員和工程師提供了一個統一的框架。
English
The performance of Large Language Models (LLMs) is fundamentally determined
by the contextual information provided during inference. This survey introduces
Context Engineering, a formal discipline that transcends simple prompt design
to encompass the systematic optimization of information payloads for LLMs. We
present a comprehensive taxonomy decomposing Context Engineering into its
foundational components and the sophisticated implementations that integrate
them into intelligent systems. We first examine the foundational components:
context retrieval and generation, context processing and context management. We
then explore how these components are architecturally integrated to create
sophisticated system implementations: retrieval-augmented generation (RAG),
memory systems and tool-integrated reasoning, and multi-agent systems. Through
this systematic analysis of over 1300 research papers, our survey not only
establishes a technical roadmap for the field but also reveals a critical
research gap: a fundamental asymmetry exists between model capabilities. While
current models, augmented by advanced context engineering, demonstrate
remarkable proficiency in understanding complex contexts, they exhibit
pronounced limitations in generating equally sophisticated, long-form outputs.
Addressing this gap is a defining priority for future research. Ultimately,
this survey provides a unified framework for both researchers and engineers
advancing context-aware AI.