eMargin: Revisiting Contrastive Learning with Margin-Based Separation

Abdul-Kazeem Shamba, Kerstin Bach, Gavin Taylor
7/20/2025
cs.LGcs.AI

Official code: sfi-norwai/eMargin (2 stars, MIT, last commit 2025-07-22).

Abstract

We revisit previous contrastive learning frameworks to investigate the effect of introducing an adaptive margin into the contrastive loss function for time series representation learning. Specifically, we explore whether an adaptive margin (eMargin), adjusted based on a predefined similarity threshold, can improve the separation between adjacent but dissimilar time steps and subsequently lead to better performance in downstream tasks. Our study evaluates the impact of this modification on clustering performance and classification in three benchmark datasets. Our findings, however, indicate that achieving high scores on unsupervised clustering metrics does not necessarily imply that the learned embeddings are meaningful or effective in downstream tasks. To be specific, eMargin added to InfoNCE consistently outperforms state-of-the-art baselines in unsupervised clustering metrics, but struggles to achieve competitive results in downstream classification with linear probing. The source code is publicly available at https://github.com/sfi-norwai/eMargin.

View on arXivView PDF

Code Implementations(1)

sfi-norwai/eMarginOfficial100%
MIT
20Shell, PythonJul 18, 20251 years agoMIT

Cite this paper

@article{shamba2025emargin,
  title  = {eMargin: Revisiting Contrastive Learning with Margin-Based Separation},
  author = {Abdul-Kazeem Shamba and Kerstin Bach and Gavin Taylor},
  year   = {2025},
  eprint = {2507.14828},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2507.14828v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2507.14828.svg)](https://codeofpaper.com/paper/2507.14828)

Discussion