How Do LLMs Read Bug Reports? An Empirical Study of Attention in LLMs for Automated Program Repair

📄 arXiv: 2607.25873v1 📥 PDF

作者: Ramtin Ehsani, Irene Manotas, Saurabh Pujar, Luca Buratti, Preetha Chatterjee

分类: cs.SE, cs.AI

发布日期: 2026-07-28

备注: Accepted at the 41st IEEE/ACM International Conference on Automated Software Engineering (ASE) 2026 Conference


💡 一句话要点

通过注意力模式分析提升LLM自动程序修复的成功率

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大语言模型 自动程序修复 注意力机制 实证研究 软件工程 错误报告分析

📋 核心要点

  1. 现有的LLM自动程序修复系统在处理不同错误时表现不一致,缺乏对注意力分配的深入理解。
  2. 论文通过实证研究分析LLM在处理错误报告时的注意力模式,揭示成功与失败修复的注意力差异。
  3. 研究结果表明,成功修复与开发者识别的关键部分之间的注意力对齐程度较高,强调了注意力分配的重要性。

📝 摘要(中文)

基于大语言模型(LLM)的自动程序修复系统正在快速发展,但其性能仍然不一致。即使在相同的上下文信息下,LLM可能对一个错误生成正确的补丁,而对另一个相关错误却失败。本文首次对LLM在程序修复中的注意力模式进行了实证研究,分析了319个真实世界的Python和Java错误,探讨了模型注意力在错误报告各部分的分布、成功与失败修复的注意力模式差异,以及这些模式与开发者认为重要的信息之间的比较。研究发现,成功的修复通常表现出对多个诊断组件的分散注意力,而失败则往往集中在版本信息等元数据上。模型注意力与开发者识别的关键部分和短语之间的强对齐与更高的修复成功率相关。此研究为LLM基础的自动程序修复失败提供了实证证据,并为未来更具可解释性和可靠性的APR系统设计提供了可行的见解。

🔬 方法详解

问题定义:本文旨在解决LLM在自动程序修复中注意力分配不当导致的修复失败问题。现有方法未能有效解释LLM如何处理错误报告中的信息。

核心思路:通过分析319个真实的Python和Java错误,研究模型注意力在不同错误报告部分的分布,揭示成功与失败修复的注意力模式差异。

技术框架:研究采用实证分析方法,首先收集错误报告数据,然后通过模型分析工具提取注意力模式,最后对比成功与失败修复的注意力分布。

关键创新:首次提供了LLM在程序修复中的注意力模式的实证证据,揭示了注意力分配对修复成功的影响,与现有方法的理论分析形成对比。

关键设计:研究中使用的模型注意力分析工具能够精确捕捉到不同部分的注意力分布,关注了多个诊断组件如错误描述、堆栈跟踪和测试用例等。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,成功修复的注意力分布较为分散,覆盖多个诊断组件,而失败修复则表现出对元数据的过度集中。模型注意力与开发者识别的关键部分之间的强对齐与更高的修复成功率相关,强调了注意力分配的重要性。

🎯 应用场景

该研究为自动程序修复系统的设计提供了重要的理论基础,能够帮助开发者理解LLM在处理错误报告时的行为。未来,这些发现可以指导更高效的修复工具开发,提升软件维护的自动化水平,减少开发者的工作负担。

📄 摘要(原文)

Large Language Model (LLM)-based Automated Program Repair systems are advancing rapidly, yet their performance remains inconsistent. Even when provided with the same contextual information, an LLM may generate a correct patch for one bug but fail on another closely related bug. Why this happens remains poorly understood, and it is unclear how LLMs prioritize the diverse information in bug reports and whether model attention affects repair success. In this paper, we present the first empirical study of attention patterns in LLM-based program repair, providing interpretable insights into how models process bug reports and where their attention is concentrated during repair. We analyze 319 real-world Python and Java bugs from SWE-bench Verified and Multi-SWE-bench to study (RQ1) how model attention is distributed across bug report sections, (RQ2) how attention patterns within each section differ between successful and unsuccessful repairs, and (RQ3) how these patterns compare to information developers consider important for bug fixing. We find that successful repairs are characterized by diffused attention across multiple diagnostic components such as bug descriptions, stacktraces, and test cases, while failures often exhibit over-localized attention toward metadata such as version information. We further observe that stronger alignment between model attention and developer-identified key sections and phrases is associated with higher repair success. Our results provide the first empirical evidence that attention misallocation is a key factor in LLM-based APR failures, and offer actionable insights for designing more interpretable and reliable future APR systems.