arXiv:2604.03253cs.CLcs.LG2026-04被引 1

让大模型自己模拟代码运行,提升编程竞赛表现

Self-Execution Simulation Improves Coding Models

论文配图:Self-Execution Simulation Improves Coding Models
图 1 · 摘自论文原文
  • 通过逐步模拟代码执行过程训练模型
  • 在多个竞赛基准上性能优于传统推理方法
  • 适合想提升代码自检能力的研究者

当前大语言模型生成代码时难以准确评估其执行结果。本文提出一种新方法,让代码大模型学习以逐步方式模拟程序执行,并利用该能力改进编程竞赛表现。方法结合自然语言执行轨迹的监督微调、基于真实执行的文本解释,以及使用可验证奖励的强化学习。引入两个互补目标:根据代码和输入预测输出,以及在有真实或自预测执行反馈下解决编程任务。这使模型能对多个候选解进行自我验证,并通过模拟测试执行实现迭代纠错。在多个竞赛基准上,该方法均持续优于标准推理方法。我们还进行了消融实验与分析,揭示执行模拟的作用及其局限性。

原文摘要 · Abstract (English)

A promising research direction in enabling LLMs to generate consistently correct code involves addressing their inability to properly estimate program execution, particularly for code they generate. In this work, we demonstrate that Code LLMs can be trained to simulate program execution in a step-by-step manner and that this capability can be leveraged to improve competitive programming performance. Our approach combines supervised fine-tuning on natural language execution traces, textual explanations grounded in true execution, with reinforcement learning using verifiable rewards. We introduce two complementary objectives: output prediction given code and inputs, and solving competitive programming tasks with either ground-truth or self-predicted execution feedback. These objectives enable models to perform self-verification over multiple candidate solutions, and iterative self-fixing by simulating test execution. Across multiple competitive programming benchmarks, our method yields consistent improvements over standard reasoning approaches. We further present ablations and analysis to elucidate the role of execution simulation and its limitations.

代码生成自验证强化学习

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