CoDiEmb: A Collaborative yet Distinct Framework for Unified Representation Learning in Information Retrieval and Semantic Textual Similarity

Bowen Zhang, Zixin Song, Chunquan Chen, Qian-Wen Zhang, Di Yin, Xing Sun · DOI

Abstract

CoDiEmb is a novel framework designed to enable a single text encoder to perform effectively across both Information Retrieval (IR) and Semantic Textual Similarity (STS) tasks. By decoupling task-specific learning signals through specialized loss functions and a "delta-guided" hierarchical model fusion strategy, CoDiEmb mitigates the performance trade-offs commonly associated with multi-task learning in these domains. Experimental results on the CMTEB benchmark demonstrate that CoDiEmb consistently outperforms single-task specialists and naive co-training approaches while improving the geometric properties of the embedding space.

Introduction

In natural language processing, text embeddings serve as a universal representation for various downstream tasks. Ideally, a single model should excel at both Information Retrieval (IR)—finding relevant documents for a query—and Semantic Textual Similarity (STS)—quantifying the semantic equivalence between sentences. However, these tasks possess fundamentally different characteristics:

  • Symmetry: STS is inherently symmetric, whereas IR is asymmetric (short queries vs. long documents).
  • Granularity: STS requires fine-grained continuous scoring, while IR often relies on binary relevance labels.
  • Optimization Objectives: STS focuses on global correlation (e.g., Spearman’s $\rho$), while IR prioritizes top-k ranking metrics (e.g., nDCG).
Comparison of data structures and relationships in Information Retrieval (IR) and Semantic Textual Similarity (STS) tasks.

Simultaneous training on both tasks often leads to "negative transfer," where improvements in one domain degrade performance in the other. CoDiEmb addresses this by creating a "collaborative yet distinct" learning environment that leverages the strengths of both tasks without compromising individual performance.

Methodology

The CoDiEmb framework introduces three primary innovations to harmonize IR and STS training:

1. Differentiated Loss Functions

To respect the unique requirements of each task, CoDiEmb employs specialized loss functions:

  • IR Loss: An optimized InfoNCE loss handles multiple positives and hard negatives. Cross-device sampling is utilized to scale the pool of distractors, enhancing the model's discriminative power.
  • STS Loss: Instead of standard contrastive objectives, a trio of list-wise losses is used: Pearson Loss for linear correlation, Normalized Rank KL-divergence to stabilize gradients by focusing on relative ranks, and Preference Rank Optimization (PRO) to penalize specific ordering errors.

2. Dynamic Task Sampling

To prevent gradient interference, a dynamic sampler ensures that each training batch contains data from only one task type. This allows the model to receive "pure" task-specific gradients during every iteration, avoiding the noise introduced by mixed-task batches.

3. Hierarchical Model Fusion

Rather than simple uniform averaging, CoDiEmb utilizes a "delta-guided" fusion strategy. The framework analyzes the parameter shift (the "delta") from the pre-trained starting point for both IR and STS specialists. It then merges these specialist "soups" using layer-wise weights derived from these shifts. This allows specific layers to specialize in the task for which they showed the most significant adaptation.

Experimental Evaluation

CoDiEmb was evaluated using the Chinese Massive Text Embedding Benchmark (CMTEB), covering 8 IR tasks and 7 STS tasks. The framework was validated across multiple architectures, including MiniCPM, multilingual-e5-large, and bge-large-zh-v1.5.

Key Results

  • Performance Gains: On the MiniCPM backbone, CoDiEmb achieved an average score of 73.44, significantly outperforming the IR-only specialist (62.89) and the STS-only specialist (65.56).
  • Embedding Space Health: CoDiEmb effectively addresses the issue of anisotropy (embeddings clustering in a narrow cone). On the STSB dataset, the framework reduced the "Condition Number" by 92% compared to standard InfoNCE baselines, resulting in a more isotropic and expressive embedding space.
  • Layer Specialization: Analysis revealed that middle layers often specialize in IR features, while later layers adapt more strongly to STS requirements.

Conclusion

CoDiEmb successfully bridges the gap between IR and STS by treating them as complementary forces: IR acts as a global "push-apart" force preventing collapse, while STS provides local "fine-sorting" for nuanced organization. While currently focused on these two domains, the framework's unified data format is extensible to other tasks. Future research will explore scaling CoDiEmb to larger LLM-based encoders and broader NLP tasks such as classification and clustering.

Summary updated

BibTeX
@misc{zhang2025codiemb,
  author = {Bowen Zhang and Zixin Song and Chunquan Chen and Qian-Wen Zhang and Di Yin and Xing Sun},
  title = {{CoDiEmb: A Collaborative yet Distinct Framework for Unified Representation Learning in Information Retrieval and Semantic Textual Similarity}},
  year = {2025},
  eprint = {2508.11442},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.11442},
}
Figure