用提示词让大模型像可调神经网络一样精确计算函数
A Theoretical Framework for Prompt Engineering: Approximating Smooth Functions with Transformer Prompts
- 将提示词设计为可配置的计算结构,使大模型动态调整内部运算
- 证明了大模型能用精心设计的提示逼近任意β阶可微函数,精度可无限提升
- 解释了长提示、多样化词元等技巧为何有效,适合研究智能体与提示工程者
提示工程已成为引导大语言模型(LLMs)生成期望响应的关键技术,显著提升其在各类任务中的表现。随着LLMs逐渐从静态预测器演变为具备推理、决策和动态适应复杂环境能力的智能体,其提示工程的理论基础却仍不明确。本文提出一个形式化框架,表明当使用精心设计的提示时,变压器模型可作为可配置的计算系统,在推理过程中模拟‘虚拟’神经网络。具体而言,输入提示等价于配置网络参数,使模型能动态调整内部计算。基于此构建,我们建立了对β阶可微函数的逼近理论,证明在适当结构的提示引导下,变压器能以任意精度逼近此类函数。此外,该框架为多种经验上成功的提示工程技术提供了理论支持,包括使用更长且结构化的提示、过滤无关信息、增强提示词元多样性以及利用多智能体交互。通过将大模型视为可适配的智能体而非静态模型,我们的发现突显了其在自主推理与问题求解方面的潜力,为提示工程与智能体设计的更稳健、理论化发展铺平道路。
原文摘要 · Abstract (English)
Prompt engineering has emerged as a powerful technique for guiding large language models (LLMs) toward desired responses, significantly enhancing their performance across diverse tasks. Beyond their role as static predictors, LLMs increasingly function as intelligent agents, capable of reasoning, decision-making, and adapting dynamically to complex environments. However, the theoretical underpinnings of prompt engineering remain largely unexplored. In this paper, we introduce a formal framework demonstrating that transformer models, when provided with carefully designed prompts, can act as a configurable computational system by emulating a ``virtual'' neural network during inference. Specifically, input prompts effectively translate into the corresponding network configuration, enabling LLMs to adjust their internal computations dynamically. Building on this construction, we establish an approximation theory for $β$-times differentiable functions, proving that transformers can approximate such functions with arbitrary precision when guided by appropriately structured prompts. Moreover, our framework provides theoretical justification for several empirically successful prompt engineering techniques, including the use of longer, structured prompts, filtering irrelevant information, enhancing prompt token diversity, and leveraging multi-agent interactions. By framing LLMs as adaptable agents rather than static models, our findings underscore their potential for autonomous reasoning and problem-solving, paving the way for more robust and theoretically grounded advancements in prompt engineering and AI agent design.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。