BayesPO: Bayesian Prompt Optimization via Parallel-Tempered Gradient-Guided Discrete MCMC

📄 arXiv: 2607.16001 📥 PDF

作者: Junjie Zhou, Zhijian Ou

分类: cs.CL

发布日期: 2026-07-20


💡 一句话要点

提出BayesPO以优化大语言模型的提示生成

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 贝叶斯优化 提示生成 马尔可夫链蒙特卡洛 自然语言处理 大语言模型 能量基方法 并行温度调节

📋 核心要点

  1. 现有的提示优化方法多依赖启发式搜索,缺乏系统性和理论基础,导致效果不稳定。
  2. 本文提出BayesPO框架,通过贝叶斯后验采样将提示优化转化为能量基问题,利用梯度引导MCMC提议。
  3. 实验表明,BayesPO在多个任务上显著提升了提示的语义质量和模型的准确率,尤其是在复杂任务中表现优异。

📝 摘要(中文)

提示优化通过不更新模型参数来适应大型语言模型(LLMs),但许多自动提示优化器仍然依赖于对候选指令的启发式搜索。本文将提示优化视为对离散提示标记的贝叶斯后验采样,定义了一个后验分布,该分布结合了任务似然项和语言模型先验,从而将提示优化转化为基于能量的后验采样问题。我们提出的BayesPO框架使用了马尔可夫链蒙特卡洛(MCMC)方法,采用了Metropolis-Hastings修正的Gibbs-Langevin(GwL)提议,并集成了并行温度调节以全局探索复杂的能量景观。实验结果显示,BayesPO能够发现语义上有意义的提示,并在多个任务中显著提高准确率。

🔬 方法详解

问题定义:本文旨在解决现有提示优化方法的局限性,特别是其依赖启发式搜索导致的效果不稳定和缺乏理论支持的问题。

核心思路:通过将提示优化视为贝叶斯后验采样,结合任务似然和语言模型先验,形成一个能量基的后验采样问题,从而实现更系统的优化。

技术框架:BayesPO框架包括后验分布的定义、MCMC采样过程以及并行温度调节模块,整体流程从定义后验分布到生成优化提示。

关键创新:最重要的创新在于将提示优化转化为贝叶斯后验采样问题,并利用梯度引导MCMC提议,这一方法与传统启发式方法本质上不同。

关键设计:在GwL采样器的设计中,考虑了非权重绑定的LLM嵌入的实际约束,并通过并行温度调节来增强全局探索能力。实验中使用的损失函数和参数设置经过精心设计,以确保采样的有效性和效率。

📊 实验亮点

实验结果显示,BayesPO在24个指令诱导子任务上将平均准确率从60.04%提升至63.23%。此外,在诗歌完成任务中,通过并行温度调节成功逃离局部最优,发现了语义上有意义的提示。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理中的任务适应、对话系统的提示生成以及其他需要动态调整模型输入的场景。通过提供一种系统化的提示优化方法,BayesPO能够提高模型在特定任务上的表现,具有重要的实际价值和未来影响。

📄 摘要(原文)

Prompt optimization adapts large language models (LLMs) without updating model parameters, but many automatic prompt optimizers remain heuristic search procedures over candidate instructions. This paper studies prompt optimization as Bayesian posterior sampling over discrete prompt tokens. We define a posterior distribution by combining a task likelihood term, which rewards prompts that explain input-output examples, with a language-model prior, which favors fluent instructions. This converts prompt optimization into an energy-based posterior sampling problem, for which gradients can be used to guide discrete Markov chain Monte Carlo (MCMC) proposals over vocabulary tokens. We refer to our framework as BayesPO, short for Bayesian Prompt Optimization. In this paper, BayesPO is instantiated with Markov chain Monte Carlo: it uses a Metropolis-Hastings corrected Gibbs-with-Langevin (GwL) proposal and integrates parallel tempering for global exploration of rugged LLM-induced energy landscapes. The concrete sampler further adapts the GwL sampler to the practical constraints of non-weight-tied LLM embeddings. Experiments with Qwen2.5 models show that the sampler discovers semantically meaningful prompts on diagnostic tasks, that parallel tempering helps escape a local optimum in a poetry completion task, and that post-optimizing APE prompts on 24 instruction-induction subtasks improves average accuracy from 60.04% to 63.23%. The study also reveals two main limitations: energy minimization may overfit small optimization sets, and the current sampler remains computationally expensive. These findings position Bayesian prompt sampling as a principled post-optimization tool and point to a promising direction for probabilistic prompt optimization.