Views
No views yet
CodeRankEmbed is a 137M bi-encoder supporting 8192 context length for code retrieval. It significantly outperforms various open-source and proprietary code embedding models on various code retrieval tasks.CodeRankEmbed with our re-ranker CodeRankLLM for even higher quality code retrieval.| Name | Parameters | CSN (MRR) | CoIR (NDCG@10) |
|---|---|---|---|
| CodeRankEmbed | 137M | 77.9 | 60.1 |
| Arctic-Embed-M-Long | 137M | 53.4 | 43.0 |
| CodeSage-Small | 130M | 64.9 | 54.4 |
| CodeSage-Base | 356M | 68.7 | 57.5 |
| CodeSage-Large | 1.3B | 71.2 | 59.4 |
| Jina-Code-v2 | 161M | 67.2 | 58.4 |
| CodeT5+ | 110M | 74.2 | 45.9 |
| OpenAI-Ada-002 | 110M | 71.3 | 45.6 |
| Voyage-Code-002 | Unknown | 68.5 | 56.3 |
1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("nomic-ai/CodeRankEmbed", trust_remote_code=True)
4queries = ['Represent this query for searching relevant code: Calculate the n-th factorial']
5codes = ['def fact(n):\n if n < 0:\n raise ValueError\n return 1 if n == 0 else n * fact(n - 1)']
6query_embeddings = model.encode(queries)
7print(query_embeddings)
8code_embeddings = model.encode(codes)
9print(code_embeddings)CodeRankEmbed, with weights shared between the text and code encoder. The retriever is contrastively fine-tuned with InfoNCE loss on a 21 million example high-quality dataset we curated called CoRNStack. Our encoder is initialized with Arctic-Embed-M-Long, a 137M parameter text encoder supporting an extended context length of 8,192 tokens.1@misc{suresh2025cornstackhighqualitycontrastivedata,
2 title={CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking},
3 author={Tarun Suresh and Revanth Gangi Reddy and Yifei Xu and Zach Nussbaum and Andriy Mulyar and Brandon Duderstadt and Heng Ji},
4 year={2025},
5 eprint={2412.01007},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2412.01007},
9}