g↗genai/ learner
How Machines Learn / Lesson 05

Self-supervised learning

People do not hand-label billions of sentences to train a language model. In self-supervised learning, the training setup derives targets from raw data itself—for example, by hiding part of a sentence and checking predictions against the hidden piece.

Concept + interactive labBeginner friendly

Why people do not label every sentence.

In supervised learning (Lesson 4.1), each training example comes with an outside answer—a target attached by people or an external record, such as tagging an email as “Spam” or “Not spam.” Hand-labelling billions of web pages that way would be far too slow and costly.

Self-supervised learning solves that bottleneck by starting with unlabelled data—plain text, images, or audio with no outside tags attached—and deriving the target automatically from the data itself. A common way to do this with text is to hide one piece of a sentence and ask the model to predict what was hidden.

Think of studying with a sticky note: you cover one word in a sentence you already have, try to guess it, and lift the sticky note to check. The sentence itself is the answer key.

Running example: a plain recipe sentence

Start with one unlabelled sentence: “Simmer the soup until the carrots feel soft.” Hide “carrots” to make the input (“Simmer the soup until the [____] feel soft.”) and keep “carrots” as the target to check the model’s guess.

Diagram titled Self-supervised learning: raw unlabelled text 'Simmer the soup until the carrots feel soft.' splits into two paths—an Input 'Simmer the soup until the [____] feel soft.' sent to Model guesses ('potatoes') and a Target ('carrots') taken directly from the text—both meeting at Compare & adjust. Bottom cards show the sticky-note Analogy and three Key takeaways.
The hidden word comes straight from the raw sentence and goes to the comparison step, where checking the guess against the target guides training.

In this lesson, you will compare two common ways to hide text—fill-in-the-blank (masked) prediction and next-word prediction—try hiding words yourself, look at what self-supervised learning can and cannot guarantee, and check your understanding.

Two ways to hide text and make targets.

Where the target comes from stays the same—it is carved out of the raw text itself—but different hiding rules change what context the model gets to see. Real language models usually work on tokens (words or word pieces, as in Lesson 2.2); we use whole words here to keep the examples easy to read.

1. Fill in the blank (masked prediction)

Hide a word in a sentence and let the model read the surrounding words—on both sides whenever words appear before and after the blank (or the available side at sentence edges).

Recipe example: Input “Simmer the soup until the [____] feel soft.” → Target: “carrots”.

Everyday example: Reading a smudged weather note (“Bring a warm [____] for the mountain hike.”) and using the words before and after to guess “jacket”.

2. Predict the next word

Show only the earlier words and hide the very next word—the same next-token task you met in Lesson 2.2.

Recipe example: Input “Simmer the soup until the” → Target: “carrots”.

Everyday example: Reading a story one line at a time and guessing the next word before turning the page.

Notice how much training material a single sentence can supply. In an eight-word sentence, next-word prediction can create seven sequential input-and-target pairs (one for each word after the first), all without a human labelling a single example.

Diagram titled Two ways to hide text: top row Fill in the blank shows 'Simmer the soup until the [____] feel soft.' tagged Before & after pointing to Target 'carrots'; bottom row Predict next word shows 'Simmer the soup until the' tagged Earlier words only pointing to Target 'carrots'. Bottom cards show an open-book Analogy and three Key takeaways.
In this example, fill-in-the-blank gives context on both sides, while next-word prediction hides everything after the current position. Both take their target from the sentence itself.

The same idea works beyond text too: vision models can hide patches of an image and predict the missing region, and audio models can hide short slices of speech. In each case, the raw data supplies its own target.

Hide a word and see how data makes its own target.

Remember the sticky-note analogy: hiding a word turns a plain sentence into an input and a target automatically. Try both hiding modes below and see how visible context changes what seems plausible.

  1. Start on Soup recipe in Fill in the blank mode, with “carrots” hidden, and pick potatoes to see what happens when a sensible guess differs from the sentence’s exact target.
  2. Switch to Predict next word and notice that “feel soft.” disappears from the model’s input.
  3. Click another highlighted word—or choose Weather note—to see a new target created automatically from the sentence.
  4. Click Reset lab to return to the starting setup.
Full sentence: 8 single-word masks (3 selectable here)Context: before & after
1. Choose a raw sentence
2. Choose how to hide it
3. Pick a highlighted word to hide (that word becomes the target)
Simmertheuntilthefeel.
Input shown to the model

Simmer the soup until the [____] feel soft.

The words before (“Simmer the soup until the”) and after (“feel soft.”) narrow the blank to plural ingredients that soften when cooked.

4. Guess the word from the original sentence to reveal the self-supplied target

Waiting for your guess

Pick one of the four words above. The lab will reveal the hidden word from the original sentence—the target the data supplied on its own.

Illustrative simulation: these sentences, candidate words, and explanations are pre-written for this lesson, not generated by a live model. In this toy lab, three highlighted words per sentence are interactive; real training runs across full passages and usually splits text into subword tokens rather than whole words.

What self-supervised learning can and cannot do.

Because raw text supplies its own targets, self-supervised pretraining scales to vast datasets. That helps a model pick up grammar, common phrasing, and broad patterns across many topics.

Still, self-supervised learning has real limits. Predicting hidden text teaches patterns in the training data, not guaranteed truth—if the source text contains mistakes, outdated facts, or bias, those words become targets too.

It also does not remove people from building an AI system. Teams still collect, clean, and filter training data, choose the hiding task, and often add later training steps—such as human-written examples or preference feedback—so a chat assistant follows instructions helpfully and safely.

  • Does self-supervised learning mean zero human effort?

    No. It removes the need for people to hand-label every pretraining example, not the human work of curating data, filtering low-quality text, and tuning models for specific tasks later.

  • How is self-supervised learning different from unsupervised learning?

    In clustering (Lesson 4.4), there is no target answer to predict—a system groups similar items. Self-supervised learning does predict a target, except the target is derived from the raw data itself. In everyday speech, people sometimes still group it under unsupervised learning because no outside labels are provided.

  • If “potatoes” misses the target “carrots”, does the model learn that “potatoes” is wrong?

    On this single sentence, the target is “carrots”, so training nudges the model toward “carrots” for this example. That does not rule out “potatoes” permanently: other training examples can supply “potatoes” or “noodles” as targets in similar soup contexts.

✎ Try it yourselfKnowledge check · Practice only

Check your understanding.

A weather archive holds millions of daily forecast notes with no category tags attached. A researcher wants to pretrain a model on these notes using self-supervised learning. Which training setup matches self-supervised learning?

Take this with you.

Data can supply its own targets. In self-supervised learning, the training setup derives targets automatically from unlabelled data—such as hiding a word in a sentence and checking the model’s guess against it. That lets models learn broad patterns at huge scale without people hand-labelling every example, though humans still curate the data and predicting text does not guarantee truth.

Ready to continue? Return to How Machines Learn.