arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2604.12214cs.SE
收藏

结构锚点与推理脆弱性:理解LLM4Code中的CoT鲁棒性

Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Code

Polytechnique Montreal(蒙特利尔高等理工学院);School of Cryptologic Science and Engineering, Shandong University(山东大学密码学科学与工程学院)

Yang Liu, Da Song, Armstrong Foundjem, Heng Li, Foutse Khomh

AI总结:

本文研究了CoT提示在LLM4Code中的鲁棒性,通过系统扰动分析发现其性能依赖于模型家族、任务结构和提示明确性,并识别出三种轨迹变形模式。

摘要:

链式推理(CoT)提示被广泛用于从大型语言模型中提取显式推理以生成代码(LLM4Code)。然而,其对鲁棒性和在现实输入扰动下推理轨迹稳定性的影响仍不明确。先前工作主要通过最终正确性评估CoT,留下关键空白:如何理解CoT如何重塑内部不确定性动态以及为何有时损害而非帮助代码生成。本文认为CoT并非普遍有益;其鲁棒性取决于扰动是否破坏推理到代码轨迹中结构敏感的承诺点。我们对六个模型和两个代码基准(MHPP和BigCodeBench)进行了受控的大规模实证研究,对任务文档字符串进行系统性的字符、单词和句子级扰动。我们通过令牌级不确定性仪器完整生成轨迹,并定义了三种新的结构锚点:推理-代码转换、符号承诺和算法表达。发现:(1)CoT不产生均匀的性能或鲁棒性提升:其益处取决于模型家族、任务结构和提示明确性。(2)CoT和No-CoT表现出不同的鲁棒性特征,不同扰动家族触发不同的失败模式。(3)我们识别出三种反复出现的轨迹变形——延长、分支和简化——当扰动与结构锚点相互作用时系统性出现,解释了失败模式。(4)早期阶段的不确定性作为可靠的诊断信号,用于定位轨迹不稳定性开始于敏感锚点附近。这些结果为CoT的混合性能提供了统一解释,并提出了构建更鲁棒推理代码生成器的设计原则。

英文摘要:

Chain-of-Thought (CoT) prompting is widely used to elicit explicit reasoning from large language models for code (LLM4Code). However, its impact on robustness and the stability of reasoning trajectories under realistic input perturbations remains poorly understood. Prior work has largely evaluated CoT through final correctness, leaving a critical gap in understanding how CoT reshapes internal uncertainty dynamics and why it sometimes harms rather than helps code generation. We suggest that CoT is not uniformly beneficial; instead, its robustness depends on whether perturbations destabilize structurally sensitive commitment points along the reasoning-to-code trajectory. We conduct a controlled, large-scale empirical study of CoT across six models and two code benchmarks (MHPP and BigCodeBench), subjecting task docstrings to systematic character-, word-, and sentence-level perturbations. We instrument full generation traces with token-level uncertainty and define three novel structural anchors: reasoning-code transition, symbolic commitment, and algorithmic articulation. Findings: (1) CoT does not yield uniform performance or robustness gains: its benefits are contingent on model family, task structure, and prompt explicitness. (2) CoT and No-CoT exhibit distinct robustness profiles, with different perturbation families triggering different failure modes. (3) We identify three recurrent trajectory deformations--Lengthening, Branching, and Simplification--that systematically emerge when perturbations interact with structural anchors and explain failure patterns. (4) Early-stage uncertainty serves as a reliable diagnostic signal for localizing where trajectory instability begins around sensitive anchors. These results provide a unified explanation for CoT's mixed performance and suggest design principles for building more robust reasoning-based code generators.

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

↑