让大模型代码生成的推理过程可被全局理解,揭示其真实决策逻辑。
Enabling Global, Human-Centered Explanations for LLMs:From Tokens to Interpretable Code and Test Generation
- 将局部词元解释映射为高层编程类别,实现全局代码级可解释性。
- 通过统计聚合降低50%以上解释不确定性,发现模型依赖缩进等浅层语法。
- 用户研究证实模型推理与人类开发者严重不符,凸显全局解释必要性。
随着代码大语言模型(LM4Code)在软件工程中日益重要,对其输出结果建立信任变得关键。然而,传统准确率指标掩盖了生成模型的内在推理过程,难以揭示决策依据。尽管事后可解释性方法试图填补这一空白,但通常仅提供局部、词元级别的洞察,无法支持开发者理解的全局分析。本文提出代码推理(CodeQ)框架,通过将词元级解释映射至高层次编程类别,实现全局可解释性。对数千个词元级解释的聚合分析显示,该方法能从噪声数据中提炼清晰信号,使解释不确定性(香农熵)下降超过50%。此外,我们发现代码生成模型(codeparrot-small)始终偏好浅层语法特征(如缩进),而非深层语义逻辑。在37名参与者的用户研究中,其推理与人类开发者显著不一致。这些隐藏于传统指标下的发现,凸显了全局可解释性技术在建立对LM4Code信任中的核心作用。
原文摘要 · Abstract (English)
As Large Language Models for Code (LM4Code) become integral to software engineering, establishing trust in their output becomes critical. However, standard accuracy metrics obscure the underlying reasoning of generative models, offering little insight into how decisions are made. Although post-hoc interpretability methods attempt to fill this gap, they often restrict explanations to local, token-level insights, which fail to provide a developer-understandable global analysis. Our work highlights the urgent need for \textbf{global, code-based} explanations that reveal how models reason across code. To support this vision, we introduce \textit{code rationales} (CodeQ), a framework that enables global interpretability by mapping token-level rationales to high-level programming categories. Aggregating thousands of these token-level explanations allows us to perform statistical analyses that expose systemic reasoning behaviors. We validate this aggregation by showing it distills a clear signal from noisy token data, reducing explanation uncertainty (Shannon entropy) by over 50%. Additionally, we find that a code generation model (\textit{codeparrot-small}) consistently favors shallow syntactic cues (e.g., \textbf{indentation}) over deeper semantic logic. Furthermore, in a user study with 37 participants, we find its reasoning is significantly misaligned with that of human developers. These findings, hidden from traditional metrics, demonstrate the importance of global interpretability techniques to foster trust in LM4Code.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。