Table of Contents
Fetching ...

Beyond the Unit Hypersphere: Embedding Magnitude in Contrastive Learning

Xincan Feng, Taro Watanabe

TL;DR

This work questions the default use of unit-normalized embeddings in contrastive learning, showing that embedding magnitude can encode task-relevant information, particularly for retrieval and RAG. Through a minimal 2×2 ablation and a continuous learnable normalization, the authors demonstrate that removing the unit-sphere constraint enables magnitude-based signals to improve performance, especially on hard, out-of-domain tasks, while symmetric tasks suffer if magnitude is not treated carefully. They propose the Task Symmetry Principle to guide similarity function choice: magnitude learning benefits asymmetric tasks (e.g., retrieval, QA) but can harm symmetric tasks (e.g., STS, clustering) where symmetry is essential. The results include substantial gains on RAG QA, insights into when and how magnitude helps, and practical guidance for leveraging magnitude with learnable normalization, though architectural compatibility (as in E5) can limit gains without adjustments. Overall, the paper provides both theoretical guarantees and empirical evidence that magnitude-aware contrastive learning can outperform cosine-based approaches in appropriate, asymmetric settings, with broad implications for dense retrieval and cross-modal systems.

Abstract

Cosine similarity is prevalent in contrastive learning, yet it makes an implicit assumption: embedding magnitude is noise. Prior work occasionally found dot product and cosine similarity comparable, but left unanswered WHAT information magnitude carries, WHEN it helps, and HOW to leverage it. We conduct a systematic study through a $2 \times 2$ ablation that independently controls input-side and output-side normalization across text and vision models. Our findings reveal three key insights. First, in text retrieval, output (document) magnitude strongly correlates with relevance (Cohen's $d$ up to 1.80), yielding the largest gains on reasoning-intensive tasks. Second, input and output magnitudes serve asymmetric roles: output magnitude directly scales similarity scores while input magnitude modulates training dynamics. Third, magnitude learning benefits asymmetric tasks (text retrieval, RAG) but harms symmetric tasks (STS, text-image alignment). These findings establish a task symmetry principle: the choice between cosine and dot product depends on whether the task has distinct input roles, enabling cost-free improvements by simply removing an unnecessary constraint.

Beyond the Unit Hypersphere: Embedding Magnitude in Contrastive Learning

TL;DR

This work questions the default use of unit-normalized embeddings in contrastive learning, showing that embedding magnitude can encode task-relevant information, particularly for retrieval and RAG. Through a minimal 2×2 ablation and a continuous learnable normalization, the authors demonstrate that removing the unit-sphere constraint enables magnitude-based signals to improve performance, especially on hard, out-of-domain tasks, while symmetric tasks suffer if magnitude is not treated carefully. They propose the Task Symmetry Principle to guide similarity function choice: magnitude learning benefits asymmetric tasks (e.g., retrieval, QA) but can harm symmetric tasks (e.g., STS, clustering) where symmetry is essential. The results include substantial gains on RAG QA, insights into when and how magnitude helps, and practical guidance for leveraging magnitude with learnable normalization, though architectural compatibility (as in E5) can limit gains without adjustments. Overall, the paper provides both theoretical guarantees and empirical evidence that magnitude-aware contrastive learning can outperform cosine-based approaches in appropriate, asymmetric settings, with broad implications for dense retrieval and cross-modal systems.

Abstract

Cosine similarity is prevalent in contrastive learning, yet it makes an implicit assumption: embedding magnitude is noise. Prior work occasionally found dot product and cosine similarity comparable, but left unanswered WHAT information magnitude carries, WHEN it helps, and HOW to leverage it. We conduct a systematic study through a ablation that independently controls input-side and output-side normalization across text and vision models. Our findings reveal three key insights. First, in text retrieval, output (document) magnitude strongly correlates with relevance (Cohen's up to 1.80), yielding the largest gains on reasoning-intensive tasks. Second, input and output magnitudes serve asymmetric roles: output magnitude directly scales similarity scores while input magnitude modulates training dynamics. Third, magnitude learning benefits asymmetric tasks (text retrieval, RAG) but harms symmetric tasks (STS, text-image alignment). These findings establish a task symmetry principle: the choice between cosine and dot product depends on whether the task has distinct input roles, enabling cost-free improvements by simply removing an unnecessary constraint.
Paper Structure (134 sections, 5 theorems, 20 equations, 9 figures, 24 tables)

This paper contains 134 sections, 5 theorems, 20 equations, 9 figures, 24 tables.

Key Result

Proposition 4.1

For a fixed query $\bm{q}$, only document magnitude can alter document rankings. Formally, let $\pi_s$ denote the ranking (permutation) of a document set $\mathcal{D}$ sorted by decreasing $s(\bm{q}, \bm{d})$. Then: Query magnitude $\|\bm{q}\|$ is a positive constant for a fixed query that scales all scores uniformly, thus never affecting rankings.

Figures (9)

  • Figure 1: The $2 \times 2$ ablation framework. The dashed circle represents the unit sphere. Normalized vectors ($\hat{\bm{v}}$) lie on the sphere; unnormalized vectors extend beyond. Rows: query magnitude preserved or discarded. Columns: document magnitude preserved or discarded.
  • Figure 2: Step-matched val NDCG@10 comparison during training. For both models, the Learnable variant consistently performs near the top, with validation curves closely following DNorm throughout training.
  • Figure 3: Per-dataset Cohen's $d$ vs. $\Delta\%$ for Contriever (top) and RetroMAE (bottom, excluding bright-pony). Cohen's $d$ values are averaged across 3 seeds (0, 42, 1337) with horizontal error bars showing $\pm$std. Each point represents one dataset: blue squares = In-Domain (TREC-DL), green circles = BEIR, red triangles = BRIGHT, orange pentagons = Multi-hop. Background shading indicates Cohen's $d$ effect size interpretation: large ($|d| \geq 0.8$), medium ($0.5 \leq |d| < 0.8$), small ($0.2 \leq |d| < 0.5$), and negligible ($|d| < 0.2$, white). Dashed lines show regression fits: Contriever ($r=0.57$, $p<0.001$), RetroMAE ($r=0.68$, $p<0.001$). The bright-pony dataset is excluded from the RetroMAE plot due to its anomalous $\Delta\%=512.5$ caused by an extremely low Cosine baseline (see text for analysis). See Table \ref{['tab:cohens_d_all_datasets']} for per-dataset values.
  • Figure 4: Learned normalization strengths $\gamma_q, \gamma_d$ over training. Contriever drifts toward Dot ($\gamma < 0.5$), while RetroMAE drifts toward Cosine ($\gamma > 0.5$).
  • Figure 5: $\Delta$CV vs. $\Delta$Perf for Contriever and RetroMAE on 39 datasets (3-seed averaged). The two models form clearly separated clusters: Contriever (blue, $\Delta$CV $<$ 2) benefits from QNorm ($\Delta$Perf $<$ 0), while RetroMAE (red, $\Delta$CV $>$ 4) benefits from DNorm ($\Delta$Perf $>$ 0). Large markers indicate cluster means; error bars show $\Delta$CV std across datasets.
  • ...and 4 more figures

Theorems & Definitions (7)

  • Proposition 4.1: Ranking Equivalence
  • Proposition 4.2: Gradient Asymmetry
  • Corollary 6.1: Task Symmetry Constraint
  • Proposition 20.1: Normalization Gradient
  • proof
  • Proposition 20.2: Generalized Ranking Equivalence
  • proof