MODELCATALOG

Understand the architecture behind BERT, GPT and modern LLMs.

NLP / Transformers / Advanced

10. Transformer Architecture

Understand the architecture behind BERT, GPT and modern LLMs.

01 Learning objectives

By the end of this module, you should be able to explain the concept in plain language, connect it to a use case, and recognize when it is — and is not — appropriate.

  1. Objective 1

    Understand multi-head attention, feed-forward blocks, residuals and normalization.

  2. Objective 2

    Understand positional information.

  3. Objective 3

    Distinguish encoder-only, decoder-only and encoder-decoder models.

02 Transformer block

A Transformer replaces recurrence with attention-based processing. Major ingredients:

  • token embeddings,
  • positional information,
  • multi-head self-attention,
  • feed-forward network,
  • residual connections,
  • normalization.

03 Why multiple heads?

Different attention heads can learn different relationships, such as local syntax, long-range dependencies or entity relationships.

04 Model families

  • Encoder-only: representation/understanding tasks; BERT-style.
  • Decoder-only: autoregressive generation; GPT-style.
  • Encoder-decoder: source-to-target generation; T5-style/translation-style.

05 Pitfalls and nuances

These are the mistakes most likely to create a wrong mental model or a weak implementation.

  1. Pitfall 1

    Assuming 'Transformer' and 'LLM' are synonyms.

  2. Pitfall 2

    Forgetting that sequence position must be encoded somehow.

  3. Pitfall 3

    Assuming bigger context windows guarantee good use of all context.

06 Checkpoint questions

Try answering these without looking back at the module. If the explanation is clear in your own words, you are ready to continue.

  1. Check 1

    Why does a Transformer need positional information?

  2. Check 2

    Which family is naturally suited to next-token generation?