arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.17626cs.LGcs.SE
收藏

通过元步骤解码实现验证器引导的代码翻译

Verifiers in the Loop: Decoding Time Verification for Code Translation

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);University of Wisconsin–Madison(威斯康星大学麦迪逊分校);Google(谷歌)

Tianyang Zhou, Somesh Jha, Mihai Christodorescu, Kirill Levchenko, Varun Chandrasekaran

AI总结:

本研究提出了一种元步骤解码框架DTV,通过在生成过程中整合验证器调用,提高了代码翻译的通过率,同时减少了token的使用。

摘要:

测试时间缩放是提高大语言模型的重要机制,特别是在具有确定性验证器的任务中。代码翻译是典型例子:源程序约束有效输出,而编译器、类型检查器和行为检查提供精确的通过/失败反馈。现有方法通常在生成后才应用这些验证器,这效率低下,因为早期错误会破坏自回归上下文且很少被后续纠正。我们引入解码时间验证(DTV),一种框架将结构边界视为元步骤,用于引导解码。DTV在状态机控制器下交替生成与验证器调用,强制有效前缀,利用结构边界检查和结构感知回滚,防止错误传播并减少浪费的token。我们在C到Rust和JavaScript到TypeScript翻译上评估DTV。使用Qwen3-4B作为主要生成器,在匹配的token预算下,DTV将C到Rust的通过率从72.3%提升到82.0%,JavaScript到TypeScript的通过率从33.3%提升到46.0%,同时每案例使用更少的token;相同趋势在Gemma-4-E4B上也有所体现。在评估的匹配成本网格中,DTV在通过率与成本的权衡上优于事后验证或基于采样的缩放。这些结果表明,验证器引导的解码是代码翻译中有效利用推理时间计算的方法。

英文摘要:

Test-time scaling is an important mechanism for improving large language models, especially on tasks with deterministic verifiers. Code translation is a canonical example: the source program constrains valid outputs, while compilers, type checkers, and behavioral checks provide exact pass/fail feedback. Outcome-only approaches apply these verifiers only after generation, which is inefficient because early errors corrupt the autoregressive context and are rarely corrected later. We introduce Decoding Time Verification (DTV), a framework that treats structural boundaries as meta steps for verifier-guided decoding. DTV interleaves generation with verifier calls under a state-machine controller that commits verified prefixes, using structural-boundary checks and structure-aware rollback to prevent error propagation while reducing wasted tokens. We evaluate DTV on C-to-Rust and JavaScript-to-TypeScript translation. Using Qwen3-4B as the primary generator under matched token budgets, DTV improves pass rates from 72.3% to 82.0% on C-to-Rust and from 33.3% to 46.0% on JavaScript-to-TypeScript relative to matched self-refinement baselines, while using fewer tokens per case; the same trend largely transfers to Gemma-4-E4B and Qwen3-30B-A3B. In the evaluated cost-matched grid, DTV achieves a more favorable tradeoff between pass rate and generated-token cost than post-hoc verification or sampling-based scaling. These results show that verifier-guided decoding is an effective use of inference-time compute for code translation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑