Advanced level · Module 6 of 10 · 18 guided hours
Transformer Architecture and Modern NLP
Transformers for language: architecture, encoder-only, decoder-only and encoder-decoder families, subword tokenisation and its effect on low-resource languages, fine-tuning a small pretrained model, and the place of large language models.
Learning objectives
- Explain the transformer architecture and its model families
- Analyse subword tokenisation, including its cost for low-resource languages
- Fine-tune and evaluate a small pretrained transformer for a language task
Topics
- transformer blocks and positional information
- encoder-only, decoder-only and encoder-decoder models
- subword tokenisation (BPE, WordPiece, SentencePiece)
- the Hugging Face pipeline and Hub
- fine-tuning with Trainer
- large language models and their limits
Lessons
-
Lesson 1 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.
transformer blockpositional encodingresidual connection and layer normencoder-only (BERT-style)decoder-only (GPT-style)encoder-decoder (T5-style)
-
Lesson 2 Subword Tokenisation and Low-Resource Languages
Learners inspect how pretrained tokenisers split English, Juba Arabic and other text into subwords, and measure the extra cost and quality risks for under-represented languages.
subword tokenisationAutoTokenizertokens per word (fertility)vocabulary coveragecontext length cost
-
Lesson 3 Fine-Tuning a Pretrained Transformer
Learners fine-tune a small encoder model (DistilBERT-size) for the news or enquiry classification task with the Hugging Face Trainer on CPU or a free notebook GPU.
AutoModelForSequenceClassificationdatasets libraryTrainer and TrainingArgumentslearning rate and epochscompute budget
-
Lesson 4 Large Language Models in NLP Systems
Learners place large language models in the NLP toolbox: what they do well, how to evaluate them on NLP tasks and when a small task-specific model is the better choice. Prompting and RAG application building are covered in the AI programme.
zero-shot and few-shot classificationtask evaluation setshallucinationcost, latency and privacysmall vs large models
Practical activity
Measure tokenisation fertility across languages, fine-tune a small transformer for the classification task, and complete the model-choice comparison including an LLM baseline.
Expected outcomes
- Practical transformer skills on modest hardware
- Evidence-based choices about modern NLP models
Assessment
Notebook review of fine-tuning and fertility analysis (60%) and the model-choice recommendation (40%).
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.