CoIR: A Comprehensive Benchmark for Code Information Retrieval Models

Xiangyang Li, Kuicai Dong, Yi Quan Lee, Wei Xia, Hao Zhang, Xinyi Dai, Yasheng Wang, Ruiming Tang

Introduction

In the rapidly evolving landscape of software engineering, Information Retrieval (IR) plays a critical role in helping developers navigate vast codebases. However, while natural language IR has matured significantly, code retrieval remains a challenging frontier. Source code is not merely text; it is semi-structured, inherently logical, and governed by strict syntactic rules.

Existing benchmarks, such as CodeSearchNet and CosQA, have historically focused on narrow "Text-to-Code" tasks—searching for code snippets using natural language queries. This limited scope fails to capture the complexity of real-world developer needs and has led to a phenomenon where modern models "memorize" specific datasets, showing high leaderboard scores that do not generalize to broader coding tasks. To address these gaps, we introduce CoIR (Code Information Retrieval), a comprehensive and "overfit-resistant" evaluation suite designed for the next generation of code-aware embedding models.

The CoIR Framework

CoIR is designed as a standardized evaluation framework that moves beyond simple keyword matching. The benchmark categorizes retrieval into four main pillars to reflect the diversity of developer workflows:

  1. Text-to-Code: Traditional natural language search for code.
  2. Code-to-Text: Retrieving documentation or explanations for a specific snippet.
  3. Code-to-Code: Finding related code segments, such as completing a partial snippet or finding equivalent logic in a different programming language.
  4. Hybrid Code Retrieval: Handling queries and results that mix both natural language and code.
The Code-to-Code pillar includes tasks like Code Context Retrieval and Similar Code Retrieval across different languages.
Hybrid Code Retrieval evaluates a model's ability to handle single-turn and multi-turn Q&A involving both text and code.

To ensure high quality, the authors performed manual inspection and rigorous cleaning of the data, removing ambiguous or low-quality examples found in "silver-standard" datasets. CoIR is released as a Python package compatible with the MTEB (Massive Text Embedding Benchmark) and BEIR schemas, allowing for seamless integration into existing research pipelines.

Dataset Composition

CoIR consists of 10 datasets covering 7 distinct domains (including GitHub, StackOverflow, and Competitive Programming) and 14 programming languages. Notable additions include:

  • CodeSearchNet-CCR: A new task for "Code Context Retrieval," where models must identify the code segment that logically completes an initial snippet.
  • StackOverflowQA: A curated dataset from Stack Overflow dumps designed to mirror real-world developer queries.
  • Refined Existing Sets: The benchmark also includes cleaned versions of APPS (contest code), CosQA (web queries), Synthetic Text2SQL, and CodeTransOcean (cross-language retrieval).

Key Insights and Results

The Overfitting Challenge

Evaluation on CoIR revealed a significant performance gap compared to legacy benchmarks. Models like OpenAI-Ada-002 and Voyage-Code-002 showed much higher scores on older datasets than on the full CoIR suite, suggesting they have become over-optimized for specific distributions. CoIR provides a more rigorous test of a model's true semantic understanding.

Model Performance

No single model dominated every task, though specialized models showed clear advantages. Voyage-Code-002 led the evaluation with a mean NDCG@10 of 56.26, followed by the general-purpose LLM-based retriever E5-Mistral at 55.18. Interestingly, while Voyage-Code-002 excelled in code-specific tasks, E5-Mistral performed better on hybrid and contest-based tasks. Traditional keyword-based search (BM25) performed poorly (mean score of 29.79), confirming that code retrieval requires deep logical understanding rather than simple token matching.

Efficiency and Context

There is a notable accuracy-latency trade-off. The top-performing E5-Mistral (7B parameters) is approximately 250 times slower at generating embeddings than smaller models like E5-Base, presenting a challenge for real-time IDE integration. Additionally, models optimized for long contexts (up to 4,096 tokens) showed significant performance boosts on complex tasks like StackOverflow QA.

Conclusion and Future Work

CoIR establishes a new standard for evaluating code retrieval models by emphasizing task diversity and data quality. While it represents a major step forward, future iterations aim to address current limitations, such as the English-centric nature of natural language queries and the lack of metadata (e.g., library versions) in the retrieval process. By providing a standardized, multi-faceted benchmark, CoIR paves the way for more robust and capable code-aware AI systems.

Summary updated

BibTeX
@inproceedings{li2025coir,
  author = {Xiangyang Li and Kuicai Dong and Yi Quan Lee and Wei Xia and Hao Zhang and Xinyi Dai and Yasheng Wang and Ruiming Tang},
  title = {{CoIR: A Comprehensive Benchmark for Code Information Retrieval Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.acl-long.1072},
}
Figure