TL;DR
Should you use cosine similarity or dot product to compare vector embeddings? This paper shows that the standard practice of treating both sides symmetrically is a missed opportunity. By introducing a 2×2 framework that independently controls query and document normalization, the authors reveal that unilateral normalization (normalizing only one side) can supercharge out-of-domain retrieval by up to +72% and boost downstream RAG performance by +24%.
What Problem Does This Paper Address?
In modern machine learning, we constantly compare pairs of vectors—queries to documents, images to text captions, or users to items—using a learned similarity function $s(q, d)$. Yet, across different fields, the treatment of embedding magnitude is wildly inconsistent. Some architectures normalize it away entirely using cosine similarity, others preserve it via dot products, and some bury it inside Euclidean distance metrics.
Most of these choices are inherited by convention rather than principled design. More importantly, both cosine similarity (which normalizes both sides) and dot product (which normalizes neither) apply a symmetric treatment. This paper addresses a fundamental gap: When does embedding magnitude actually matter, and how should each side of a comparison treat it?
Methods
The authors break down the traditional denominator of cosine similarity into two independent per-side factors, expanding the design space into a 2×2 framework. This exposes two previously unstudied intermediate variants:
- QNORM: Only the query vector is normalized; document magnitude is preserved.
- DNORM: Only the document vector is normalized; query magnitude is preserved.
To unify these discrete choices, they introduce Learnable Normalization, which uses sigmoid-gated parameters to let the model dynamically discover the optimal normalization level via gradient descent.
Crucially, they propose the concept of Functional Symmetry. A task is functionally symmetric if its aggregate scoring procedure (the combination of training loss and inference protocol) treats the query ($Q$) and candidate ($C$) as interchangeable (e.g., Semantic Textual Similarity). If the roles are distinct (e.g., text retrieval, where a short query searches a long document), the task is functionally asymmetric.
Finally, for asymmetric tasks, the authors use the condition number ($\kappa$) of the Fisher Information Matrix (FIM) computed on the pretrained model before training to predict whether QNORM or DNORM will optimize more stably.
Datasets
The framework was validated across six distinct task families using a massive suite of datasets:
- Text Retrieval: MS MARCO (v1.1 QA and Passage Ranking) for in-domain training; BEIR (14 datasets), BRIGHT (12 reasoning-intensive datasets), and Multi-hop QA (4 datasets including HotpotQA and MuSiQue) for out-of-domain evaluation.
- Semantic Textual Similarity (STS): STS-Benchmark (STS-B) combined with AllNLI.
- Vision-Language Alignment: MS-COCO (using CLIP ViT-B/32).
- Knowledge Graph Completion (KGC): FB15k-237 and WN18RR.
- Few-Shot Classification: CIFAR-100 and mini-ImageNet.
- Recommender Systems: MovieLens-1M and MovieLens-100K.
Key Insights and Ideas
- Inference vs. Training Asymmetry: Embedding magnitudes play completely different roles depending on the phase. At inference time, only the document magnitude affects ranking (query magnitude scales all scores uniformly, leaving order unchanged). At training time, query magnitude acts as a per-example adaptive temperature, modulating gradient strength. High-magnitude queries sharpen the softmax distribution, signaling "confidence."
- Symmetry Predicts the Winner: Functional symmetry acts as a flawless cross-task predictor. Symmetric tasks strictly favor cosine similarity because partial normalization breaks role exchangeability. Asymmetric tasks, however, consistently perform better under unilateral normalization (QNORM or DNORM).
- Magnitude is Domain-Invariant: The benefits of magnitude learning are significantly more pronounced out-of-domain (OOD) than in-domain. This suggests that embedding magnitude encodes domain-invariant relevance signals—such as specificity or information density—that transfer robustly across data distributions, whereas angular similarity tends to overfit to domain-specific patterns.
Key Results
The coarse rule proposed by the authors (cosine for symmetric tasks, unilateral/magnitude-preserving for asymmetric tasks) held true in every single case examined.
- Retrieval Breakthroughs: On the reasoning-heavy BRIGHT benchmark, Contriever using QNORM outperformed Cosine similarity by a staggering +72% relative gain.
- Downstream RAG Impact: These retrieval improvements directly translated to generation quality. In a Retrieval-Augmented Generation (RAG) setup with Flan-T5-Large, QNORM improved Exact Match (EM) scores by up to +24% on TriviaQA compared to a Cosine baseline.
- Beating the Defaults: In few-shot classification, DNORM outperformed both Cosine similarity and the standard Euclidean distance default used by Prototypical Networks. In recommender systems, unilateral variants soundly beat Cosine similarity on MovieLens benchmarks.
Limitations and Future Work
While comprehensive, the paper primarily focuses on finetuning existing pretrained models. The authors note that exploring how these normalization strategies behave when training massive models entirely from scratch remains an open question.
Additionally, future work includes designing asymmetric objectives specifically for vision-language models (like CLIP) that can preserve their bidirectional retrieval capabilities while still unlocking the benefits of magnitude learning on individual tasks. Finally, extending this functional-symmetry principle to other domains like speech and graph neural networks represents an exciting next step.
Summary updated