liveBook · Manning

BERT

As explained in Deep Learning with Python, Third Edition

A pretrained bidirectional Transformer encoder model for language understanding, used here as an NLP example rather than a generation model.

BERT is a pretrained bidirectional Transformer encoder for building rich representations of input text. Every position can attend to tokens before and after it, making BERT useful for language understanding rather than generation in a loop. section 15.4.1

Masked language modeling

To pretrain BERT, replace roughly 15% of tokens in a text sequence with [MASK]. The model predicts the original tokens from their surrounding context. This unsupervised setup requires no labels and can use large text collections such as Wikipedia. section 15.4.1

Keep these distinctions in mind:

  • BERT predicts masked tokens from both directions; a causal language model predicts each token from preceding tokens. section 15.4.1
  • Pretraining the entire Transformer produces context-sensitive word embeddings, rather than fixed embeddings independent of surrounding words. section 15.4.1

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains encoder directionality, masked-token training, unsupervised data collection, and contextual embeddings without detailing implementation internals.
Examples
Demonstrates masking roughly 15% of tokens, predicting replacements from surrounding text, and pretraining on Wikipedia.
What it assumes
Assumes familiarity with Transformer encoders while defining bidirectional attention and masked language modeling.
What you can do after
Evaluate/understand when bidirectional masked-language modeling fits language-understanding tasks instead of autoregressive generation.
How it connects
Connects Transformer encoders, masked language modeling, causal language models, word embeddings, and NLP benchmarks.

Also explained in

Compare how 9 books explain BERT →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.