Skip to content
Cosvexa – Cosvexa home

Research · Foundations

Self-supervised learning explained

Self-supervised learning is a way of training models on unlabelled data by making the data supply its own labels: part of the input is hidden or altered, and the model learns to predict it. Predicting the next word, filling in masked words or matching two views of the same image are examples. It is how large language models and many vision and speech models are pretrained.

Cosvexa team · Published

A luminous image made of tiles with several tiles missing, faint glowing lines reaching from the visible tiles to fill in the gaps.

Key points

  • Self-supervised learning turns raw data into a supervised task, so no human labelling is needed.
  • The made-up task (the pretext task) is not the goal; the useful representations it forces the model to learn are.
  • Main families: predicting hidden parts (next-token, masked tokens or patches) and contrastive or joint-embedding methods.
  • It scales with cheap unlabelled data, which is why it underpins today's foundation models.
  • The learned model usually needs fine-tuning or prompting with a small amount of labelled data or feedback for a specific task.

What self-supervised learning is

Classic machine learning is split into supervised learning, which needs labelled examples, and unsupervised learning, which looks for structure in unlabelled data (see supervised vs unsupervised learning). Self-supervised learning sits in between. It uses unlabelled data, like unsupervised learning, but it trains with an ordinary supervised objective, because it constructs the labels automatically from the data itself.

The trick is a pretext task: a prediction problem whose answer is already in the data. Hide a word in a sentence and ask the model to guess it; the hidden word is the label. Cut an image into patches, remove most of them and ask the model to reconstruct them; the removed pixels are the label. Show the model two differently cropped and coloured copies of a photo and ask it to recognize that they belong together; the fact that they came from the same photo is the label. Nobody has to annotate anything.

The pretext task is rarely what anyone wants in the end. Few people need a program that fills in blanked-out words. The point is that solving the task well, across billions of examples, forces the model to learn general features of the data: grammar and facts for text, shapes and objects for images, phonemes for speech. Those features, the model's internal representations, can then be reused for the tasks people do care about, often with very little labelled data.

How it works: a concrete example

Take the masked-language-modelling task used by BERT (Devlin et al., 2018), covered in more depth in BERT explained. The sentence is “The cat sat on the mat because it was tired.” Training hides some of its tokens; the BERT paper masks 15% of the tokens in each sequence. The model might see “The cat sat on the [MASK] because it was [MASK].” and must output a probability for every word in its vocabulary at each masked position. The loss is low if it puts high probability on “mat” and “tired”.

  1. 1

    Take raw data

    Collect a large amount of unlabelled text, images, audio or video. No annotation is required.

  2. 2

    Create the task

    Automatically hide, corrupt or transform part of each example, and keep the original part as the target.

  3. 3

    Train the model to predict

    Use an ordinary loss, such as cross-entropy for words or squared error for pixels, and gradient descent to make predictions match the hidden targets.

  4. 4

    Keep the representations

    After pretraining, discard the parts used only for the pretext task, such as a reconstruction decoder, and keep the encoder that produces representations.

  5. 5

    Adapt to real tasks

    Fine-tune on a small labelled set, train a simple classifier on top of the frozen features, or, for generative language models, use prompting and instruction tuning.

To guess “tired” correctly, the model has to work out that “it” refers to the cat and that cats, not mats, get tired. Repeated over a large corpus, this kind of pressure builds up knowledge of syntax, word meaning and the world. Generative language models such as GPT use an even simpler pretext task, predicting the next token from the ones before it, which is the core of pretraining for large language models.

The main approaches

ApproachPretext taskWell-known examples
Autoregressive predictionPredict the next element from the previous onesGPT-style language models
Masked predictionReconstruct hidden parts of the inputBERT (masked words), MAE (masked image patches), wav2vec 2.0 (masked speech, with a contrastive target)
Contrastive learningPull together two views of the same example, push apart views of different examplesCPC, MoCo, SimCLR; CLIP for image–text pairs
Non-contrastive joint embeddingMake two views agree without explicit negative examples, using tricks to avoid trivial solutionsBYOL, DINO, I-JEPA

Text

Language was the first big success. word2vec (Mikolov et al., 2013) learned word vectors by predicting words from their neighbours. BERT showed in 2018 that masked prediction with a transformer produced representations that, after fine-tuning, set new results on many language-understanding benchmarks. GPT-style models showed that next-token prediction at scale produces models that can be prompted to do many tasks directly.

Images

Vision took longer because pixels are less structured than words. Contrastive learning made the breakthrough: Contrastive Predictive Coding (van den Oord et al., 2018) introduced the widely used InfoNCE loss, and MoCo and SimCLR applied the idea to images with heavy data augmentation. The SimCLR authors reported that a linear classifier trained on their self-supervised features reached 76.5% top-1 accuracy on ImageNet, matching a supervised ResNet-50. BYOL (2020) then showed that good features could be learned without explicit negative pairs, and masked autoencoders (He et al., 2021) brought the masked-prediction idea to images, hiding a high proportion of patches, for example 75%, and reconstructing the missing pixels.

CLIP (2021) applied contrastive learning to 400 million image–text pairs collected from the internet. Its authors called this learning from natural language supervision, and it is often classed as weak supervision rather than pure self-supervision, because the captions were written by people. The mechanism, however, is the same contrastive objective.

Speech

wav2vec 2.0 (Baevski et al., 2020) masks parts of the speech signal in a learned latent space and solves a contrastive task over them. The authors reported that after pretraining on 53,000 hours of unlabelled audio, fine-tuning with just ten minutes of transcribed speech still reached word error rates of 4.8% and 8.2% on the clean and other test sets of the LibriSpeech benchmark. Results of this kind point to a way of building speech recognition for languages with little transcribed audio.

Why it matters

  • It removes the labelling bottleneck. Labelled data is slow and expensive to produce; unlabelled text, images and audio exist in enormous quantities. Self-supervision lets model size and data grow together.
  • It produces general-purpose models. A model pretrained this way can be adapted to many tasks, which is the defining property of foundation models.
  • It helps low-resource settings. Pretraining on abundant unlabelled data, then fine-tuning on a small labelled set, often beats training on the small set alone, which matters for rare languages, medical imaging and specialized industries.
  • It learns from the structure of the world, not from a fixed list of categories. A classifier trained on a thousand labels learns what those labels need; a model trained to predict the data learns whatever helps prediction, which tends to be broader.

Limits and common misconceptions

  • “Self-supervised” does not mean the model teaches itself in a deep sense. The task is designed by people, and the choice of task strongly shapes what the model learns.
  • It is not free of human influence. The training data, how it is filtered and what it over- or under-represents all come from people. Biases in the data end up in the representations.
  • Pretraining alone rarely gives the final product. A next-token predictor continues text; it does not reliably follow instructions or refuse harmful requests. That takes supervised fine-tuning and feedback-based training.
  • Collapse is a real failure mode. In joint-embedding methods, a model can satisfy the objective by mapping every input to the same output. Contrastive negatives, momentum encoders, stop-gradient tricks and regularizers exist to prevent this.
  • More compute is needed, not less. Self-supervision saves labelling effort, but it usually requires much larger datasets and long training runs.

Where it is going

Self-supervised pretraining is now the default first stage for language, vision, speech and increasingly video, robotics and scientific data such as protein sequences. Current research directions include joint-embedding predictive architectures such as I-JEPA (2023), which predict the representation of hidden regions rather than their raw pixels; large self-supervised vision models such as DINOv2 (2023), whose features are used without fine-tuning; and multimodal pretraining that learns from text, images, audio and video together.

A second open question is data. The highest-quality public text is finite, which has led to more interest in synthetic data, in better filtering and in learning more from each example. Whatever the answers, the core idea seems likely to stay: let the structure of raw data provide the training signal, and save scarce human labels for steering the result. For how the resulting representations are used, see embeddings explained.

Frequently asked questions

What is self-supervised learning in simple terms?

It is a way of learning from unlabelled data by hiding part of each example and training the model to predict the hidden part. Because the answer is already in the data, nobody has to label anything. The model learns useful general knowledge as a side effect of getting good at the prediction.

What is the difference between self-supervised and unsupervised learning?

Both use unlabelled data. Self-supervised learning is usually considered a subtype of unsupervised learning that creates explicit prediction targets from the data and trains with a supervised-style loss. Classic unsupervised methods such as clustering or PCA instead look for structure without any prediction target.

Are large language models self-supervised?

Their pretraining is. A language model learns by predicting the next token in huge amounts of text, where the next token is the label. Later stages, such as instruction tuning and preference training, use human-written examples and feedback, so the finished assistant is not purely self-supervised.

What is contrastive learning?

Contrastive learning trains a model so that two different views of the same example, such as two crops of one photo, get similar representations, while views of different examples get dissimilar ones. CPC, MoCo, SimCLR and CLIP are well-known contrastive methods.

What is a pretext task?

A pretext task is the artificial prediction problem used to train a self-supervised model, such as filling in masked words or reconstructing hidden image patches. It is not the end goal; it is chosen because solving it requires learning representations that are useful for real tasks.

References

  1. Devlin et al. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
  2. van den Oord, Li and Vinyals (2018). Representation Learning with Contrastive Predictive Coding
  3. Chen et al. (2020). A Simple Framework for Contrastive Learning of Visual Representations
  4. Grill et al. (2020). Bootstrap your own latent: A new approach to self-supervised Learning
  5. Baevski et al. (2020). wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations
  6. He et al. (2021). Masked Autoencoders Are Scalable Vision Learners

More in this section

Start free: 50 Cosvexa-1 questions a day

Every major model in one workspace; on the Free plan Cosvexa-1 answers 50 questions a day. No card needed to start.