Kaijing Ma

Safe Inference-Time Alignment via Lagrangian Reward Augmentation

Original note, sentence-aligned / 原创笔记逐句对照。Not a full-paper translation / 不是论文全文翻译。

English / 中文 · Source / 原文

Calibrate a reward rather than invent a decoder

校准奖励,而非发明解码器

LARA adds a calibrated cost penalty to an existing reward and passes the result to an inference-time alignment procedure.

LARA 在已有奖励中加入经过校准的代价惩罚,并将结果交给推理时对齐程序。

Its starting objective maximizes expected reward minus a KL penalty while constraining expected cost.

起点目标是在限制期望代价的同时,最大化期望奖励减去 KL 惩罚。

The reward and cost are fixed models; their scores are not automatically ground-truth helpfulness and harm.

奖励与代价由固定模型给出,其分数不会自动成为真实有用性和危害。

maximize_π E[r] − β E_x KL(π(·|x) || π_ref(·|x)), subject to E[c] ≤ τ

The scalar dual problem

标量对偶问题

Under bounded scores and a strict feasible policy, the Lagrangian converts the constraint into a multiplier λ ≥ 0.

在分数有界且存在严格可行策略时,拉格朗日函数将约束转化为乘子 λ ≥ 0。

r_λ = r − λc; π*_λ(y|x) ∝ π_ref(y|x) exp[(r(x,y) − λc(x,y))/β]
g(λ) = β E_x log E_{π_ref} exp[(r − λc)/β] + λτ

Differentiating gives g′(λ) = τ − E_{π*_λ}[c], so excess expected cost pushes the optimal multiplier upward.

求导得到 g′(λ) = τ − E_{π*_λ}[c],因此期望代价超预算时,最优乘子应向上调整。

The second derivative is the expected conditional cost variance divided by β and is nonnegative.

二阶导数为条件代价方差的期望除以 β,因此非负。

A constant cost supplies no curvature, so strong convexity needs an additional variance assumption.

常数代价不提供曲率,因此强凸性需要额外的方差假设。

The search interval must contain a useful solution; choosing its upper boundary does not itself establish feasibility.

搜索区间必须包含有用解;选到区间上边界本身不能证明可行。

Calibration and finite samples

校准与有限样本

For each calibration prompt, the procedure samples several responses from the reference model and estimates the log partition function.

对每个校准提示词,程序从参考模型采样若干回答,并估计对数配分函数。

It averages across prompts and minimizes the resulting convex scalar objective.

然后跨提示词平均,并最小化所得凸标量目标。

The finite-sample theorem assumes bounded rewards and costs, an interior optimum, and strong convexity on a compact interval.

有限样本定理假设奖励与代价有界、最优点位于区间内部,且紧区间内强凸。

Its error contains both the number of prompts N and the number of responses per prompt K.

误差同时包含提示词数量 N 和每个提示词的回答数 K。

Increasing N alone does not eliminate the inner Monte Carlo error when K stays fixed.

K 固定时,仅增加 N 不能消除内部 Monte Carlo 误差。

The policy mismatch must stay visible

必须保留对策略不匹配的说明

The exact derivation concerns a Gibbs distribution over complete responses.

精确推导针对完整回答上的 Gibbs 分布。

A token-local reward modification generally does not sample its exact next-token conditional, which would require summing over future completions.

逐词局部奖励修改通常不会采样其精确下一词条件分布,因为后者需要对未来续写求和。

Even ordinary deterministic Best-of-N selection is not generally identical to finite-temperature Gibbs sampling.

即便普通的确定性 Best-of-N 选择,一般也不等于有限温度 Gibbs 采样。

Thus empirical constraint satisfaction by a chosen decoder should be checked directly rather than inherited from the ideal policy formula.

因此,应直接检查具体解码器的经验约束满足情况,而不是从理想策略公式自动继承保证。

This qualification also applies to the paper's sequence-level reranking interpretation.

这一限定也适用于论文对序列级重排序的解释。

Experiments and practical boundaries

实验与实际边界

The main experiments use Alpaca-finetuned Llama-3.2-3B and Qwen-2.5-3B as reference policies.

主实验以经 Alpaca 微调的 Llama-3.2-3B 和 Qwen-2.5-3B 为参考策略。

Reward and cost models use BeaverTails preference labels, and comparisons include Safe-RLHF, SafeDPO, and inference-time baselines.

奖励与代价模型使用 BeaverTails 偏好标签,对照包含 Safe-RLHF、SafeDPO 和推理时基线。

Figure 1 sweeps λ to inspect the measured helpfulness-cost tradeoff; an 8B check appears in the appendix.

图 1 扫描 λ 以观察实测有用性与代价的权衡,附录还给出 8B 检查。

A calibrated expected-cost budget is a population average, not a guarantee for every prompt or a bound on attack success without a matching cost definition.

校准后的期望代价预算是总体平均,不是逐提示词保证;若代价定义不对应攻击成功,也不能视为攻击成功率上界。

A reproduction should separate calibration prompts from evaluation prompts and compare the deployed decoder's cost with the ideal tilted estimate.

复现应分离校准与评估提示词,并比较实际部署解码器的代价与理想倾斜分布估计。

Distribution shift, cost-model error, and inaccurate tail estimates remain important limitations.

分布漂移、代价模型误差与尾部估计不准仍是重要局限。