Code-QA-Bench: Separating Code Reasoning from Documentation Memorization in Repository-Level QA
This paper introduces Code-QA-Bench, an automated framework that synthesizes repository-level QA benchmarks to rigorously separate genuine code reasoning from documentation memorization by employing an answer-first generation pipeline and a three-condition experimental design across 10 Python repositories.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are hiring a new employee to manage a massive, complex library. You want to know two things:
- Do they actually know how to find books by looking at the shelves and the Dewey Decimal System? (Real code reasoning)
- Or are they just reciting the library's brochure from memory because they read it years ago? (Documentation memorization)
Most previous tests for AI coding assistants were like asking the employee to write a new book from scratch. But in the real world, developers spend more time reading and understanding existing code than writing new code.
The paper introduces Code-QA-Bench, a new way to test AI models that separates "real understanding" from "rote memorization." Here is how it works, using simple analogies:
1. The Three "Exam Rooms"
To figure out what the AI is really doing, the researchers put the AI through three different test conditions, like sending a student into three different rooms:
- The "Closed-Book" Room: The AI is given a question but no access to the library. It has to rely entirely on what it memorized during its training. If it gets the answer right, it's just reciting facts it already knew.
- The "Code-Only" Room: The AI is given the library, but all the signs, labels, and brochures are ripped off. The shelves are bare, and the books have no titles on the spines. The AI must figure out how the library works just by looking at the structure of the shelves and the books themselves. This tests if it can actually reason through the code.
- The "Documented" Room: The AI gets the library with everything intact—all the signs, the user manuals, and the brochures. This tests if the AI can use helpful guides to get a better answer.
By comparing the scores from these three rooms, the researchers can calculate exactly how much the AI is "cheating" with memory versus how much it is actually "thinking" with the code.
2. The "Answer-First" Recipe
Usually, when people make tests, they write a question first and hope the answer exists. The researchers flipped this script. They built a pipeline that works like a detective:
- The Detective (AI Agent) investigates the code first. It explores the actual source files to find the "Gold Answer" (the truth).
- The Detective writes the question later. Once the truth is verified, the system generates a question that must be answered by that specific truth.
This ensures that every question is grounded in reality. It's like a teacher who first solves a math problem on the board, verifies the answer is correct, and then writes the test question based on that solution. This prevents the AI from being asked questions that have no real answer in the code.
3. The "Strip-Search" of Documentation
To make the "Code-Only" room fair, the researchers had to remove all the "cheat sheets." They wrote a tool that automatically strips a code repository of:
- Docstrings: The little notes inside the code explaining what a function does.
- Comments: The human notes written by developers.
- Documentation Files: The big README files and manuals.
They left behind the "skeleton" of the code: the variable names, the function names, and the logic flow. This forces the AI to understand the structure of the code, not just read the labels.
4. What They Found
They tested four of the smartest AI models available on 528 different tasks. Here is the "bottom line" in plain English:
- Code is King: The biggest jump in performance happened when the AI got access to the code (moving from the "Closed-Book" room to the "Code-Only" room). This proves that reading the actual code is the most important skill, far more than just having a good memory of the library's brochure.
- Docs Help, But Not Much: Having the documentation (the "Documented" room) did help, but only a little bit. It added about a 7% boost to the score. This suggests that for most questions, a smart AI can figure things out just by looking at the code structure; the documentation just adds a few extra details or "why" explanations.
- The "Memorization" Trap: The AI models were surprisingly good at the "Closed-Book" test. They knew a lot about these popular libraries just from their training data. However, when the questions required specific, deep details about the code structure, their memory wasn't enough—they needed to read the code.
5. Why This Matters
Before this, it was hard to tell if an AI was smart or just a parrot. If an AI gave a perfect answer, you didn't know if it understood the code or if it had just memorized the answer from a tutorial it read during training.
Code-QA-Bench acts like a lie detector test for AI. It proves that:
- True code understanding requires looking at the code, not just the documentation.
- Current AI models are getting very good at reading code structures (like a mechanic reading an engine without the manual).
- We can now build better tests that don't get fooled by an AI's memory.
In short, this paper built a new gym for AI models to prove they can actually do the work of reading code, rather than just reciting the instructions.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.