Abstract
With the growing popularity of RAG, the capabilities of embedding models are gaining increasing attention. Embedding models are primarily trained through contrastive loss learning, with negative examples being a key component. Previous work has proposed various hard negative mining strategies, but these strategies are typically employed as preprocessing steps. In this paper, we propose the conan-embedding model, which maximizes the utilization of more and higher-quality negative examples. Specifically, since the model's ability to handle preprocessed negative examples evolves during training, we propose dynamic hard negative mining method to expose the model to more challenging negative examples throughout the training process. Secondly, contrastive learning requires as many negative examples as possible but is limited by GPU memory constraints. Therefore, we use a Cross-GPU balancing Loss to provide more negative examples for embedding training and balance the batch size across multiple tasks. Moreover, we also discovered that the prompt-response pairs from LLMs can be used for embedding training. Our approach effectively enhances the capabilities of embedding models, currently ranking first on the Chinese leaderboard of Massive text embedding benchmark.
Introduction
In Retrieval-Augmented Generation (RAG) systems, embedding models serve as critical gatekeepers of quality. These models are typically trained using contrastive learning, which aims to pull "positive" pairs (e.g., a query and its relevant document) closer together in vector space while pushing "negative" pairs (unrelated text) further apart.
However, current training pipelines face two major challenges. First, static hard negatives chosen during preprocessing often become "easy" as the model improves, leading to a plateau in learning. Second, hardware constraints limit the number of negative samples that can be processed in a single batch, and sequential training on diverse tasks (like retrieval vs. semantic similarity) often causes training oscillations. To address these issues, we introduce Conan-embedding, a 326M parameter model that achieves state-of-the-art performance on the Chinese Massive Text Embedding Benchmark (CMTEB).
Methodology
Dynamic Hard Negative Mining (DHNM)
Standard hard negative mining (HNM) is a static process. As the model's discriminative power increases, these pre-selected negatives no longer provide a sufficient training signal. Conan-embedding introduces Dynamic Hard Negative Mining (DHNM), where the set of negative samples is refreshed iteratively.
As shown in the figure above, in standard HNM, the similarity score of negative samples drops quickly, indicating they are becoming too easy for the model. By periodically re-mining (every 100 steps), DHNM ensures the model is consistently challenged by "hard" negatives, maintaining a higher difficulty level throughout the training process.
Cross-GPU Batch Balance Loss (CBB)
Contrastive learning benefits significantly from large batch sizes, which provide more negative samples. However, GPU memory limits this scaling. Furthermore, multi-task learning across retrieval and Semantic Textual Similarity (STS) tasks can be unstable. We propose the Cross-GPU Batch Balance Loss (CBB) to solve these issues by distributing different tasks across multiple GPUs.
In this setup, multiple GPUs (e.g., GPU 0-3) handle retrieval tasks, sharing queries to maximize the effective negative sample pool, while a separate GPU (GPU 4) handles STS tasks. By aggregating these losses into a single update, the model achieves a balanced search space and avoids the oscillations typical of sequential multi-task training.
Matryoshka Representation Learning (MRL)
To provide flexibility in deployment, Conan-embedding incorporates Matryoshka Representation Learning (MRL). This allows the model to produce embeddings of varying lengths (from 256 to 1792 dimensions) without a significant loss in accuracy, enabling users to trade off storage and latency for performance.
Data and Training
The model underwent a massive two-stage training process:
- Weakly-supervised Pre-training: We utilized a dataset of 0.75 billion text pairs, filtered down to 0.4 billion high-quality pairs. A key finding was that including 100 million prompt-response pairs from Large Language Models (LLMs) significantly enhances embedding quality.
- Supervised Fine-tuning: The model was fine-tuned on a curated set of 4.2 million pairs across STS, Retrieval, and LLM-generated synthetic tasks.
Results and Key Insights
Conan-embedding currently holds the #1 spot on the CMTEB leaderboard, with an average score of 72.62, significantly outperforming competitive models like gte-Qwen2 and xiaobu-embedding-v2 (baseline 62.9).
Ablation studies confirm the efficacy of our methods:
- Vanilla Baseline: 68.8
- With DHNM: 71.2
- Full Conan (DHNM + CBB): 72.62
These results demonstrate that "more" and "better" negative samples are indeed the key to superior text embeddings. Furthermore, the "moving target" strategy of DHNM ensures the model stays in a state of constant improvement, while CBB Loss provides the stability needed for complex multi-task convergence.
Conclusion
Conan-embedding advances the state-of-the-art in text embeddings by focusing on the quality and quantity of negative samples. Through Dynamic Hard Negative Mining and Cross-GPU Batch Balance Loss, we overcome the limitations of static preprocessing and hardware constraints. Our findings also highlight the immense value of LLM-generated data for training robust retrieval models.
Summary updated