arXiv:2505.01954cs.LG2025-05被引 4

用验证器梯度精准控制语言模型生成的语义属性。

Semantic Probabilistic Control of Language Models

  • 基于验证器梯度重加权下一个词分布,实现语义约束下的高效采样。
  • 在毒性、情感和主题一致性上满足约束概率超95%,且生成质量未下降。
  • 适合需要精确语义控制的生成场景,如安全对话与内容过滤。

语义控制旨在引导语言模型生成满足细微非词汇约束的内容,如毒性、情感或礼貌性,这些属性可通过序列级验证器捕捉。这本质上是条件于目标属性的模型分布采样,但由于验证器不可分解,计算上难以实现。现有方法要么仅处理句法约束,无法涵盖上述属性;要么依赖采样探索条件分布,对低概率事件估计效率低下。本文利用验证器的梯度信息,高效推理所有满足目标属性的生成结果,通过重加权下一个词分布实现精确控制。从初始样本出发,构建一个偏向语义相似句子的局部语言模型分布,从而可计算期望句子嵌入。该期望嵌入结合初始样本处的验证器评估,用于估计满足约束的概率,并直接指导下一个词分布更新。我们在控制毒性、情感和主题一致性方面进行了评估,生成结果满足约束的概率超过95%,且未降低生成质量。

原文摘要 · Abstract (English)

Semantic control entails steering LM generations towards satisfying subtle non-lexical constraints, e.g., toxicity, sentiment, or politeness, attributes that can be captured by a sequence-level verifier. It can thus be viewed as sampling from the LM distribution conditioned on the target attribute, a computationally intractable problem due to the non-decomposable nature of the verifier. Existing approaches to LM control either only deal with syntactic constraints which cannot capture the aforementioned attributes, or rely on sampling to explore the conditional LM distribution, an ineffective estimator for low-probability events. In this work, we leverage a verifier's gradient information to efficiently reason over all generations that satisfy the target attribute, enabling precise steering of LM generations by reweighing the next-token distribution. Starting from an initial sample, we create a local LM distribution favoring semantically similar sentences. This approximation enables the tractable computation of an expected sentence embedding. We use this expected embedding, informed by the verifier's evaluation at the initial sample, to estimate the probability of satisfying the constraint, which directly informs the update to the next-token distribution. We evaluated the effectiveness of our approach in controlling the toxicity, sentiment, and topic-adherence of LMs yielding generations satisfying the constraint with high probability (>95%) without degrading their quality.

语言模型控制语义约束生成质量验证器梯度

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