用可扩展的自动机方法改进语言模型约束生成,减少采样偏差。
Mitigating Bias in Locally Constrained Decoding via Tractable Proposals
- 将约束转为张量化自动机,实现高效GPU推理
- 结合逻辑与概率信息,用电路乘法生成更优采样提案
- 在函数调用等任务中显著降低粒子数需求,收敛更快
大型语言模型生成常无法满足如JSON模式等约束。现有局部约束解码(LCD)通过盲目屏蔽下一个词导致采样偏差,性能下降。近期工作采用序列蒙特卡洛(SMC)缓解此问题,但提案分布和势函数设计仍具挑战。本文提出一种通用方法,从 $p_{\mathrm{lm}}( \cdot \mid \mathrm{constraint})$ 构造提案与势函数。首先,证明以有限自动机形式表示的约束可张量化,实现高效GPU执行,用于构建全局约束解码(GCD)提案。其次,利用张量化自动机与隐马尔可夫模型共享电路结构的特点,通过电路乘法获得同时包含逻辑与概率信息的随机性GCD(P-GCD)提案。在函数调用、关键词生成和SQL生成任务上评估(P-)GCD。实验表明,在相同SMC设置下,相比LCD提案,(P-)GCD以显著更少的粒子数更快收敛至目标分布。
原文摘要 · Abstract (English)
Generations from large language models often fail to conform to desired constraints such as JSON schema. Existing locally constrained decoding (LCD) approaches enforce constraints by myopically masking out next tokens, resulting in biased sampling and degradation in performance. Recent work uses sequential Monte Carlo (SMC) methods to mitigate such biases, but designing effective proposal distributions or potential functions remains a key challenge. In this work, we propose a generic approach to construct proposals and potentials for SMC sampling from $p_{\mathrm{lm}}( \cdot \mid \mathrm{constraint})$. First, we show that constraints specified as finite automata can be tensorized for efficient execution on GPUs, which we use to construct globally constrained decoding (GCD) proposals. In addition, leveraging the fact that tensorized finite automata share the same circuit structure as hidden Markov models, we circuit-multiply them to obtain the probabilistic GCD (P-GCD) proposals encoding both logical and probabilistic information about the target distributions. We evaluate (P-)GCD on the tasks of function calling, keyword-based generation, and SQL generation. Experiments show that under the same SMC sampling setup, compared to LCD proposals, (P-)GCD converges faster to the target distribution with significantly fewer particles.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。