Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Attention and Transformers from Scratch
Rating: 1.0 out of 5(1 rating)
10 students

Attention and Transformers from Scratch

From RNN Seq2Seq to Bahdanau and Luong attention to a full Transformer — built, trained and explained in PyTorch
Created byOC OC
Last updated 8/2026
English

What you'll learn

  • Explain the fixed-context-vector problem of RNN Seq2Seq models and measure it yourself
  • Derive additive (Bahdanau) and multiplicative (Luong) attention and implement both in PyTorch
  • Read 'Attention Is All You Need' and map each component to code
  • Implement positional encoding, masking, multi-head attention, Add & Norm and feed-forward blocks
  • Assemble, train and use a complete Transformer for translation and inspect its cross-attention

Course content

8 sections • 28 lectures • 3h 23m total length
  • What AI can do with language3:56
  • Why attention?4:07
  • The NLP engineer roadmap5:24

Requirements

  • A computer with Python 3.10+ (a free Google Colab account is enough for most sessions)
  • Comfort reading Python code; you do not need to be an expert
  • Basic PyTorch and an idea of what an RNN does

Description

This course contains the use of artificial intelligence.

The voice-over in this course is synthesized with a text-to-speech model from scripts written and reviewed by the instructor, and the on-screen material (notebooks, code, slides) is the instructor's own work.


Attention is the idea behind every modern language model, and it was invented to solve one concrete problem: a sequence-to-sequence model squeezes a whole sentence into one fixed vector, and long sentences fall apart. This course starts from that problem and builds all the way up to a working Transformer.


We begin with what language models can do and the roadmap of an NLP engineer. Then we implement an RNN Seq2Seq model in PyTorch and measure its limits: the fixed context vector, what a wider hidden state does and does not fix. We derive the attention mechanism in depth — the core idea, the alignment weights, Bahdanau's additive attention — and implement Bahdanau and Luong attention with alignment visualisations. Next we read "Attention Is All You Need" section by section: self-attention, multi-head attention, positional encoding, feed-forward blocks, encoder and decoder. Finally we assemble a Transformer from parts — positional encoding, masking, multi-head attention, Add & Norm, encoder and decoder layers — train it, translate with it, and inspect cross-attention.


Theory sessions use slides; implementation sessions show the notebook on screen while the narration explains every cell. Small models that train in minutes, full understanding of what each line does.

Who this course is for:

  • Developers who use Transformers and want to understand the mechanism
  • Students starting NLP or preparing for deep-learning interviews
  • Engineers who want to build a Transformer from parts rather than import one