Definition

Transformer

A Transformer is a neural network architecture built from attention, feed-forward layers, and residual connections. It uses position information to represent the order of inputs. The original design has an encoder and decoder, while many language models use the decoder alone. Dense self-attention considers a number of position pairs that grows quadratically with sequence length.

Estimate how the number of attention pairs grows

An unmasked attention head over 256 positions makes a score for each of 65,536 query–key pairs. At 512 positions, there are 262,144 pairs, four times as many. This calculation describes dense attention scores for one head. Memory use and measured runtime also depend on masking, kernel implementation, hardware and the rest of the model.

Transformer architecture and attention complexity

Intelligence at Scale by Shashank Agarwal

Transformer diagram from Intelligence at Scale
Diagram from chapter 3, Attention Is All You Need

Explained in

Chapter 3: Attention Is All You Need Free

The paper behind every major AI model today. Google invented it. Then watched someone else ship it.

Related terms

This is one term. The chapter is the argument.

Intelligence at Scale: 22 chapters, 65,000 words, 80-plus diagrams. Kindle, paperback and hardcover on Amazon.

Buy on Amazon.com
← All terms