Advanced level · Module 6: Transformer Architecture and Modern NLP · Lesson 1 of 4
Inside the Transformer
Learners connect self-attention to the full transformer block (multi-head attention, feed-forward layers, residual connections, layer normalisation and positional information) and the three model families.
In this lesson you will
- Describe the parts of a transformer block
- Distinguish encoder-only, decoder-only and encoder-decoder models
Key concepts
transformer blockpositional encodingresidual connection and layer normencoder-only (BERT-style)decoder-only (GPT-style)encoder-decoder (T5-style)
The lesson
A transformer block applies multi-head self-attention and then a feed-forward layer, each wrapped with a residual connection and layer normalisation. Because attention ignores order, positional information (fixed sinusoidal or learned position embeddings) is added to the token embeddings.
Encoder-only models (the BERT family) read the whole text in both directions and suit classification, NER and extractive QA. Decoder-only models (the GPT family) predict the next token and suit generation. Encoder-decoder models (T5, BART, NLLB) map input to output and suit translation and summarisation.
These models are pretrained on very large text collections and then adapted. Their strengths and weaknesses follow their pretraining data, which is mostly English and other widely used languages.
Step by step
- Draw a transformer block and label each part.
- Classify five tasks by the best model family.
- Read the abstract and architecture figure of 'Attention Is All You Need'.
- Explain why positional information is needed.
Practice activity
Produce an annotated transformer diagram and a task-to-model-family table.
Expected result: A correct diagram and sensible task mapping.
Check your understanding
-
Which model family suits extractive question answering?
Show answer
Encoder-only models.
-
Why do transformers need positional information?
Show answer
Self-attention by itself does not know token order.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.