Zubnet AIAprenderWiki › Contrastive Aprendering
Training

Contrastive Aprendering

SimCLR, InfoNCE
Un enfoque de aprendizaje auto-supervisado que entrena modelos contrastando pares positivos (items similares que deberían estar cerca en espacio de embedding) contra pares negativos (items distintos que deberían estar lejos). CLIP contrasta pares imagen-texto coincidentes contra no-coincidentes. SimCLR contrasta vistas aumentadas de la misma imagen contra vistas de imágenes distintas. El modelo aprende representaciones donde la similitud en espacio de embedding refleja la similitud del mundo real.

Por qué importa

El contrastive learning es cómo se entrenan la mayoría de modelos de embedding — los modelos que impulsan búsqueda semántica, RAG y recomendaciones. También es el enfoque de entrenamiento detrás de CLIP, que conecta lenguaje y visión. Cada vez que usas embeddings para medir similitud, el contrastive learning probablemente es cómo se crearon esos embeddings.

Deep Dive

The InfoNCE loss (used by CLIP and many embedding models): given a batch of N positive pairs, treat the N−1 non-matching items in the batch as negative examples. The loss pushes positive pair embeddings closer together and negative pair embeddings apart. The key insight: you don't need explicitly labeled negative examples — other items in the batch serve as negatives for free, making the approach highly scalable.

Data Augmentation as Supervision

In vision, contrastive learning creates positive pairs through data augmentation: two random crops of the same image are a positive pair (they show the same content from different views). Different images form negative pairs. The model learns that the augmented views should have similar embeddings while different images should have different embeddings. This learns useful visual representations without any labels — pure self-supervision.

Hard Negatives

Not all negatives are equally useful for learning. "Hard negatives" — items that are similar but not matching — provide the most learning signal. For a query about "Python web frameworks," a hard negative might be a document about "Python data science" (similar topic, wrong answer) rather than one about "cooking recipes" (obviously irrelevant). Mining hard negatives is a key technique for training high-quality embedding models.

Conceptos relacionados

← Todos los términos
← Continual Aprendering ControlNet →