Margins in Contrastive Learning: Evaluating Multi-task Retrieval for Sentence Embeddings

Tollef Emil Jørgensen, Jens Breitung


Abstract
This paper explores retrieval with sentence embeddings by fine-tuning sentence-transformer models for classification while preserving their ability to capture semantic similarity. To evaluate this balance, we introduce two opposing metrics – polarity score and semantic similarity score – that measure the model’s capacity to separate classes and retain semantic relationships between sentences. We propose a system that augments supervised datasets with contrastive pairs and triplets, training models under various configurations and evaluating their performance on top-k sentence retrieval. Experiments on two binary classification tasks demonstrate that reducing the margin parameter of loss functions greatly mitigates the trade-off between the metrics. These findings suggest that a single fine-tuned model can effectively handle joint classification and retrieval tasks, particularly in low-resource settings, without relying on multiple specialized models.
Anthology ID:
2025.nodalida-1.28
Volume:
Proceedings of the Joint 25th Nordic Conference on Computational Linguistics and 11th Baltic Conference on Human Language Technologies (NoDaLiDa/Baltic-HLT 2025)
Month:
march
Year:
2025
Address:
Tallinn, Estonia
Editors:
Richard Johansson, Sara Stymne
Venue:
NoDaLiDa
SIG:
Publisher:
University of Tartu Library
Note:
Pages:
269–278
Language:
URL:
https://preview.aclanthology.org/Ingest-2025-COMPUTEL/2025.nodalida-1.28/
DOI:
Bibkey:
Cite (ACL):
Tollef Emil Jørgensen and Jens Breitung. 2025. Margins in Contrastive Learning: Evaluating Multi-task Retrieval for Sentence Embeddings. In Proceedings of the Joint 25th Nordic Conference on Computational Linguistics and 11th Baltic Conference on Human Language Technologies (NoDaLiDa/Baltic-HLT 2025), pages 269–278, Tallinn, Estonia. University of Tartu Library.
Cite (Informal):
Margins in Contrastive Learning: Evaluating Multi-task Retrieval for Sentence Embeddings (Jørgensen & Breitung, NoDaLiDa 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/Ingest-2025-COMPUTEL/2025.nodalida-1.28.pdf