Notes

BERT

Reading a word properly means reading what sits on both sides of it. Earlier neural language models ran strictly left to right, so the representation of “bank” in “the bank of the river” was built without ever seeing “river”. BERT — Bidirectional Encoder Representations from Transformers — removed that limitation.

How it is trained
BERT is an encoder-only transformer stack trained on two self-supervised objectives over unlabelled text: masked language modeling, where 15% of tokens are hidden and must be recovered from the full surrounding context, and next sentence prediction, where the model judges whether one segment followed another. Because nothing is being generated, every layer can attend in both directions at once. Input is split by WordPiece, so an unfamiliar word arrives as known pieces rather than as an unknown token.

How it gets used
Pre-training happens once, on a cluster; what you do is fine-tune. Add a small head on top and train briefly on labelled data:

  • A classifier over the pooled [CLS] token for sentiment, intent or natural language inference.
  • A per-token head for named entity recognition, or a span head for question answering as scored by SQuAD.
  • Frozen internal layers as a source of contextual embeddings for another model.

Why it matters
BERT moved every task on the GLUE benchmark at once and established the pattern the field still follows — pre-train a general encoder, adapt it cheaply per task — along with the variants that trim its costs: RoBERTa, DistilBERT, ALBERT, ELECTRA. It produces no text, and asking it to write is the most common misuse.

BERT is an encoder-only transformer pre-trained on unlabelled text with masked language modeling and next-sentence prediction, producing a representation of each token that depends on context from both directions. Fine-tuning it with a small task head gives strong results on classification, tagging and question answering from modest labelled data. It established the pre-train-then-fine-tune pattern for language understanding, and it generates no text — it is a reader, not a writer.

Read the word “bank” on its own and you cannot say what it means. Read “we sat on the bank and watched the boats go by” and you can — because you took in the words on both sides of it.

BERT was the model that taught software to do that properly. It was trained by hiding random words in billions of sentences and learning to guess them from everything around them. Once it had that general feel for how language fits together, it could be adapted in an afternoon to spot angry reviews, pull names out of contracts, or answer questions about a document. It reads rather than writes.