arXiv:2607.16001cs.CL2026-07

用贝叶斯方法优化提示词,让大模型更懂任务意图。

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

论文配图:BayesPO: Bayesian Prompt Optimization via Parallel-Tempered Gradient-Guided Discrete MCMC
图 1 · 摘自论文原文
  • 将提示优化建模为贝叶斯后验采样,结合任务似然与语言模型先验
  • 在24个指令归纳任务上,准确率从60.04%提升至63.23%
  • 适合需要高精度提示的场景,尤其擅长跳出局部最优

提示优化可在不更新模型参数的前提下适配大语言模型,但多数自动优化器仍依赖启发式搜索。本文将提示优化视为离散提示词上的贝叶斯后验采样,通过任务似然项(奖励能解释输入输出示例的提示)与语言模型先验(偏好流畅指令)构建后验分布。这将问题转化为基于能量的后验采样,利用梯度引导离散马尔可夫链蒙特卡洛(MCMC)提案。提出的方法称为BayesPO,采用带莱格朗日修正的吉布斯-朗之万(GwL)提议,并引入并行退火以全局探索由大模型引起的复杂能量景观。具体采样器还针对非权值共享嵌入的实际情况进行了调整。在Qwen2.5模型上的实验表明,该方法能在诊断任务中发现语义合理的提示,在诗歌补全任务中有效逃离局部最优,且对24个指令归纳子任务的后优化使平均准确率从60.04%提升至63.23%。研究也揭示两大局限:能量最小化可能对小规模优化集过拟合,当前采样器仍计算开销较大。这些发现确立了贝叶斯提示采样作为一种原理严谨的后优化工具,并指明概率提示优化的可行方向。

原文摘要 · Abstract (English)

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.

提示优化贝叶斯方法大模型采样

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