The Idea: Reading Both Ways at Once
BERT (Bidirectional Encoder Representations from Transformers), published by Google in October 2018, starts from a simple but profound observation.
Before BERT, language models read left to right, one word at a time. That's what GPT does: it predicts the next word by only looking at the previous words. But when you read a sentence, you don't do that. You see the context before and after a word to understand it.
Take an example: "He put his money in the bank." Is it a financial institution or the side of a river? To know, you need what comes before ("money") AND potentially what comes after. A left-to-right model only sees "He put his money in the" when it processes "bank." BERT sees the entire sentence.
Technically simple. Conceptually powerful. And the results were devastating to the state of the art.
BERT proved a fundamental principle: pre-training a model on a large amount of unlabeled text (Wikipedia, books), then fine-tuning it on a small amount of labeled data for a specific task, beats specialized systems trained from scratch. This was truly revolutionary in 2018 and has become the norm for the entire industry.
Masked Language Modeling: The Key Technical Innovation
How do you train a bidirectional model? You can't just ask it to predict the next word, because it would already see the answer (it looks in both directions). BERT's trick is called Masked Language Modeling (MLM).
The principle: you take a sentence, mask 15% of the tokens at random, and ask the model to guess what's hidden. But with an important subtlety for training robustness. Among those 15% of selected tokens:
- 80% are replaced with a special [MASK] token
- 10% are replaced with a random token (to force the model to stay alert)
- 10% are kept intact (so the model also learns not to modify what's correct)
The model must predict the original tokens by relying on the left and right context simultaneously. This is what forces deep bidirectional language understanding.
The analogy: it's like a fill-in-the-blank exercise. You have to guess the missing words by relying on all the surrounding context. The better you are at reading comprehension, the more accurately you guess.

BERT also uses a second training task: Next Sentence Prediction (NSP). The model receives two sentences and must predict whether the second logically follows the first. This helps it understand inter-sentence relationships (though later work, like RoBERTa, showed this task wasn't so crucial).

Architecture
- BERT-Base: 12 layers, 768 dimensions, 12 attention heads, 110M parameters
- BERT-Large: 24 layers, 1024 dimensions, 16 attention heads, 340M parameters
- Encoder-only architecture (no decoder part, so no text generation)
- Pre-trained on BookCorpus + English Wikipedia (~3.3 billion words)
Compared to current standards (hundreds of billions of parameters), BERT is tiny. But in 2018, 340M parameters was considerable, and the results were spectacular.
Results: Absolute Domination
BERT literally swept 11 NLP benchmarks (Natural Language Processing) in one go:
- GLUE: +7.7 points above the previous state of the art. A gigantic leap in NLP.
- SQuAD (question answering): surpasses human performance on the reading comprehension task.
- NER (named entity recognition), sentiment analysis, text inference: all significantly improved.
The NLP community was in shock. A single model, pre-trained generically, was beating specialized systems that had been refined for years on each individual task.
The Variants: BERT Spawns a Family
BERT's success triggered an avalanche of variants:
RoBERTa (Facebook, 2019): same architecture, but better trained. More data, longer training, without the NSP task (deemed useless). Better than BERT on everything.
DistilBERT (Hugging Face, 2019): 60% smaller than BERT-Base, but retains 97% of its performance. Proof that knowledge distillation works remarkably.
ALBERT: lightweight version with parameter sharing between layers. Smaller, comparable performance.
Multilingual: mBERT (104 languages) and XLM-RoBERTa extended the approach to dozens of languages simultaneously. A single model to understand French, English, Chinese, Arabic...
Specialized: SciBERT (scientific papers), BioBERT (biomedical literature), FinBERT (financial texts), ClinicalBERT (medical records). Each pre-trained on domain-specific corpora.
BERT established the workflow that still dominates today: pre-train on a huge generalist corpus, then fine-tune on a small specific corpus. GPT-3 adopted it. All modern LLMs do it. It's not just a technique, it has become the standard way to build language models.
The Fundamental Problem: BERT Doesn't Generate
Despite its dominance, BERT has a major handicap: it can't generate text.
BERT is an encoder. You give it text, it returns embeddings (vector representations) or a classification. It's perfect for: understanding text, classifying an email as spam/not spam, extracting entities, answering questions about a document.
But asking BERT to write a paragraph, hold a conversation, or draft an email? Impossible by design. It's not autoregressive (it doesn't generate token by token).
GPT (decoder, autoregressive) generates text. And generation turned out to be the most transformative use case of AI.
Encoder vs Decoder: Who Won?
In 2018-2019, the debate was fierce: encoder (BERT) or decoder (GPT)?
In hindsight, the decoder won. Not because bidirectional attention is inferior (on the contrary, it captures context better). But because autoregressive generation enables scaling toward emergent capabilities that pure encoders don't develop.
The larger you make an autoregressive model, the more capable it becomes of new things (reasoning, code, math). Encoders like BERT, even very large ones, remain limited to the comprehension tasks they're fine-tuned for.
BERT is still used today for embeddings (transforming text into vectors for semantic search) and classification. But GPT and its successors reign supreme over text generation, which has become the dominant use case for LLMs.
BERT = encoder = comprehension and classification. GPT = decoder = text generation. This initial architectural choice determined the possible use cases. And generation dominates modern LLMs. BERT blazed the trail, but GPT conquered the territory.