From t-SNE to UMAP with contrastive learning

Sebastian Damrich, Jan Niklas Böhm, Fred A. Hamprecht, Dmitry Kobak
6/3/2022
45 citations
cs.LGcs.HC
contrastive-ssl

Official code: berenslab/contrastive-ne (58 stars, Jupyter Notebook, MIT, last commit 2025-11-07). 1 more implementation below.

Abstract

Neighbor embedding methods $t$-SNE and UMAP are the de facto standard for visualizing high-dimensional datasets. Motivated from entirely different viewpoints, their loss functions appear to be unrelated.

Show full abstract

In practice, they yield strongly differing embeddings and can suggest conflicting interpretations of the same data. The fundamental reasons for this and, more generally, the exact relationship between $t$-SNE and UMAP have remained unclear. In this work, we uncover their conceptual connection via a new insight into contrastive learning methods. Noise-contrastive estimation can be used to optimize $t$-SNE, while UMAP relies on negative sampling, another contrastive method. We find the precise relationship between these two contrastive methods and provide a mathematical characterization of the distortion introduced by negative sampling. Visually, this distortion results in UMAP generating more compact embeddings with tighter clusters compared to $t$-SNE. We exploit this new conceptual connection to propose and implement a generalization of negative sampling, allowing us to interpolate between (and even extrapolate beyond) $t$-SNE and UMAP and their respective embeddings. Moving along this spectrum of embeddings leads to a trade-off between discrete / local and continuous / global structures, mitigating the risk of over-interpreting ostensible features of any single embedding. We provide a PyTorch implementation.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
berenslab/contrastive-neOfficial58Jupyter NotebookMIT2025-11-07
sciai-lab/cl-tsne-umapOfficial33Jupyter NotebookMIT2025-05-09
MIT

Contrastive neighbor embeddings

5810Jupyter Notebook, PythonFeb 15, 20221 years agoMIT
MIT
333Jupyter Notebook, PythonMay 31, 20221 years agoMIT

Similar Papers

Cite this paper

@article{damrich2022from,
  title  = {From t-SNE to UMAP with contrastive learning},
  author = {Sebastian Damrich and Jan Niklas Böhm and Fred A. Hamprecht and Dmitry Kobak},
  year   = {2022},
  eprint = {2206.01816},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2206.01816}
}

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/2206.01816.svg)](https://codeofpaper.com/paper/2206.01816)

Discussion