instibrain
instibrain  /  guides  /  how a model works  /  lesson 9
lesson 9 of 9 · how a model works

Kinds of models: one design, three last steps.

Nearly every model that reads or writes language is one design, the transformer. What differs is its last step and its training.

new words

Transformer
The design of lessons 3 to 6: an embedding matrix, layers of attention and feed-forward, and a last step. Published in 2017.
Decoder
A transformer that looks only back and writes the next token. Every chat model is one.
Encoder
A transformer that reads the whole text in both directions at once, to understand it, not to continue it.
Mixture of experts
A model whose feed-forward is split into experts, of which only a few run for each token.

the lesson

KindInOutFor
Chat model, a decodertextthe next token, again and againwriting answers; Claude is one
Embedding model, an encoderone textone vectorsearch by meaning
Reranker, an encodertwo texts togetherone scoreputting the best results first

An embedding model is trained on pairs of texts, so texts that mean the same land close: AI basics, lesson 4. A reranker reads the question and one passage together, which is slower and sharper than comparing two vectors: RAG, lesson 5. A retrieval system runs them in a row: the embedding model finds the chunks, and the chat model writes from them. An index belongs to its embedding model; vectors from two models cannot be compared.

VariationWhat changes
Reasoning modelReasoning training, lesson 7: it writes its working first, in thinking tokens.
Mixture of expertsA router picks a few experts for each token. Fewer weights run per token, and every expert still sits in memory.
MultimodalAn image is cut into small squares, and each becomes a vector in the same row as the text's tokens. A 224 × 224 image in 16 × 16 squares is 14 × 14 = 196 of them.

Not every model is a transformer. Most image generators are diffusion models, which turn noise into a picture step by step. A bank's fraud score is often classical machine learning, such as decision trees, with no layers at all. What reads or writes language today is nearly always a transformer.

Three kinds of transformer, by what goes in and what comes out.

try it

Type this and press Enter:

Which kind of model are you? Which kind would find, among 10,000 files, the ones that answer a question by meaning, and which would put the best five in order?

you should see

  • A chat model: a decoder that writes one token at a time.
  • An embedding model to find the candidates by meaning, and a reranker to put the best few in order.