Towards a Generalist Code Embedding Model Based on Massive Data Synthesis

Abstract

Code embedding models attract increasing attention due to the widespread popularity of retrieval-augmented generation (RAG) in software development. These models are expected to capture the rich semantic relationships inherent to code, which differ significantly from those found in text. However, existing models remain severely limited due to the scarcity of high-quality training data. In this work, we introduce \textbf{CodeR} (\underline{Code} \underline{R}etrieval), a state-of-the-art embedding model for general-purpose code retrieval. The superior performance of CodeR is built upon \textbf{CodeR-Pile}, a large-scale synthetic dataset constructed under the DRU (Diversity, Reliability, Usability) principle via a novel data synthesis pipeline. To optimize training effectiveness, we propose \textbf{Annealing}, a curriculum learning strategy that enables effective knowledge transfer across heterogeneous sources of data. We evaluate CodeR based on 16 diverse code retrieval tasks, where it significantly outperforms existing baselines and exhibits strong out-of-domain generalization performance. We have publicly released our code and the well-trained model to facilitate further research in this critical area\footnote{\url{https://github.com/FlagOpen/FlagEmbedding/tree/master/research/BGE_Coder}}.

Cite

Text

Li et al. "Towards a Generalist Code Embedding Model Based on Massive Data Synthesis." Advances in Neural Information Processing Systems, 2025.

Markdown

[Li et al. "Towards a Generalist Code Embedding Model Based on Massive Data Synthesis." Advances in Neural Information Processing Systems, 2025.](https://mlanthology.org/neurips/2025/li2025neurips-generalist/)

BibTeX

@inproceedings{li2025neurips-generalist,
  title     = {{Towards a Generalist Code Embedding Model Based on Massive Data Synthesis}},
  author    = {Li, Chaofan and Chen, Jianlyu and Shao, Yingxia and Lian, Defu and Liu, Zheng},
  booktitle = {Advances in Neural Information Processing Systems},
  year      = {2025},
  url       = {https://mlanthology.org/neurips/2025/li2025neurips-generalist/}
}