liveBook · Manning

BERT

As explained in Build a Large Language Model (From Scratch)

A transformer-based model built on the encoder stack and trained for bidirectional masked-word prediction.

BERT (bidirectional encoder representations from transformers) is a transformer-based model built on the encoder stack. It predicts masked or hidden words using bidirectional context, making it especially useful for text classification. section 1.4

BERT differs from GPT in architecture, training objective, and typical applications:

  • Uses the transformer encoder rather than the decoder. section 1.4
  • Learns through masked-word prediction rather than text completion. section 1.4
  • Supports tasks such as sentiment prediction, document categorization, and toxic-content detection. section 1.4
Figure 1.5 A visual representation of the transformer’s encoder and decoder submodules. On the left, the encoder segment exemplifies BERT-like LLMs, which focus on masked word prediction and are primarily used for tasks like text classification. On the right, the decoder segment showcases GPT-like LLMs, designed for generative tasks and producing coherent text sequences.
figure

Compare the encoder segment associated with BERT-like models with the decoder segment associated with GPT-like generative models. section 1.4

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Defines BERT’s encoder basis and training objective, while deferring self-attention implementation and input preprocessing details.
Examples
Uses masked sentences, sentiment prediction, document categorization, and toxic-content detection as concrete examples.
What it assumes
Assumes familiarity with transformer encoder-decoder structure while postponing detailed self-attention and input preprocessing.
What you can do after
Apply it via text classification for sentiment, document categorization, or toxic-content detection.
How it connects
Connects BERT to transformer architecture, encoder-decoder models, self-attention, GPT, and text classification.

Also explained in

Compare how 9 books explain BERT →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.