Hierarchical Reward Modeling for Fault Localization in Large Code Repositories (2025)

Abstract: Large Language Models (LLMs) exhibit significant potential in complex software engineering tasks, however, their fault localization capabilities within repository are constrained by inherent limitations in max context length. Although Test-Time Scaling (TTS) can generate multiple candidate solutions, traditional selection strategies often fail to identify the optimal one. To solve this problem, we introduces Hi erarchical Lo calization R eward M odel (HiLoRM), which specifically designed to evaluate and select the most accurate fault localization candidates (at file, function, and line levels) from the multiple sampled outputs of LLMs, thereby enhancing localization accuracy. Furthermore, we constructed the HiFL-44k dataset, comprising approximately 44,000 fault localization instances, to train HiLoRM. Experimental results demonstrate that on the SWE-Bench-Lite dataset, HiLoRM improves the final line-level localization recall by 12% compared to a baseline model that does not use a reward model. Concurrently, HiLoRM exhibits a strong capability to evaluate predictions from larger LLMs (e.g., 32B parameters) and demonstrates transferability and generalization potential when applied to other fault localization methods. This work provides an effective methodology and an accessible model to significantly improve the accuracy and reliability of LLMs for repository-level fault localization. Our codes and datasets are available at https://github.com/SZU-ZJW/HiFL-Method.

## introduction large language models (llms) have demonstrated potential in tackling complex software engineering tasks within intricate code repositories, such as resolving github issues. however, their performance on benchmarks like swe-bench remains limited @xcite , 2024c), with even state-of-the-art open-source llms often struggling to exceed a 50% resolution rate. in-depth analysis reveals that fault localization-precisely identifying code locations needing modification-is a critical bottleneck hindering llm performance @xcite . the inherent input context length limitations of current llms prevent processing entire large repositories, making precise identification of relevant code segments challenging. effective fault localization is thus a fundamental prerequisite for successful code repair @xcite . to address llm performance limitations in code repair, researchers have explored strategies like more fine-grained agent methods @xcite , retrieval-augmented generation (rag) for enhanced repository understanding @xcite , and fine-tuning llms for specific domains @xcite . test time scaling (tts), a technique improving model output quality by allocating additional computational resources during testing without model retraining, has also shown promise, with improved performance in models like openai's o1 and deepseek-r1 @xcite . tts typically generates multiple candidate solutions, with one subsequently selected. however, conventional tts selection strategies (e.g., "best of n", majority voting) have limitations in discerning the optimal solution, as shown in figure 1 . empirical evidence suggests these methods often prioritize model confidence over the actual quality of the fix. therefore, the crucial challenge is accurately identifying the most correct repair from tts-generated candidates. to address challenges in fault localization for real-world software development, we propose leveraging a specifically trained reward model to evaluate multiple fault localization candidates from test time scaling. a scoring mechanism based on a reward model can provide a more reliable basis for selection by quantifying each candidate's quality. our designed reward model, hierarchical localization reward model (hilorm), assesses fault localization accuracy, enabling detailed comparative analysis at file, function, and line levels to identify the most precise answer from multiple candidates. this selection mechanism allows more reliable determination of the optimal fault localization result. for training our reward model, we constructed hifl-44k, a novel dataset with fine-grained bug localization data (file, function, line levels). we performed supervised fine-tuning (sft) on a base model, then trained our reward model using reinforcement learning, specifically the group relative policy optimization (grpo) method. during training, the model directly outputted the index of the most likely correct answer from multiple candidates. experimental results show hilorm, trained on hifl-44k, significantly improves file-level bug localization performance on swe-bench-lite by 9.33% compared to scenarios without a reward model. our primary contributions are: ## hifl-44k dataset this study constructed a large-scale fault localization dataset comprising 44k instances, named hifl-44k, the statistical results of the data set are shown in ## conclusion to address the context limitations and candidate selection challenges faced by llms in software repository-level fault localization, this paper proposes a hierarchical localization reward model, hilorm. it was trained on the hifl-44k dataset that we built, can evaluate and select llm-generated candidates at the file, function, and line levels. experiments demonstrate that integrating hilorm significantly improves the fault localization accuracy of llms on swe-bench-lite (especially at the file level) and effectively selects the best candidates from multiple samples. hilorm also exhibits good generalization to larger-scale base models and different methods such as cosil. its performance improvement is primarily attributed to the reward mechanism, rather than just the base model. hilorm and its accompanying hifl-44k dataset offer an effective solution for precise fault localization by llms by optimizing candidate selection. this significantly enhances localization accuracy and reliability, and holds important practical significance.