Finding the exact file or function responsible for a bug—a task known as software issue localization—is often the most grueling part of a developer's day. While we’ve seen a surge in "agentic" AI systems that can navigate codebases to find and fix bugs, these agents are often slow, brittle, and expensive.
A new paper from researchers at UIUC, Salesforce, and KAIST introduces SWERank, a framework that proves we don't always need a complex, multi-turn agent to find a bug. By treating localization as a specialized retrieval problem and training on a massive new dataset, SWERank achieves state-of-the-art results at a fraction of the cost of current leaders like Claude-3.5.
TL;DR
SWERank is a high-performance retrieve-and-rerank framework designed specifically for pinpointing buggy code from natural language reports. By leveraging a new 67k-sample dataset called SWELoc, it outperforms expensive agentic systems on benchmarks like SWE-Bench-Lite while being up to 60x more cost-effective.
What Problem Does This Paper Address?
Automated software engineering has two main camps: Agentic systems (which use LLMs to "act" like a dev, running commands like grep or read_file) and Retrieval models (which search for code like a search engine).
The problem? Agents are expensive (costing ~$0.66+ per issue) and slow because they require multiple rounds of reasoning. Traditional retrieval models, on the other hand, are usually trained on short, functional queries (e.g., "how to sort a list"). They struggle with real-world bug reports, which are verbose (averaging over 380 tokens), messy, and describe failures rather than desired features. SWERank aims to bridge this gap by creating a retrieval system specifically "tuned" for the unique language of software issues.
Methods
The authors propose a two-stage retrieve-and-rerank pipeline:
- SWERankEmbed (The Retriever): A bi-encoder model that maps both the issue description and code snippets into a shared vector space. It uses a contrastive learning objective (InfoNCE) to ensure that a bug report sits close to the specific function that eventually fixed it.
- SWERankLLM (The Reranker): A larger, instruction-tuned LLM that takes the top candidates from the retriever and performs a "listwise" reranking.
- The Innovation: Since most datasets only tell us which function was "positive" (fixed) and not the relative quality of the "negatives," the authors modified the training objective. Instead of asking the model to rank the whole list, they train it to specifically identify and prioritize the single known positive identifier from a set of candidates.
Datasets
The backbone of this work is SWELoc, a new large-scale dataset curated to train these models effectively.
- Source: Curated from 3,387 public GitHub repositories.
- Scale: 67,341 initial pairs of issue descriptions and their corresponding code modifications.
- Quality Control: As illustrated in the pipeline above, the authors used PR scraping, negative mining, and "Top-K consistency filtering" to remove noisy data where the bug report and the code fix didn't semantically align. This ensures the model learns from high-quality examples.
For evaluation, the team used SWE-Bench-Lite and LocBench, two standard benchmarks for real-world software engineering tasks.
Key Insights and Ideas
- Issue Reports $\neq$ Code Search: The authors highlight a "fundamental difference in query nature." Bug reports describe erroneous behavior, not functionality. Models trained on standard "CodeSearchNet" style data are fundamentally misaligned for localization.
- Quality Over Quantity: One of the most striking findings is that simply adding more data doesn't help if it's noisy. Applying consistency filtering significantly boosted performance, even if it reduced the total number of training samples.
- Reranking Bridges the Semantic Gap: The reranker (SWERankLLM) showed massive gains in "low-similarity" buckets—cases where the bug report and the code don't share many keywords. This suggests the LLM is doing deep semantic reasoning that simple vector search misses.
Key Results
SWERank proves that specialized retrieval can outcompete generalized agents in both accuracy and efficiency.
- State-of-the-Art Performance: SWERank (Large) achieved 83.21% Acc@1 for file-level localization on SWE-Bench-Lite, outperforming top-tier agents like LocAgent (using Claude-3.5).
- Efficiency: As shown in the chart above, while a Claude-3.5 agent might cost $0.66 per issue, SWERankLLM (32B) costs just $0.015—a roughly 44x to 60x reduction in cost with better accuracy.
- Downstream Impact: When plugged into a repair tool (SWE-Fixer), SWERank's superior localization led to a higher "Pass@1" rate for actually fixing the bugs (24.5% vs. 21.0% for the baseline).
- Generalizability: The authors showed that finetuning other popular models (like Arctic-Embed) on the SWELoc dataset consistently improved their localization abilities by 8-17%.
Limitations and Future Work
- The "Complex Issue" Wall: Performance drops sharply as the number of modified functions increases. For issues requiring changes to more than 5 functions, all models (including SWERank) still struggle, often hitting only single-digit accuracy.
- Beyond Functions: While the model is great at finding functions and files, it doesn't yet pinpoint the exact line of code, which is the "holy grail" of fault localization.
- Cross-File Dependencies: The current bi-encoder approach looks at functions in isolation. Future work could involve incorporating repository-level context or dependency graphs directly into the ranking process to better handle multi-file bugs.
Summary updated