Decoder
What is Decoder?
In one sentence: A decoder is the part of a model that produces output, one piece at a time, such as writing a sentence word by word.
What does Decoder look like?
When a chatbot types out its answer word by word, a decoder is generating each next token.
Why does Decoder matter?
Most popular chatbots today are decoder-only models.
Decoder vs. Encoder
An encoder reads an entire input bidirectionally to build rich understanding (embeddings/classification), while an autoregressive decoder reads left-to-right to generate new tokens.
| Dimension | Decoder | Encoder |
|---|---|---|
| Attention direction | Causal—only sees earlier tokens | Sees words both before and after at once |
| Best at | Chat, writing, coding, open-ended generation | Embeddings, search reranking, classification |
| Classic family | GPT, Llama, Claude | BERT, RoBERTa |
Last updated · Fact-checked by The AI Math
Linking to this page from a lesson or article? <a href="https://getaimath.com/dictionary/decoder/">Decoder, explained simply</a> (The AI Math Dictionary)