Skip to content
Back to course

15.1 Transformers

Transformers are the neural network architecture that powers nearly every modern large language model. Unlike older recurrent networks (RNNs) that read text one word at a time, a Transformer looks at an entire sequence at once and uses a mechanism called self-attention to decide which words matter most to each other.

ThecatsatThecatsat
A Transformer block: tokens flow through self-attention and feed-forward layers.

Imagine translating an Amharic news headline into English. A Transformer can simultaneously weigh the subject, the verb and the object across the whole sentence, rather than forgetting the beginning by the time it reaches the end. This parallel processing is also why Transformers train so fast on modern GPUs.

Scenario

Your team must process very long documents quickly on GPUs. Why might a Transformer be a better fit than an RNN?

Check your understanding

1/4 · 40 XP

What core mechanism lets a Transformer relate words across a sentence?