← Latest papers
🤖 AI

CoSQA+: Pioneering the Multi-Choice Code Search Benchmark with Test-Driven Agents

This paper introduces CoSQA+, a high-quality multi-choice code search benchmark featuring 412,080 agent-annotated pairs verified by a novel test-driven agent system, which demonstrates superior performance over existing datasets and significantly improves code search models.

Original authors: Jing Gong, Yanghui Wu, Linxi Liang, Yanlin Wang, Jiachi Chen, Mingwei Liu, Zibin Zheng

Published 2026-02-05
📖 5 min read🧠 Deep dive

Original authors: Jing Gong, Yanghui Wu, Linxi Liang, Yanlin Wang, Jiachi Chen, Mingwei Liu, Zibin Zheng

Original paper dedicated to the public domain under CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.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 looking for a specific recipe in a massive, chaotic cookbook. You type a vague request like "make something sweet with flour," and the book spits out a single page. But what if that one page isn't the only right answer? What if there are five different ways to make a sweet flour dish, and you want to see all of them to pick the best one?

This is the problem the authors of this paper, CoSQA+, are trying to solve. They are building a better "test" for computers that search for code (computer instructions) using natural language (human words).

Here is a breakdown of their work using simple analogies:

1. The Problem: The "One Right Answer" Trap

Currently, most computer systems that search for code are trained like a multiple-choice test where there is only one correct answer per question.

  • The Reality: In the real world, programmers often ask vague questions (e.g., "how do I remove bad characters?"). There isn't just one way to do this; there might be ten different valid code snippets that solve the problem in slightly different ways.
  • The Flaw: Existing datasets force the computer to pick just one "winner," ignoring the other valid solutions. It's like grading a student's essay by only accepting one specific sentence structure, even if the student wrote a perfectly good paragraph using a different structure.

2. The Solution: CoSQA+ (The "Multi-Choice" Library)

The authors created a new dataset called CoSQA+. Instead of a "one question, one answer" test, they built a library where one question is paired with many possible correct answers.

  • The Scale: They gathered over 412,000 pairs of questions and code snippets.
  • The Goal: To teach computers that when a human asks a question, there might be a whole menu of correct code options, not just a single dish.

3. The Challenge: How Do You Grade 400,000 Answers?

If you have 400,000 questions, you can't hire 400,000 human experts to read every single code snippet and check if it works. That would take forever and cost a fortune.

  • The Old Way: Humans read the code and guess if it works based on how it looks. This is like a teacher grading a math test just by looking at the numbers without actually doing the math. They might miss a subtle error.
  • The New Way (The "Test-Driven Agent"): The authors built a team of AI robots (agents) that don't just read the code; they run it.
    • The Chef Analogy: Imagine you have a recipe (the code). Instead of just reading the ingredients list, the robot actually goes into the kitchen, cooks the dish, and tastes it.
    • The Process:
      1. The Screener: A robot quickly checks if the code obviously works or obviously fails.
      2. The Generator: If it's unclear, another robot writes a "tasting test" (a test program) to see if the code does what the human asked.
      3. The Executor: A robot runs the code in a safe, isolated kitchen (a Docker container).
      4. The Bug Fixer: If the kitchen catches fire (an error), this robot tries to fix the recipe or the ingredients so it can run again.
      5. The Arbiter: A final robot looks at the results of the cooking and decides: "Did this actually solve the problem?"

4. The Results: Robots vs. Humans

The authors tested their robot team against human experts and other AI models.

  • The Score: The robot team got 93.9% accuracy.
  • The Comparison: Human experts who just read the code (without running tests) only got about 89% accuracy. Other AI models got even lower scores.
  • Why? Because the robots actually tested the code. They didn't just guess; they proved the code worked by running it. It's the difference between guessing a car works because it looks shiny, and actually driving it to see if the engine starts.

5. Why This Matters

  • Better Training: When they used this new "Multi-Choice" dataset to train computer models, the models got much better at finding code. They learned that there are many ways to solve a problem.
  • Cross-Language: The robot team didn't just work for Python (a popular coding language); they also worked well for Java, Go, and PHP. This suggests their "run-and-test" method is a universal way to check code, regardless of the language.

Summary

The paper introduces CoSQA+, a massive new dataset that treats code search like a real-world scenario where one question has many right answers. To build this dataset without hiring an army of humans, they created a team of AI robots that write their own tests, run the code, and grade the results. These robots proved to be more accurate than human experts who only read the code, creating a higher-quality "textbook" for training future code-searching computers.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →