Skip to content
RAG Repo

CoIR (Code Retrieval Benchmark)

CoIR (Code Information Retrieval) brings together a range of programming tasks and languages into one benchmark aimed squarely at code retrieval. It spans several kinds of retrieval that a code assistant actually does: finding code from a natural-language description, finding code that is similar to other code, answering code questions, and retrieving the right snippet to complete a function. Standard text-retrieval benchmarks say little about any of this, because source code carries meaning in its structure, syntax, and identifiers that plain prose does not.

CoIR ships as a Python package with a small, consistent evaluation harness, and the underlying task datasets are on HuggingFace, so you point it at an embedding or retrieval model and get comparable scores back. If you have used BEIR or MTEB for text, the workflow will feel familiar: same idea, tuned for code.

The important thing to be clear about is what CoIR is for. It is a measuring tape, not a knowledge base. You do not put CoIR into your production index. You use it to choose the embedding model that will power a RAG system over your own codebases, whether that is code search, documentation lookup, or an in-editor assistant, before you commit to indexing millions of lines. Picking the wrong retriever is expensive to discover later, and this is how you avoid it.

A couple of caveats. Benchmark scores are a guide, not a guarantee, and your private code may differ from the public repositories these tasks are built from, so treat the ranking as a shortlist and confirm on a sample of your own data. There is also a risk that popular models have seen some of this public code in training, which can flatter their scores. On licensing CoIR is clean: it is released under the MIT licence, so commercial use is fine.

Reach for CoIR alongside general-purpose suites like MTEB and BEIR for prose, and LongEmbed when your documents run very long.

retrievalbenchmarkcodeevaluation

Related sources