Skip to main content
QUICK REVIEW

[Paper Review] Large Language Models for Test-Free Fault Localization

Aidan Z. H. Yang, Ruben Martins|arXiv (Cornell University)|Oct 3, 2023
Software Engineering ResearchComputer Science4 citations
TL;DR

This paper proposes LLMAO, the first large language model (LLM)-based fault localization approach that identifies buggy code lines without test coverage or program analysis. By fine-tuning bidirectional adapter layers on top of code-optimized LLMs (e.g., CodeGen), LLMAO achieves state-of-the-art performance, improving Top-1 and Top-5 fault localization accuracy by up to 54.4% and 35.6% respectively over prior machine learning-based methods.

ABSTRACT

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.

Motivation & Objective

  • To address the limitations of existing fault localization techniques that rely on test coverage, program instrumentation, or extensive preprocessing.
  • To explore whether large language models (LLMs) can be adapted for test-free, line-level fault localization using few-shot learning.
  • To overcome the left-to-right autoregressive limitation of standard LLMs for discriminative tasks like fault localization.
  • To evaluate whether scaling up the underlying LLM improves fault localization performance.
  • To demonstrate that LLMs can detect security vulnerabilities at the line level without test cases or compilable code.

Proposed method

  • Fine-tune small, lightweight bidirectional adapter layers on top of pre-trained code LLMs (e.g., CodeGen with 350M, 6B, and 16B parameters) to enable bidirectional context understanding.
  • Use a small, manually curated dataset of buggy programs from Defects4J, BugsInPy, and Devign to fine-tune the adapter layers.
  • Train the model to predict the likelihood of each code line being buggy based on the full program context, leveraging the LLM’s deep semantic understanding.
  • Introduce adapter layers that allow the model to attend to both left and right context of a token, overcoming the inherent autoregressive bias of standard LLMs.
  • Use the model’s attention mechanisms to compute suspiciousness scores for each line, with higher scores indicating higher likelihood of being buggy.
  • Evaluate performance using standard fault localization metrics (e.g., Top-1, Top-5, AUC) across multiple benchmarks and model sizes.
Figure 2 . LLMAO ’s architecture, which takes as input a buggy program and produces a list of suspiciousness scores for each code line
Figure 2 . LLMAO ’s architecture, which takes as input a buggy program and produces a list of suspiciousness scores for each code line

Experimental results

Research questions

  • RQ1Can large language models be effectively fine-tuned for test-free, line-level fault localization without relying on test coverage or program analysis?
  • RQ2Does the performance of LLM-based fault localization scale with the size of the underlying model?
  • RQ3Can bidirectional adapter layers improve fault localization accuracy compared to standard left-to-right LLMs?
  • RQ4Can LLM-based fault localization detect security vulnerabilities at the line level without test cases?
  • RQ5How does LLMAO compare to state-of-the-art machine learning-based fault localization techniques in terms of precision and recall?

Key findings

  • LLMAO improves Top-1 fault localization accuracy by 2.3% to 54.4% over the strongest existing machine learning-based baselines.
  • LLMAO improves Top-5 fault localization accuracy by 14.4% to 35.6% over existing state-of-the-art methods.
  • Performance scales consistently with LLM size, with the 16B-parameter CodeGen-based model achieving the highest AUC across all datasets.
  • The use of bidirectional adapter layers is essential for achieving state-of-the-art results, as it enables the model to access context from both directions.
  • LLMAO is the first deep learning-based approach to localize security vulnerabilities at the line level without requiring test cases or compilable code.
  • The model achieves strong performance on three distinct benchmarks: 395 bugs from Defects4J, 493 from BugsInPy, and 5,260 from Devign.
Figure 4 . Attention masking procedure of LLMAO
Figure 4 . Attention masking procedure of LLMAO

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.