Robots Atlas>ROBOTS ATLAS
Architecture

BERT

2018ActivePublished
Key innovation
Introduced deep bidirectional language representations by pre-training a Transformer encoder with Masked Language Modeling, enabling a single model to be fine-tuned across many NLP tasks with minimal architectural changes.
Category
Architecture
Abstraction level
Pattern
Operation level
ModelTrainingPost-training
Use cases
Text classification and sentiment analysisNamed Entity Recognition (NER)Question Answering (SQuAD)Natural Language InferenceSemantic search and rerankingSentence-pair classificationBackbone encoder for downstream NLP

How it works

1) WordPiece tokenization splits text into subwords; [CLS] is prepended (used as aggregate sequence representation) and [SEP] separates segments. 2) Each token's input is the sum of three embeddings: token, segment (A/B), and positional. 3) The sequence passes through a stack of Transformer encoder layers (12 or 24), each with Multi-Head Self-Attention without causal masking (attention is bidirectional) plus a feed-forward sublayer, both with residual connections and layer normalization. 4) Pre-training: ~15% of tokens are masked (of which 80% replaced with [MASK], 10% with a random token, 10% kept) and the model predicts the original (MLM); concurrently the model classifies whether sentence B follows sentence A (NSP). 5) Fine-tuning: a small task head is added (e.g. linear over the [CLS] representation for classification, or span prediction over all token outputs for QA), and the whole model is trained end-to-end with a small learning rate.

Problem solved

Earlier language models (LSTM-LM, ELMo, GPT-1) were either unidirectional or merely concatenated two independent unidirectional models, which limited contextual word representation quality. There was also no universal pre-trained model that, after fine-tuning, would achieve top performance across many diverse NLP tasks without bespoke architectures.

Components

Transformer Encoder StackProduces contextual token representations conditioned on full bidirectional context.

Stack of 12 (Base) or 24 (Large) identical Transformer encoder layers, each with Multi-Head Self-Attention and a feed-forward sublayer.

WordPiece TokenizerSplits text into subwords, mitigates OOV problem.

Subword tokenizer with a vocabulary of ~30,000 pieces.

Token / Segment / Position EmbeddingsRepresent token identity, segment (A/B) membership, and position in the sequence.

Three learned embedding tables summed as input to the encoder.

[CLS] Token HeadAllows fine-tuning to perform classification with a single linear layer.

Special token prepended to the sequence whose final hidden state aggregates the whole sequence for classification tasks.

MLM HeadImplements the MLM objective during pre-training.

Output layer with weights tied to the embedding table, used in pre-training to predict masked tokens.

Implementation

Implementation pitfalls
512-token limitHigh

Positional embeddings are learned and capped at 512 positions; longer documents require chunking, sliding-window approaches, or long-context variants (Longformer, BigBird).

Fix:Use sliding window with overlap, hierarchical aggregation, or a long-context model.
Mismatch between pre-training and generationMedium

BERT is a bidirectional encoder — unsuited for autoregressive text generation; use decoder-only (GPT-like) or seq2seq (T5, BART) models for generation instead.

Weakness of Next Sentence PredictionLow

Later work (RoBERTa, ALBERT) showed NSP has little or negative effect; prefer NSP-free variants or improved objectives (e.g. Sentence-Order Prediction in ALBERT).

[MASK] mismatch between pre-training and fine-tuningLow

The [MASK] token appears only during pre-training, not fine-tuning — the authors mitigate this with the 80/10/10 scheme. Awareness matters when modifying the pre-training recipe.

Evolution

Original paper · 2018 · Jacob Devlin
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Jacob Devlin, Ming-Wei Chang, Kenton Lee, Kristina Toutanova
2018
Original BERT paper published
Inflection point

Devlin et al. release BERT on arXiv (October 2018) with Base/Large models and TensorFlow code.

2019
RoBERTa — improved pre-training recipe

Facebook AI shows BERT was undertrained; removing NSP, larger batches, and more data yields substantially better results.

2019
DistilBERT — distillation-based compression

Hugging Face introduces DistilBERT — 40% smaller, 60% faster, preserving 97% of BERT-Base quality.

2019
ALBERT — parameter sharing and SOP

Google introduces ALBERT with cross-layer parameter sharing and replaces NSP with Sentence-Order Prediction.

2020
ELECTRA — more efficient pre-training objective

The 'replaced token detection' objective proves more sample-efficient than MLM.

2019
BERT deployed in Google Search
Inflection point

Google announces BERT in production for query understanding — one of the largest single quality changes in Search history.

Hyperparameters (configurable axes)

Number of layersCritical

Depth of the encoder stack. BERT-Base: 12, BERT-Large: 24.

12BERT-Base
24BERT-Large
Hidden size (d_model)Critical

Internal representation dimensionality. Base: 768, Large: 1024.

768BERT-Base
1024BERT-Large
Number of attention headsHigh

Base: 12, Large: 16.

Max sequence lengthHigh

BERT uses a fixed length of 512 tokens (limit of learned positional embeddings).

512Standard BERT
WordPiece vocabulary sizeMedium

Standard vocabulary is 30,522 (uncased) or 28,996 (cased) tokens.

MLM mask probabilityHigh

15% of tokens selected for MLM; of those 80% replaced with [MASK], 10% with random tokens, 10% kept unchanged.

Computational complexity

Time complexity: O(L · n² · d). Space complexity: O(L · n² + n · d + L · d²).

Execution paradigm

Primary mode
Dense

All parameters are active for every input (dense forward pass), with no routing or sparsity.

Activation pattern
All paths active

Parallelism

Parallelism level
Fully parallel

Self-attention and FFN are fully parallel across tokens within a layer; no recurrence (unlike RNN/LSTM).

Scope
TrainingInferenceAcross tokensAcross layers

Hardware requirements

Primary

Operations are dense matrix multiplications (GEMMs) ideal for tensor cores; FP16/BF16 mixed precision delivers significant speedup.

Primary

The original BERT was pre-trained on Google TPUs; the architecture maps well to systolic MMUs.