BERT
BERT (Bidirectional Encoder Representations from Transformers) is a pretrained language model released by Google in 2018. It runs self-supervised pretraining on massive text with a bidirectional Transformer encoder, then transfers to downstream tasks by fine-tuning. It set records on 11 natural language understanding benchmarks, moving NLP from "a separate network per task" to the unified "pretrain then fine-tune" paradigm.
Core Principles
BERT's backbone is the Transformer encoder, and its key design is bidirectional attention: each position sees the full context on both sides at once, unlike GPT's unidirectional left-side view. The input sums token (WordPiece), position and segment embeddings; the final hidden state of [CLS] often serves as the sentence representation, and [SEP] separates sentence pairs.
Pretraining has two tasks. The masked language model (MLM) hides about 15% of input tokens and asks the model to predict them from bidirectional context; of the masked positions, 80% become [MASK], 10% a random token and 10% stay unchanged, easing the input-distribution gap between pretraining and fine-tuning. Next sentence prediction (NSP) judges whether the second sentence truly follows the first, to learn inter-sentence relations. Later work such as RoBERTa found NSP of limited value, and removing it worked better.
The paradigm freed linguistic knowledge from labeled data: tasks that once needed thousands to hundreds of thousands of samples now need only hundreds to a few thousand for fine-tuning close to a task-specific model. Two versions were released: BERT-Base with 12 layers, 768 hidden dimensions and 12 heads (about 110M parameters), and BERT-Large with 24 layers, 1024 dimensions and 16 heads (about 340M). The corpus was BooksCorpus (about 800M words) plus English Wikipedia (about 2.5B words).
Key Points
Fine-tuning paradigm: a downstream task only adds a lightweight output layer, with full fine-tuning at a small learning rate; the gain is clearest on low-data tasks.
Chinese version: Google's BERT-Base Chinese splits by character, while Chinese RoBERTa uses whole word masking so a word is not split into separately masked characters, which is more robust. The Chinese-BERT-wwm series from Harbin Institute of Technology and iFlytek is widely used in China.
Derivative lineage: RoBERTa dropped NSP and enlarged data and steps; ALBERT cut parameters to about one tenth via sharing; DistilBERT shrank 40% through distillation while keeping about 97% of performance; ELECTRA switched to replaced-token detection for higher efficiency.
Limitations: as a pure encoder without autoregressive decoding, BERT is weak at open-ended generation; position embeddings cap at 512 tokens, so long documents need chunking or sparse-attention variants like Longformer and BigBird; MLM inputs contain [MASK] while inference does not, leaving a distribution gap.
Common Misconceptions
Misconception one: treating BERT as a general generative model. It is an understanding model; generation needs a decoder such as GPT or an encoder-decoder like BART and T5. Misconception two: reading bidirectional as predicting all words at once; MLM predicts only the masked 15%, with the rest as context, and masking everything makes the task uninformative. Misconception three: assuming the [CLS] vector is naturally a good sentence vector; without contrastive training it often loses to simple mean pooling on semantic similarity.
Application Scenarios
Text classification and sentiment analysis, named entity recognition, question answering and reading comprehension, semantic similarity and retrieval ranking, intent recognition and slot filling, legal and medical extraction, search reranking, sensitive content moderation, and text correction and grammar checking.