techtree / Transformer

What is a transformer?

The whole machine, end to end.

46 seconds

text→tokens→vectors→blocks→softmax→next token\text{text} \to \text{tokens} \to \text{vectors} \to \text{blocks} \to \text{softmax} \to \text{next token}
Transcript

A transformer takes in text, chops it into tokens, and looks up a vector for each one, with its position added.

The vectors rise through a stack of blocks. In each block, attention lets the tokens share information, and an MLP works on each token by itself.

At the top, the last vector becomes a score for every token in the vocabulary. Softmax makes them probabilities, and one token is picked.

It is added to the text, and the whole machine runs again.

All of its skill lives in its weights: the embedding table, the attention matrices, and the MLPs.

Text in. One token out. Again and again. That is a transformer.