LLM-BL: Large Language Models are Zero-Shot Rankers for Bug Localization
Authors:
- 27 April 2025
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 548-559
Abstract
Bug localization, which aims to localize software faults specific to a bug report, is valuable for improving software developers' efficiency. This task is often formulated as an information retrieval problem, where potentially buggy files are retrieved and ranked according to their textual similarity to a target bug report. To address this task, many methods have been proposed, primarily focusing on resolving the semantic gap between natural language in bug reports and programming language in source files. Recently, Large Language Models (LLMs) have demonstrated strong capabilities in seamlessly understanding both natural language and programming language, potentially addressing the semantic gap issue through natural conversation. However, the limited context length of prompt and capability of long-context comprehension in existing LLMs make it impossible to directly load the entire codebase (e.g., thousands of code files) into LLMs' prompts to retrieve buggy code files. In this paper, we explore how to leverage existing LLMs for projectlevel bug localization without requiring additional fine-tuning and propose an LLM-based Bug Localization framework, LLM-BL. Our core idea is to enable LLMs to perform bug localization tasks using listwise ranking instructions and to avoid exceeding the context length limit by compressing the codebase through file filtering and content reduction. Specifically, LLM-BL consists of four modules: report expansion, candidate retrieval, content reduction, and LLM-based bug localization. Among them, the first three modules are used to retrieve potential buggy code files and extract bug-related information from the code files, respectively, while the last module enables the LLM to perform bug localization through listwise file ranking. We select three widely used LLMs (i.e., ChatGPT, Llama 3, CodeLlama) as the base LLMs in our framework and conduct extensive experiments on six public projects with two report types (i.e., Java and Python). Experimental results demonstrate that the two LLMs, ChatGPT and Llama 3, can more effectively understand task intentions and more accurately localize buggy files than CodeLlama. Compared to existing methods, LLM-BL achieves better localization performance without requiring any fine-tuning, in a plug-and-play manner. These results demonstrate that both ChatGPT and Llama 3 are effective zero-shot rankers for bug localization.Keywords
Funding Information
- National Natural Science Foundation of China (62441225,61972192,62172208,61906085)
This publication has 48 references indexed in Scilit:
- Large Language Models are Zero-Shot Rankers for Recommender Systems2024
- Efficient transformer with code token learner for code clone detectionJournal of Systems and Software, 2022
- TroBo: A Novel Deep Transfer Model for Enhancing Cross-Project Bug Localization2021
- Using bug descriptions to reformulate queries during text-retrieval-based bug localizationEmpirical Software Engineering, 2019
- Improving bug localization with word embedding and enhanced convolutional neural networksInformation and Software Technology, 2019
- Comparing learning to rank techniques in hybrid bug localizationApplied Soft Computing, 2018
- Locating bugs without looking backAutomated Software Engineering, 2017
- Improved bug localization based on code change histories and bug reportsInformation and Software Technology, 2017
- AmaLgam+: Composing Rich Information Sources for Accurate Bug LocalizationJournal of Software: Evolution and Process, 2016
- Bug localization using latent Dirichlet allocationInformation and Software Technology, 2010