Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Glossary › Transformer

What is transformer?

A network built from repeated blocks of attention and an MLP, with residual connections and layer normalisation. The architecture behind GPT and most current language models.

Where it is taught

The transformer block. Attention moves information between tokens. Add an MLP, two normalisations and two shortcut connections, and you have the unit that a GPT repeats again and again.

What the lesson leaves you with

  • A block is attention then an MLP, each wrapped in a residual connection with layer normalisation.
  • Residual connections give gradients a direct path, so very deep stacks can be trained.
  • Size is set by the dimension, the number of blocks and the number of heads. The design does not change.
Open the lesson

Questions

What is transformer?
A network built from repeated blocks of attention and an MLP, with residual connections and layer normalisation. The architecture behind GPT and most current language models.
Where is transformer used in AI?
Attention moves information between tokens. Add an MLP, two normalisations and two shortcut connections, and you have the unit that a GPT repeats again and again.
What is the key idea to remember about transformer?
A block is attention then an MLP, each wrapped in a residual connection with layer normalisation.
Where can I learn transformer step by step?
In the lesson “The transformer block” in Gradient’s course on the maths behind AI, with interactive diagrams and questions.

See it in 3D on the blog

  • How does ChatGPT work? The maths for Class 108 min
  • How does attention work in transformers?3 min

Related terms

  • Attention
  • Attention head
  • Autoregressive
  • Byte-pair encoding
  • Causal mask
  • Context length