Publications

BERT and the Bidirectional Pretraining Turn

By Satwik ยท January 27, 2026

BERT showed that a single deeply bidirectional encoder pretrained on unlabeled text could be fine-tuned to dominate a broad slate of language tasks. It reframed NLP around transferable representations and set the template that scaling would later inherit.

The problem BERT solved

Before 2018, most strong NLP systems learned representations that were either shallow or one-directional. Word embeddings like word2vec and GloVe gave each token a fixed vector regardless of context, so "bank" in "river bank" and "savings bank" shared one meaning. Contextual models like ELMo improved on this by reading text left-to-right and right-to-left with separate LSTMs, then concatenating the results. The left-to-right generative models that preceded GPT could only condition on prior tokens. None of these approaches let a single representation of a word attend jointly to everything on both sides of it at every layer.

BERT, from Google AI, closed that gap. It was a Transformer encoder trained so that the representation of every token could depend, at every layer, on the full left and right context simultaneously. That property, deep bidirectionality, is what the name encodes: Bidirectional Encoder Representations from Transformers.

The masked language modeling trick

The obstacle to true bidirectionality is trivial to state. If you train a model to predict the next word and also let it see the next word, the task collapses; the model just copies. Bidirectional conditioning and next-token prediction are incompatible.

BERT's answer was the masked language model objective. During pretraining, roughly fifteen percent of tokens are corrupted, and the model must reconstruct the originals from surrounding context. Most masked positions are replaced with a special MASK token, a smaller fraction are swapped for a random word, and the remainder are left unchanged. That mixture matters: because MASK never appears at fine-tuning or inference time, always masking would create a train-test mismatch, so the random-and-unchanged cases force the model to build robust representations for every position rather than only the visibly corrupted ones.

A second objective, next sentence prediction, trained the model to judge whether two segments were consecutive in the source text, with the aim of teaching discourse-level relationships useful for tasks like question answering and inference. Later work, notably RoBERTa, showed this objective was largely unnecessary and that simply training longer on more data with larger batches recovered or exceeded the gains. That finding is itself instructive: an auxiliary objective that seemed principled turned out to be a weaker lever than raw scale and optimization care.

Why it mattered

BERT's practical impact came from the fine-tuning recipe. One pretrained model could be adapted to sentence classification, named entity recognition, question answering, and textual entailment by adding a thin task-specific head and updating all weights on a modest labeled set. It set new records across the GLUE benchmark suite, the SQuAD question answering datasets, and more, often by wide margins, using the same backbone each time.

This consolidated a shift already underway: the field moved from bespoke architectures per task to a two-stage paradigm of expensive unsupervised pretraining followed by cheap supervised adaptation. Representations became the product. The engineering center of gravity moved toward the pretraining corpus, the optimization procedure, and model size, the same variables that scaling laws would soon formalize.

BERT also seeded an ecosystem. Distilled variants such as DistilBERT, multilingual versions, and domain-specific descendants for biomedical and legal text made the approach deployable well beyond research. For years, an encoder in the BERT family was the default first thing to try for a new classification or retrieval problem.

The security and safety angle

BERT is an encoder, not a generator, so it does not carry the open-ended misuse profile of models that produce fluent text on demand. But it introduced risks that remain central to AI security today.

The first is inherited bias. Because the representations absorb statistical regularities from a large web-scale corpus, they encode social stereotypes present in that text. A resume screener or toxicity filter built on these embeddings can silently propagate those correlations into consequential decisions, and the harm is harder to audit than a hand-written rule.

The second is the supply-chain surface. The whole point of the paradigm is that thousands of downstream systems reuse a handful of pretrained checkpoints downloaded from public hubs. That concentration is efficient and also a target. A poisoned or backdoored checkpoint, or one subtly altered so that a trigger phrase flips a classifier, propagates to every consumer who trusts it without verification. The lesson generalizes directly to today's foundation models: when representation learning is centralized, provenance, integrity checking, and evaluation of upstream artifacts become genuine security controls rather than hygiene. BERT was the moment that pretrained weights became critical infrastructure.