arXiv:2605.17626cs.LGcs.SE2026-05被引 1

用验证器实时纠错,让代码翻译更准更快。

Verifier-Guided Code Translation via Meta-Step Decoding

论文配图:Verifier-Guided Code Translation via Meta-Step Decoding
图 1 · 摘自论文原文
  • 生成时穿插验证,通过结构边界控制避免错误累积。
  • C-to-Rust任务通过率从72.3%提至82.0%,JS-to-TypeScript从33.3%提至46.0%。
  • 适合需要高可靠性代码转换的开发者或自动化工具设计者。

测试时扩展是提升大模型性能的重要机制,尤其在具有确定性验证器的任务中。代码翻译是典型例子:源程序限制合法输出,而编译器、类型检查器和行为检测可提供精确的通过/失败反馈。现有方法通常仅在生成后应用验证器,效率低下,因早期错误会污染自回归上下文且难以修正。我们提出解码时验证(DTV)框架,将结构边界视为元步骤,由状态机控制器协调生成与验证,通过结构边界检查和结构感知回滚,防止错误传播并减少无效词元消耗。我们在C-to-Rust和JavaScript-to-TypeScript翻译任务上评估DTV。以Qwen3-4B为生成器,在匹配词元预算下,DTV使C-to-Rust通过率从72.3%提升至82.0%,JavaScript-to-TypeScript从33.3%提升至46.0%,同时每案例使用更少词元;相同趋势也适用于Gemma-4-E4B。在成本匹配的评估网格中,DTV在通过率-成本权衡上优于事后验证或采样扩展方法。结果表明,验证器引导的解码是代码翻译中有效利用推理时计算的方式。

原文摘要 · Abstract (English)

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 check- ers, and behavioral checks provide exact pass/fail feedback. Existing approaches typically 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 enforces valid 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. In the evaluated cost-matched grid, DTV achieves a more favorable pass-rate-cost tradeoff 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.

代码生成验证引导解码优化

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