Repository Structure-Aware Training Makes SLMs Better Issue Resolver

Zexiong Ma, Shengnan An, Zeqi Lin, Yanzhen Zou, Bing XiearXiv 2024 · DOI

Introduction

Resolving software issues at the repository level remains a significant challenge for artificial intelligence. Unlike isolated code completion, true issue resolution requires an agent to interpret ambiguous bug reports, navigate complex directory structures containing hundreds of files, and pinpoint specific lines for modification. While massive Large Language Models (LLMs) like GPT-4 currently dominate this domain, they are often prohibitively expensive, slow, and present privacy risks for proprietary codebases.

Small Language Models (SLMs, <13B parameters) offer a faster, local alternative but typically struggle with repository-level tasks due to a lack of inherent understanding of project-wide architecture. This paper introduces ReSAT (Repository Structure-Aware Training), a method designed to bridge this gap by teaching SLMs the "map" of a codebase through structured training.

Comparison of Retriever-based (RAG) vs. LLM-based Localization paradigms.

The ReSAT Framework

The core philosophy of ReSAT is that SLMs do not necessarily lack reasoning power, but rather the structural context required to navigate large repositories. The authors propose a two-pillar training pipeline that transforms raw open-source data into specialized lessons for the model.

1. Multi-Level Localization Training

Instead of training the model to jump directly to a fix, ReSAT teaches it to find the bug progressively across three levels of granularity:

  • File-level: Identifying the relevant files within the repository structure.
  • Function-level: Pinpointing specific classes or functions within those files using a "modified file skeleton."
  • Line-level: Locating the exact lines of code requiring modification within the function content.

2. Code Edit Training

To improve the quality of the generated fixes, the model is trained using a Search/Replace format. This forces the model to explicitly identify the original "broken" code snippet before providing the replacement, a method found to be more effective than standard diff generation for SLMs.

The ReSAT pipeline, illustrating data scraping from GitHub and the subsequent construction of localization and code edit training sets.

Experimental Setup and Results

The researchers fine-tuned CodeQwen1.5-7B and Deepseek-Coder-6.7B on a dataset derived from 229 active Python repositories, encompassing over 44,000 Pull Requests. Evaluation was conducted on the SWE-Bench-verified benchmark (500 real-world GitHub issues) and RepoQA (cross-language repository understanding).

The results demonstrated a dramatic performance leap:

  • CodeQwen1.5-7B improved its success rate from 0.8% to 7.2%.
  • Deepseek-Coder-6.7B rose from 1.8% to 6.6%.
  • In a RAG-based configuration, the ReSAT-enhanced Deepseek model achieved a 2.6% success rate, nearly matching the original GPT-4's performance of 2.8%.

Key Insights

  • Localization as the Primary Bottleneck: Ablation studies confirmed that localization training had a significantly higher impact on success than code-edit training alone. If a model cannot accurately locate the bug, its ability to write code is irrelevant.
  • Cross-Language Transferability: Despite being trained primarily on Python, the models showed improved performance on C++, Java, and Rust in the RepoQA benchmark, suggesting that "repository-level thinking" is a transferable skill across programming languages.
  • Specialization vs. Scale: ReSAT-trained SLMs successfully resolved several complex issues that even larger models like Claude-3-Opus failed to fix, highlighting the power of domain-specific structural training.

Conclusion and Future Work

ReSAT demonstrates that with the right structural training, 7B-parameter models can become viable tools for real-world software engineering. While a gap still exists between SLMs and state-of-the-art models like GPT-4o (which scores over 33%), ReSAT provides a roadmap for narrowing this divide. Future research will focus on incorporating "Chain-of-Thought" reasoning data and scaling the training set to thousands of repositories across more diverse languages.

Summary updated

BibTeX
@misc{ma2024repository,
  author = {Zexiong Ma and Shengnan An and Zeqi Lin and Yanzhen Zou and Bing Xie},
  title = {{Repository Structure-Aware Training Makes SLMs Better Issue Resolver}},
  year = {2024},
  eprint = {2412.19031},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.19031},
}
Figure