RAG against the machine disc

RAG against the machine

Python project · featured · RAG, BM25, LLM

Answers questions about the vLLM codebase: its own BM25 finds the right chunks among 11,582, then a 0.6B model answers from only those sources.

Open it in the console View the code on GitHub Resume (PDF) LinkedIn
The workbench: why lora.md ranked first, term by term
The workbench: why lora.md ranked first, term by term
A missed code question: the right folder, the wrong file
A missed code question: the right folder, the wrong file
The guide: a BM25 score worked out with the real numbers
The guide: a BM25 score worked out with the real numbers
The guide: request.py cut into its three chunks
The guide: request.py cut into its three chunks
From the 60-second film, made in code
From the 60-second film, made in code

The problem

Answer questions about vLLM, a codebase of more than a thousand files, with Qwen3-0.6B: a model far too small to know that code. The system has to find the two or three snippets that answer each question, and the grader only counts one when it is in the right file and overlaps the reference span (an IoU of at least 0.05).

What I built

The hard part

Recall on code questions. Without the file path in the index, recall@5 on code was 0.72: many questions name the module they ask about, and code rarely repeats its own file name. Indexing each chunk with its path in front of it, twice, took code to 0.85 and docs from 0.84 to 0.88. Chunk size was the other half. Tiny chunks such as import blocks were noise, but merging too much hurt as well, because a correct 2,000-character chunk around a 60-character reference overlaps it by an IoU of 0.03 and does not count. Merging small neighbours up to 800 characters was the best of what I measured; without merging, code was at 0.78.

What it looks like

$ make evaluate
Student data is valid: True
Evaluation Results
========================================
Recall@1: 0.680  Recall@3: 0.830  Recall@5: 0.880  Recall@10: 0.910

Built with

More projects