paperbot · PL 论文追踪

全部论文 待读 收藏

P1 T-REX: Teaching Large Language Models to Reason with Verbalized Execution Semantics

T-REX:教导大型语言模型用言语化执行语义进行推理
OOPSLA 10(OOPSLA2)2026匹配度 5/10 · 论文处于 LLM×程序分析的交叉地带,核心是用教师-学生蒸馏让 LLM 逐步推理并预测程序执行状态,并在结尾讨论将动态分析(如 Python 动态切片)静态化为近似静态分析,与'利用 LLM 改进静态分析/形式化验证'有一定关联。但其主体是执行状态预测与调试,而非静态分析/形式化验证本身,也未涉及浮点或贝叶斯程序分析,与用户核心方向仅部分重合。引用 0 inbox
Yan Wang, Ling Ding, Jiechen Sun, Tien N. Nguyen, Shaohua Wang, Aashish Yadavally, Xin Xia, Yanan Zheng
crossref: 2026-10-02

AI 速览

一句话:提出教师-学生框架 T-REX,用逐步自然语言执行语义理由训练小模型预测程序状态,超越 GPT-4o。

大型语言模型在代码搜索、摘要与生成等静态代码任务上表现优异,但在动态代码推理——即不实际运行程序而推断其执行行为——方面仍受限,原因在于训练数据缺乏运行时上下文。本文提出 T-REX,一个面向执行预测的教师-学生框架,将 LLM 训练锚定在真实执行与相应执行语义上。T-REX 让大型教师模型 Explainer 生成细粒度、逐步的自然语言理由,解释实际执行中程序状态如何从一条语句转移到另一条语句;这些理由用于训练较小的学生模型 Reasoner 预测下一程序状态,从而以更低计算成本精确模拟程序行为。这种基于执行、以理由驱动的训练与语句级、感知状态转移的执行语义对齐,提升了预测准确率。实验表明,Reasoner 在多个运行时行为预测维度上优于规模大得多的 GPT-4o 与 GPT-4o-mini,并有助于运行时错误的静态检测与调试。最后,作者讨论了如何通过此类教师-学生蒸馏将 T-REX 推广到对任意动态分析的静态模拟,并以 Python 动态程序切片为例说明。

问题
LLM 在静态代码任务上表现良好,但难以在不运行程序的情况下推断动态执行行为,因其训练缺少运行时上下文。
方法
提出教师-学生框架 T-REX:教师模型 Explainer 生成语句级、逐步的自然语言执行理由,用这些理由训练较小的学生模型 Reasoner 预测下一程序状态。
评估
在多个运行时行为预测维度上与 GPT-4o、GPT-4o-mini 等更大模型对比,并评估其在运行时错误静态检测与调试中的辅助作用,还以 Python 动态程序切片展示向其他动态分析静态模拟的推广。
原文摘要(Abstract)

Large language models (LLMs) have shown strong performance in static code tasks like code search, summarization, and generation, but remain limited in dynamic code reasoning, which involves inferring how programs behave during execution without actually running them. This limitation stems from LLMs being trained on static code and lacking the necessary runtime context. In this paper, we present T-REX, a novel teacher-student framework for execution prediction that addresses these limitations by grounding LLM training in actual execution and corresponding execution semantics. T-REX uses a large teacher model (Explainer) to generate fine-grained, stepwise natural language rationales explaining how program state transitions from one statement to another during actual execution. These rationales are used to train a smaller student model (Reasoner) to predict next program states, enabling accurate simulation of program behavior with lower computational cost. Our execution-grounded, rationale-driven training aligns with transition-aware execution semantics at the statement level, enhancing prediction accuracy. Our experiments show that T-REX enables Reasoner to outperform much larger GPT-4o and GPT-4o-mini models across multiple dimensions of runtime behavior prediction, while also aiding in static detection of runtime errors as well as in debugging. Finally, we discuss how T-REX can be generalized to static emulation of any dynamic analysis through such a teacher-student distillation, illustrating with the specific case of dynamic program slicing in Python.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot12121,
  title = {T-REX: Teaching Large Language Models to Reason with Verbalized Execution Semantics},
  author = {Yan Wang and Ling Ding and Jiechen Sun and Tien N. Nguyen and Shaohua Wang and Aashish Yadavally and Xin Xia and Yanan Zheng},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {OOPSLA2},
  year = {2026},
  doi = {10.1145/3839452}
}