Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Smarter Repository Question Answering: When to Use Retrieval, Agents, or Both

MSc Thesis — Computer Science (Data Science Specialization), Leiden University

Comparing semantic retrieval, coding agents, and graph-guided coding agents for automated question answering over software repositories — and identifying when each approach is actually worth its cost.

Overview

Understanding an unfamiliar codebase — onboarding, tracing a change across modules, diagnosing a failure — is one of the most time-consuming parts of software engineering. This thesis investigates whether automated systems can answer repository-level questions accurately and efficiently, comparing three paradigms:

  1. Semantic retrieval — embedding-based chunk retrieval, single retrieve-and-generate pass (retrieval/)
  2. Coding agent — dynamic repository exploration via tool-based interactions (file navigation, search) (coding_agent/)
  3. Graph-guided coding agent — exploration guided by a structural code graph (dependencies, relationships between components) (graph_agent/)

All three are evaluated on a 720-question repository QA benchmark, with correctness scored by a human-validated LLM-as-a-judge framework (0–3 scale) against reference answers, and efficiency measured in token usage, exploration steps, and latency.

Key Results

Approach Judge score (0–3) Tokens / question Relative latency
Semantic retrieval 1.067 ≈4,800 1× (fastest)
Coding agent 0.990 ≈14,600 ~2×
Graph-guided agent 1.047 ≈14,700 ~2×

(7B backbone, locally deployable)

  • At small-model scale, retrieval dominates on every axis — higher accuracy, ~⅓ the tokens, half the latency of either agentic approach.
  • Graph guidance recovers most of the agent's quality deficit at no additional token cost, and produces fully correct answers at 2.5× retrieval's rate (though it also fails more often).
  • Retrieval's advantage is concentrated on single-file lookup questions; all three systems converge on cross-file questions.
  • Increasing the agent's exploration budget yields no quality gains — only proportionally more failures.
  • Swapping in a 32B backbone raises the graph-guided agent's score to 1.335 with zero failures, inverting the ranking — at a 15.6× latency cost.

Takeaway: backbone capacity, not architecture, is the first-order design variable for repository QA. Local/small-model deployments should default to retrieval; agentic exploration only pays off with more capable backbones, and graph-structural seeding is a near-free enhancement worth adopting by default. This motivates an adaptive routing design — retrieval by default, escalate to a larger-backbone coding agent only when retrieval confidence is low or a complete answer is required.

Repository Structure

.
├── retrieval/       # Semantic retrieval baseline (embedding-based chunk retrieval)
├── coding_agent/     # Tool-based exploration agent (file navigation, search)
├── graph_agent/      # Graph-guided coding agent (structural code graph exploration)
├── benchmark/         # Repository-level QA benchmark and evaluation harness
├── experiments/       # Experiment configs and run scripts
└── plots.ipynb        # Result analysis and figures

Method Summary

  • Benchmark: 720 repository-level questions, evaluated with a human-validated LLM-as-a-judge framework comparing generated answers to reference solutions.
  • Models: locally deployable 7B backbone (primary comparison); 32B backbone used to test the effect of model capacity.
  • Metrics: judge score (0–3 correctness scale), token usage, number of exploration steps, execution latency/cost.

Author

Manuel David Pérez Belizón — mdpbelizon@gmail.com MSc Computer Science, Data Science Specialization — Leiden University

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages