arXiv:2605.28360cs.AI2026-05

用可组合的指令单元优化提示词,让大模型更智能地自动生成任务指令。

Prompt Codebooks: Discrete Compositional Optimization for Language Model Instruction Refinement

论文配图:Prompt Codebooks: Discrete Compositional Optimization for Language Model Instruction Refinement
图 1 · 摘自论文原文
  • 将提示词拆解为可复用的自然语言单元,按输入动态组合。
  • 在6个基准上提升11.8~13.5分,同时减少14.1倍提示长度。
  • 适合需要高效、灵活指令生成的智能体应用。

自动提示优化(APO)推动了大语言模型代理工作流的发展。然而,现有方法通常将每个任务的提示视为无实例感知的单一字符串,通过全局修改优化,导致更新脆弱且难以复用已学习的子行为。本文提出提示码本优化(PCO),一种新的组合式提示优化框架,将APO重构为对有限自然语言本能单元(原子化、可复用的指令片段)的离散学习。PCO以离散码本组织提示构建知识,通过基于大模型的编码器将每个输入路由至少量条目;生成器将其组合成执行器使用的提示;评判器输出结构化评价,并按变量分解为文本梯度,联合训练编码器、生成器、评判器与码本,采用语言值最小-最大目标。结果实现每实例路由:同一任务中不同输入获得不同的本能组合。在六个基准测试中,PCO相较零样本分别在Qwen3-8B和LLaMA-3.1-8B上提升13.50和11.80分。关键突破在于,其在HotpotQA上超越GEPA达+6.34(Qwen3-8B)和+4.27(LLaMA-3.1-8B),同时部署提示长度较MIPROv2减少14.1倍,较GEPA减少3.0倍。

原文摘要 · Abstract (English)

Automatic prompt optimization (APO) has driven significant gains in LLM-based agentic workflows. However, most existing methods treat each task's prompt as a monolithic, instance-blind string optimized through global edits, producing brittle updates and preventing the reuse of learned sub-behaviors. We propose Prompt Codebook Optimization (PCO), a novel compositional prompt optimization framework that recasts APO as discrete learning over a finite vocabulary of natural-language instincts--atomic, reusable instruction units. PCO organizes prompt-construction knowledge in a discrete codebook and routes each input to a small subset of entries via an LLM-based encoder; a generator composes them into a prompt for the executor; a critic emits a structured verdict that decomposes by attribution into per-variable textual gradients, jointly training the encoder, generator, critic, and codebook under a language-valued min-max objective. The resulting routing is per-instance: different inputs in the same task receive different instinct compositions. Across six benchmarks, PCO improves aggregate performance over zero-shot by +13.50 points on Qwen3-8B and +11.80 points on LLaMA-3.1-8B. Crucially, PCO surpasses GEPA on HotpotQA by +6.34 points (Qwen3-8B) and +4.27 points (LLaMA-3.1-8B), while simultaneously reducing deployed prompt length by up to 14.1$\times$ vs. MIPROv2 and 3.0$\times$ vs. GEPA.

提示优化组合生成大模型代理指令压缩

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。