0Pricing
NLP Academy · Lezione

Masked language modeling

Come BERT apprende dal testo grezzo

Masked language modeling è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Learning Without Labels

BERT trains on plain text with no human labels at all. This clever trick is called self-supervised learning.

The Fill-in-the-Blank Game

BERT learns by hiding some words and guessing them back. That game is masked language modeling, or MLM for short.

Hiding a Word

A random word gets swapped for a special placeholder. Here the model must recover what the mask is covering up.

text = "the cat sat on the [MASK]"
# model should predict: mat

Predict the Missing Word

BERT reads everything around the blank and ranks likely fills. Strong guesses come from using the full context.

Why Hiding Helps

To fill a blank well, the model must learn grammar, facts, and word relationships. The blank forces real understanding.

The Famous 15 Percent

BERT masks about 15 percent of the words in each sentence during training. That ratio balances signal and difficulty.

Both Sides at Once

Unlike left-to-right models, BERT sees words before and after the blank. This bidirectional view makes its guesses far richer.

A Second Task

Original BERT also guessed if one sentence follows another. That extra job is next sentence prediction, teaching it about flow.

Pre-training, Then Reuse

This slow, expensive MLM phase is the pre-training step. You download the result and reuse it without redoing the work.

Try It in Code

A fill-mask pipeline lets you watch MLM in action and see BERT rank its top predictions for any blank.

from transformers import pipeline
fm = pipeline("fill-mask", model="bert-base-uncased")
fm("Paris is the [MASK] of France.")

Knowledge for Free

After MLM, BERT holds a huge store of language knowledge ready to power your tasks. All of it came from raw text.

Quick Check

What does masked language modeling ask BERT to do?

Recap

BERT learns by filling masked blanks using both sides of a sentence. This self-supervised MLM builds deep language knowledge. ✅

Domande Frequenti

La lezione «Masked language modeling» è gratuita?

Sì — il testo completo di «Masked language modeling» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.

Cosa imparerò in «Masked language modeling»?

Come BERT apprende dal testo grezzo Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare NLP Academy?

Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.

Quanto tempo richiede la lezione «Masked language modeling»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione NLP Academy?

Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Perché il contesto cambia il significato delle parole
  2. Masked language modeling
  3. Creare embedding di frasi con BERT
  4. Scegliere il modello pre-addestrato corretto
← Torna a NLP Academy