arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.34943cs.SEcs.AI
收藏

高效AI编码的推理模式:一项实证研究

Reasoning Patterns for Efficient AI Coding: An Empirical Study

Shanghai Jiao Tong University(上海交通大学)

Zhe Yin, Yuling Shi, Xiaodong Gu, Beijun Shen

AI总结:

本研究通过实证分析编码任务中大型推理模型的推理轨迹,识别出四类通用推理模式,开发了任务识别、模式引导提示、模式感知早停三种应用,可提升编码模型性能并降低token消耗,且能泛化到新模型。

摘要:

大型推理模型(LRMs)会生成包含中间推理行为的长推理轨迹,为研究和控制AI编码中的推理提供了机会。然而,这些轨迹中的潜在模式及其在分析和指导编码模型方面的潜力仍未被充分理解,这限制了对LRM推理的系统表征和推理时控制。我们对四种代表性编码任务中的推理模式开展了实证研究,将推理轨迹转化为结构化动作序列,并利用任务内支持、跨任务对比以及有效-无效支持对比来挖掘重复片段。我们表征了编码智能体的四种通用推理模式:用于代码生成的设计到实现模式、用于执行推理的状态追踪模式、用于调试的证据-修复-重新检查模式,以及用于翻译的语义映射模式。我们还分别识别出与有效和无效推理轨迹相关的正、负模式:正模式反映了验证驱动的收敛,而负模式则反映了无闭环的重复设计修订、反思和知识回忆。为验证其实际效用,我们评估了三种基于模式的应用:任务识别、模式引导提示和模式感知早停。捕捉通用推理模式的特征可在不访问任务描述或最终答案的情况下,从推理轨迹中准确识别任务;由正、负模式引导的提示可提升下游任务的整体准确率;而负模式感知早停则可大幅减少API报告的token用量,仅伴随pass@1准确率的小幅下降。这三种应用均能泛化到此前未见过的模型,表明推理模式可支持AI编码中LRM行为的分析与控制。

英文摘要:

Large Reasoning Models (LRMs) generate long reasoning traces that expose intermediate inference behavior, offering opportunities to study and control reasoning in AI coding. However, the underlying patterns in these traces and their potential for analyzing and guiding coding models remain poorly understood, limiting systematic characterization and inference-time control of LRM reasoning. We conduct an empirical study of reasoning patterns across four representative coding tasks. We transform reasoning traces into structured action sequences and mine recurring fragments using within-task support, cross-task contrasts, and valid--invalid support contrasts. We characterize four general reasoning patterns by coding agents: design-to-implementation for code generation, state tracing for execution reasoning, evidence--fix--recheck for debugging, and semantic mapping for translation. We further identify positive and negative patterns associated with valid and invalid reasoning traces, respectively. Positive patterns reflect verification-driven convergence, whereas negative patterns reflect repeated design revision, reflection, and knowledge recall without closure. To demonstrate their practical utility, we evaluate three pattern-based applications: task identification, pattern-guided prompting, and pattern-aware early stopping. Features capturing general reasoning patterns enable accurate task identification from reasoning traces without accessing task descriptions or final answers. Prompting guided by positive and negative patterns improves the overall accuracy of downstream tasks, while negative pattern-aware early stopping substantially reduces API-reported token usage with only a modest decrease in pass@1. All three applications also generalize to previously unseen models, showing that reasoning patterns can support both the analysis and control of LRM behavior in AI coding.

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

↑