[论文解读] Large Language Models for Test-Free Fault Localization
该论文提出 LLMAO,这是首个基于大语言模型(LLM)的故障定位方法,可在无需测试覆盖率或程序分析的情况下识别出错误代码行。通过在代码优化的 LLM(如 CodeGen)之上微调双向适配器层,LLMAO 实现了最先进性能,相较于先前基于机器学习的方法,其 Top-1 和 Top-5 故障定位准确率分别提升了最高 54.4% 和 35.6%。
Fault Localization (FL) aims to automatically localize buggy lines of code, a key first step in many manual and automatic debugging tasks. Previous FL techniques assume the provision of input tests, and often require extensive program analysis, program instrumentation, or data preprocessing. Prior work on deep learning for APR struggles to learn from small datasets and produces limited results on real-world programs. Inspired by the ability of large language models (LLMs) of code to adapt to new tasks based on very few examples, we investigate the applicability of LLMs to line level fault localization. Specifically, we propose to overcome the left-to-right nature of LLMs by fine-tuning a small set of bidirectional adapter layers on top of the representations learned by LLMs to produce LLMAO, the first language model based fault localization approach that locates buggy lines of code without any test coverage information. We fine-tune LLMs with 350 million, 6 billion, and 16 billion parameters on small, manually curated corpora of buggy programs such as the Defects4J corpus. We observe that our technique achieves substantially more confidence in fault localization when built on the larger models, with bug localization performance scaling consistently with the LLM size. Our empirical evaluation shows that LLMAO improves the Top-1 results over the state-of-the-art machine learning fault localization (MLFL) baselines by 2.3%-54.4%, and Top-5 results by 14.4%-35.6%. LLMAO is also the first FL technique trained using a language model architecture that can detect security vulnerabilities down to the code line level.
研究动机与目标
- 解决现有故障定位技术依赖测试覆盖率、程序插桩或大量预处理的局限性。
- 探究大语言模型(LLM)是否可通过少样本学习实现无需测试用例的、细粒度的故障定位。
- 克服标准 LLM 固有的从左到右自回归机制在判别性任务(如故障定位)中的限制。
- 评估扩大底层 LLM 规模是否能提升故障定位性能。
- 证明 LLM 可在无需测试用例或可编译代码的情况下,实现细粒度的漏洞检测。
提出的方法
- 在预训练的代码 LLM(如参数量为 350M、6B 和 16B 的 CodeGen)之上微调小型轻量级双向适配器层,以实现双向上下文理解。
- 使用来自 Defects4J、BugsInPy 和 Devign 的少量手动整理的错误程序数据集对适配器层进行微调。
- 通过利用 LLM 的深层语义理解能力,基于完整程序上下文训练模型以预测每行代码为错误代码的可能性。
- 引入适配器层,使模型能够同时关注标记的左右上下文,从而克服标准 LLM 固有的自回归偏差。
- 利用模型的注意力机制为每行代码计算可疑度分数,分数越高表示越可能是错误代码。
- 在多个基准和模型规模上,使用标准故障定位指标(如 Top-1、Top-5、AUC)评估性能。

实验结果
研究问题
- RQ1大语言模型是否可在无需测试覆盖率或程序分析的情况下,通过有效微调实现无需测试用例的、细粒度的故障定位?
- RQ2LLM 基于的故障定位性能是否随底层模型规模的增大而提升?
- RQ3与标准从左到右的 LLM 相比,双向适配器层是否能提升故障定位准确率?
- RQ4LLM 基于的故障定位是否可在无需测试用例的情况下检测出细粒度的代码安全漏洞?
- RQ5LLMAO 在精确率和召回率方面与最先进基于机器学习的故障定位技术相比如何?
主要发现
- LLMAO 相较于最强的现有基于机器学习的基线模型,Top-1 故障定位准确率提升 2.3% 至 54.4%。
- LLMAO 相较于现有最先进方法,Top-5 故障定位准确率提升 14.4% 至 35.6%。
- 性能随 LLM 规模增大而稳定提升,基于 16B 参数 CodeGen 的模型在所有数据集上均达到最高 AUC。
- 使用双向适配器层对实现最先进结果至关重要,因为它使模型能够同时获取双向上下文信息。
- LLMAO 是首个无需测试用例或可编译代码即可实现细粒度安全漏洞定位的深度学习方法。
- 该模型在三个不同基准上均表现优异:Defects4J 的 395 个错误,BugsInPy 的 493 个错误,以及 Devign 的 5,260 个错误。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。