Many methods learn feature representations from unlabeled data with a contrastive objective. Examples are word2vec-style text embeddings, sentence embeddings (quick-thoughts) and video-frame embeddings. A representation is trained so that is large for a "similar" pair and is small for a random "negative sample" . The learned is then used for downstream linear classification.
Arora, Khandeparkar, Khodak, Plevrakis and Saunshi (2019) give a framework that explains why this works. Data come from latent classes. A similar pair is two independent draws from one class, and a negative sample is a draw from a random class. Downstream tasks classify among the same latent classes.
In this framework the paper proves that the empirical minimizer of the contrastive loss has small average supervised loss whenever the function class contains a representation that separates different classes and is concentrated within classes. This mission formalizes the guarantees of Sections 4-6 and Appendices A-B of the paper.
A countable set of latent classes carries a distribution , and each class carries a distribution on the data space . Similar pairs have law , and negative samples have law .
Representations are measurable maps with , taken from a class . With the hinge loss or the logistic loss, the unsupervised loss with negative samples is
The algorithm returns , the minimizer of the empirical loss on i.i.d. tuples.
The representation is evaluated on supervised tasks: sets of distinct classes, classified by a linear map . averages the loss of the best over random tasks, and uses the mean classifier, whose rows are the class means . Two further quantities appear in the bounds:
With one negative sample, absolute constants and exist such that, for , with probability at least over the training set, for all ,
where and is the Rademacher average of on the training set.
The paper is one of the first theoretical accounts of contrastive representation learning, and its latent-class framework is the starting point of much later work on contrastive and self-supervised learning. It isolates two separate effects:
A machine-checked version fixes the exact constants and conditions behind these guarantees. The audit for this mission found that the printed Corollary 5.1.1 has the wrong coefficient of the generalization term. It also found that the printed margin of Lemma 5.1 is undefined when .
EuclideanSpace), measurable and bounded by . The function class is pointwise separable, the standard measurability convention for suprema over a class, which the paper does not state.Not included:
namespace ContrastiveUnsupervised
theorem binary_contrastive_guarantee :
∃ K c' : ℝ, 0 < c' ∧
∀ {X : Type u} [MeasurableSpace X] {C : Type v} [Countable C] {d : ℕ}
(D : C → Measure X) (ρ : C → ℝ), IsLatentClassModel D ρ → collisionProb ρ < 1 →
∀ (hinge : Bool) (R : ℝ), 0 < R →
∀ (F : Set (X → Rep d)), (∀ f ∈ F, IsBoundedRep f R) → IsPointwiseSeparable F →
∀ (M : ℕ), 1 ≤ M →
∀ (fhat : (Fin M → X × X × (Fin 1 → X)) → X → Rep d),
(∀ S, fhat S ∈ F ∧ ∀ f ∈ F, empUnsupLoss hinge 1 (fhat S) S ≤ empUnsupLoss hinge 1 f S) →
∀ δ : ℝ, 0 < δ → δ ≤ 1 / 2 →
sampleMeasure D ρ 1 M {S | ¬ ∀ f ∈ F,
avgSupLoss (stdLoss hinge) D ρ 1 (fhat S) ≤
avgMeanSupLoss (stdLoss hinge) D ρ 1 (fhat S) ∧
avgMeanSupLoss (stdLoss hinge) D ρ 1 (fhat S) ≤
unsupLossNeq hinge D ρ 1 f +
c' * (collisionProb ρ / (1 - collisionProb ρ)) * intraclassDeviation D ρ f +
1 / (1 - collisionProb ρ) * genError K R 1 M (rademacherAvg F S) δ} ≤
ENNReal.ofReal δ := by sorry
end ContrastiveUnsupervisedLet be a countable set of latent classes with distribution and class distributions , and let . Let be the hinge or the logistic loss. Let be a pointwise separable class of measurable with , . Let be an empirical minimizer, for every training set of tuples (one negative sample). There are absolute constants and such that, for every , with probability at least over the training set of tuples drawn from , for all ,
where , , , is the unsupervised loss conditioned on , and is the intraclass deviation.
This is the paper's main guarantee: if some contrasts different classes well and is concentrated within classes, the empirical minimizer of the contrastive loss does well on average binary classification.
Formalization Note and are averages over pairs of distinct classes with uniform label distribution, and uses the best linear classifier. The paper's is an absolute constant , and "with probability at least " means that the outer measure of the failure set is at most . The statement is restricted to because the proof (Mohri et al., Theorem 3.1, and Hoeffding) produces and . These are only for bounded away from ; for the two forms agree up to the constant. Pointwise separability of and measurability of each are standing conventions the paper does not state. The hypothesis is implicit in the paper's division by .