Optimal Sample Complexity of Contrastive Learning

Noga Alon, Dmitrii Avdiukhin, Dor Elboim, Orr Fischer, G. Yaroslavtsev
2/12/2026

No confident code implementation found for this paper.

Abstract

Contrastive learning is a highly successful technique for learning representations of data from labeled tuples, specifying the distance relations within the tuple. We study the sample complexity of contrastive learning, i.e. the minimum number of labeled tuples sufficient for getting high generalization accuracy. We give tight bounds on the sample complexity in a variety of settings, focusing on arbitrary distance functions, both general $\ell_p$-distances, and tree metrics. Our main result is an (almost) optimal bound on the sample complexity of learning $\ell_p$-distances for integer $p$. For any $p \ge 1$ we show that $\tilde \Theta(\min(nd,n^2))$ labeled tuples are necessary and sufficient for learning $d$-dimensional representations of $n$-point datasets. Our results hold for an arbitrary distribution of the input samples and are based on giving the corresponding bounds on the Vapnik-Chervonenkis/Natarajan dimension of the associated problems. We further show that the theoretical bounds on sample complexity obtained via VC/Natarajan dimension can have strong predictive power for experimental results, in contrast with the folklore belief about a substantial gap between the statistical learning theory and the practice of deep learning.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{alon2026optimal,
  title  = {Optimal Sample Complexity of Contrastive Learning},
  author = {Noga Alon and Dmitrii Avdiukhin and Dor Elboim and Orr Fischer and G. Yaroslavtsev},
  year   = {2026},
  eprint = {2312.00379},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2312.00379},
  journal = {ICLR 2023 2023}
}

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

Discussion