\texttt{ReMind}:理解 LLM 中的演绎代码推理
\texttt{ReMind}: Understanding Deductive Code Reasoning in LLMs
AI总结:
本文揭示了LLM在演绎代码推理中的三大挑战,提出多智能体框架ReMind,通过生成代码变体、逐步跟踪变量状态和优化控制流来识别并修正推理缺陷,实现了卓越的零样本泛化性能。
摘要:
大型语言模型(LLMs)在代码相关任务上取得了显著进展。尽管取得了进步,但实证证据表明,它们仍然难以进行\emph{演绎代码推理},即推理程序执行过程的能力。虽然先前的研究已经认识到了这一局限性,但其潜在原因在很大程度上仍未被充分探索。在本文中,我们首先提出了一项全面的实证研究,揭示了破坏演绎代码推理的三个关键挑战:(1) 生成能力与推理能力之间的内在差距,(2) 对代码来源的一致偏差,以及 (3) 在复杂基准测试上较弱的零样本泛化能力。鉴于这些挑战,我们提出了 \texttt{ReMind},一个由 \texttt{Mutator}、\texttt{Executor} 和 \texttt{Inspector} 组成的多智能体框架。\texttt{Mutator} 生成代码变体以减轻对代码来源的偏差,\texttt{Executor} 逐步跟踪变量状态以暴露不一致性,而 \texttt{Inspector} 识别有问题的推理步骤并提供控制流优化以弥合内在的推理差距。通过它们的协调合作,\texttt{ReMind} 系统地识别并优化推理缺陷,实现了出色的性能并实现了稳健的零样本泛化。在两个基准测试上使用五个 LLMs 进行的广泛实验表明,与基线方法相比,\texttt{ReMind} 在演绎代码推理方面具有卓越的优势。
英文摘要:
Large Language Models (LLMs) have achieved remarkable progress in code-related tasks. Despite their advancement, empirical evidence reveals that they still struggle with \emph{deductive code reasoning}, the ability to reason about the program execution process. While prior studies have recognized this limitation, the underlying causes remain largely underexplored. In this paper, we begin by presenting a comprehensive empirical study that reveals three key challenges undermining deductive code reasoning: (1) an intrinsic gap between generation and reasoning abilities, (2) a consistent bias towards code sources, and (3) weak zero-shot generalization on complex benchmarks. In light of these challenges, we propose \texttt{ReMind}, a multi-agent framework composed of \texttt{Mutator}, \texttt{Executor}, and \texttt{Inspector}. The \texttt{Mutator} generates code variants to mitigate bias towards code sources, the \texttt{Executor} traces variable states step-by-step to expose inconsistency, and the \texttt{Inspector} identifies problematic reasoning steps and provides control-flow refinement to bridge the intrinsic reasoning gap. Through their coordinated collaboration, \texttt{ReMind} systematically identifies and refines reasoning flaws, achieving outstanding performance and enabling robust zero-shot generalization. Extensive experiments on two benchmarks with five LLMs demonstrate the superior advantages of \texttt{ReMind} compared to baseline approaches in deductive code reasoning.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。