Home Knowledge Base Contrastive Learning Frameworks (SimCLR, MoCo, DINO, BYOL)

Contrastive Learning Frameworks (SimCLR, MoCo, DINO, BYOL) is a family of self-supervised representation learning methods that train visual encoders by learning to distinguish similar (positive) pairs from dissimilar (negative) pairs without requiring labeled data — achieving representation quality that rivals or exceeds supervised pretraining on downstream vision tasks.

Contrastive Learning Foundations

<svg viewBox="0 0 760 470" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,Segoe UI,Roboto,sans-serif">
  <rect x="0" y="0" width="760" height="470" fill="#0d1117"/>
  <text x="380" y="28" fill="#e6edf3" font-size="21" font-weight="700" text-anchor="middle">Contrastive Learning — Self-Supervised Representations</text>
  <text x="380" y="48" fill="#8b98a5" font-size="12" text-anchor="middle">learn embeddings by pulling augmented views together and pushing different images apart</text>

  <!-- SimCLR framework -->
  <rect x="30" y="65" width="700" height="210" rx="6" fill="#080d14" stroke="#233043" stroke-width="1"/>
  <text x="380" y="86" fill="#e6edf3" font-size="11" font-weight="600" text-anchor="middle">SimCLR / MoCo Framework</text>

  <!-- Original image -->
  <rect x="55" y="120" width="55" height="55" rx="3" fill="#1e3a5f" stroke="#60a5fa" stroke-width="0.8"/>
  <text x="82" y="152" fill="#93c5fd" font-size="8" text-anchor="middle">image x</text>

  <!-- Two augmentations -->
  <path d="M112,135 L145,115" fill="none" stroke="#3a4453" stroke-width="0.8"/>
  <path d="M112,160 L145,175" fill="none" stroke="#3a4453" stroke-width="0.8"/>
  <text x="130" y="108" fill="#6b7684" font-size="6">aug</text>
  <text x="130" y="185" fill="#6b7684" font-size="6">aug</text>

  <rect x="148" y="100" width="45" height="40" rx="3" fill="#14261f" stroke="#34d399" stroke-width="0.8"/>
  <text x="170" y="124" fill="#34d399" font-size="7" text-anchor="middle">x_i</text>

  <rect x="148" y="160" width="45" height="40" rx="3" fill="#1c1633" stroke="#a78bfa" stroke-width="0.8"/>
  <text x="170" y="184" fill="#a78bfa" font-size="7" text-anchor="middle">x_j</text>

  <!-- Encoders -->
  <path d="M195,120 L228,120" fill="none" stroke="#3a4453" stroke-width="0.8"/>
  <path d="M195,180 L228,180" fill="none" stroke="#3a4453" stroke-width="0.8"/>

  <rect x="230" y="105" width="70" height="30" rx="3" fill="#0b1220" stroke="#34d399" stroke-width="0.8"/>
  <text x="265" y="124" fill="#6ee7b7" font-size="7" text-anchor="middle">encoder f</text>

  <rect x="230" y="165" width="70" height="30" rx="3" fill="#0b1220" stroke="#a78bfa" stroke-width="0.8"/>
  <text x="265" y="184" fill="#c4b5fd" font-size="7" text-anchor="middle">encoder f</text>

  <!-- Projection heads -->
  <path d="M302,120 L328,120" fill="none" stroke="#3a4453" stroke-width="0.8"/>
  <path d="M302,180 L328,180" fill="none" stroke="#3a4453" stroke-width="0.8"/>

  <rect x="330" y="105" width="60" height="30" rx="3" fill="#0b1220" stroke="#f59e0b" stroke-width="0.8"/>
  <text x="360" y="124" fill="#fbbf24" font-size="7" text-anchor="middle">proj g</text>

  <rect x="330" y="165" width="60" height="30" rx="3" fill="#0b1220" stroke="#f59e0b" stroke-width="0.8"/>
  <text x="360" y="184" fill="#fbbf24" font-size="7" text-anchor="middle">proj g</text>

  <!-- Embeddings -->
  <path d="M392,120 L425,120" fill="none" stroke="#3a4453" stroke-width="0.8"/>
  <path d="M392,180 L425,180" fill="none" stroke="#3a4453" stroke-width="0.8"/>

  <circle cx="440" cy="120" r="10" fill="#14261f" stroke="#34d399" stroke-width="1"/>
  <text x="440" y="124" fill="#34d399" font-size="7" text-anchor="middle">z_i</text>

  <circle cx="440" cy="180" r="10" fill="#1c1633" stroke="#a78bfa" stroke-width="1"/>
  <text x="440" y="184" fill="#a78bfa" font-size="7" text-anchor="middle">z_j</text>

  <!-- Contrastive loss -->
  <path d="M452,120 L490,150" fill="none" stroke="#34d399" stroke-width="1.2"/>
  <path d="M452,180 L490,150" fill="none" stroke="#a78bfa" stroke-width="1.2"/>

  <rect x="493" y="130" width="120" height="40" rx="5" fill="#0b1220" stroke="#f59e0b" stroke-width="1.2"/>
  <text x="553" y="148" fill="#fbbf24" font-size="8" text-anchor="middle">NT-Xent Loss</text>
  <text x="553" y="162" fill="#6b7684" font-size="7" text-anchor="middle">-log(sim(z_i,z_j)/Σ neg)</text>

  <!-- Pull/push annotation -->
  <rect x="630" y="100" width="90" height="80" rx="4" fill="#0d1117" stroke="#334155" stroke-width="0.5"/>
  <text x="675" y="118" fill="#34d399" font-size="8" text-anchor="middle">pull ↔ together</text>
  <text x="675" y="134" fill="#34d399" font-size="7" text-anchor="middle">(same image, diff aug)</text>
  <text x="675" y="155" fill="#f87171" font-size="8" text-anchor="middle">push ↔ apart</text>
  <text x="675" y="171" fill="#f87171" font-size="7" text-anchor="middle">(different images)</text>

  <!-- Augmentations list -->
  <text x="380" y="220" fill="#8b98a5" font-size="8" text-anchor="middle">augmentations: random crop, color jitter, gaussian blur, flip, rotation, cutout</text>
  <text x="380" y="236" fill="#6b7684" font-size="7.5" text-anchor="middle">key: augmentations define what the model learns to be invariant to</text>
  <text x="380" y="252" fill="#6b7684" font-size="7.5" text-anchor="middle">batch size matters: SimCLR needs 4096+ (more negatives = better representations)</text>

  <!-- Model variants -->
  <rect x="30" y="288" width="700" height="140" rx="6" fill="#080d14" stroke="#233043" stroke-width="1"/>
  <text x="380" y="308" fill="#e6edf3" font-size="10" font-weight="600" text-anchor="middle">Contrastive Learning Family</text>

  <text x="50" y="332" fill="#60a5fa" font-size="8.5" font-weight="600">SimCLR (2020):</text><text x="150" y="332" fill="#8b98a5" font-size="8">symmetric, needs large batch (4096), simple but effective</text>
  <text x="50" y="350" fill="#34d399" font-size="8.5" font-weight="600">MoCo v3 (2021):</text><text x="155" y="350" fill="#8b98a5" font-size="8">momentum encoder, queue of negatives, works with batch=256</text>
  <text x="50" y="368" fill="#a78bfa" font-size="8.5" font-weight="600">DINO/DINOv2 (2023):</text><text x="180" y="368" fill="#8b98a5" font-size="8">self-distillation (no negatives!), ViT backbone, best features</text>
  <text x="50" y="386" fill="#f59e0b" font-size="8.5" font-weight="600">BYOL (2020):</text><text x="135" y="386" fill="#8b98a5" font-size="8">no negatives needed — asymmetric with predictor head</text>
  <text x="50" y="404" fill="#38bdf8" font-size="8.5" font-weight="600">CLIP (2021):</text><text x="130" y="404" fill="#8b98a5" font-size="8">contrastive between image and text pairs (multimodal)</text>
  <text x="50" y="420" fill="#6b7684" font-size="7.5">DINOv2 features are now the default vision backbone for many tasks — competitive with supervised pretraining</text>

  <text x="380" y="452" fill="#6b7684" font-size="11" text-anchor="middle">Contrastive learning proved that labels are optional — augmentation + structure is enough to learn representations.</text>
</svg>

Contrastive learning trains encoders to map augmented views of the same image (positive pairs) to nearby points in embedding space while pushing apart representations of different images (negative pairs). The InfoNCE loss function treats the task as classification: for a query embedding q and positive key k+, minimize $-log frac{exp(q cdot k^+ / au)}{sum_i exp(q cdot k_i / au)}$ where τ is temperature and the denominator sums over all keys including negatives. The quality of learned representations depends critically on augmentation strategies, negative sampling, and projection head design.

SimCLR: Simple Contrastive Learning of Representations

MoCo: Momentum Contrast

BYOL: Bootstrap Your Own Latent

DINO: Self-Distillation with No Labels

Downstream Transfer and Impact

Contrastive and self-distillation frameworks have fundamentally changed visual representation learning, proving that large-scale unlabeled data combined with carefully designed learning objectives can produce features rivaling decades of supervised pretraining research.

contrastive learning simclr mocodino self supervised learningbyol contrastive frameworkself supervised visual representationcontrastive loss infoNCE

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.