# Encoder

- **Canonical URL:** https://getaimath.com/dictionary/encoder/
- **Topics:** [LLM Fundamentals](https://getaimath.com/dictionary/category/llm-fundamentals/)
- **Last updated:** 2026-11-25

## What is Encoder?

**In one sentence:** An encoder is the part of a model that reads an input and turns it into a set of numbers that capture its meaning.

Think of an encoder as a really good note-taker. It reads a sentence, picture or sound and writes compact "notes" in the form of numbers. Other parts of the system, or other tasks like search, can then use those notes. Encoder-only models like BERT are great at understanding but not at writing long text.

![How ChatGPT & Claude Talk: Super-Powered Autocomplete — Simple cartoon diagram showing a sentence chopped into Lego word blocks (tokens), an AI brain weighing the odds of the next word ("mat" 75%, "couch" 18%, "roof" 5%), and snapping "mat" onto the end of the sentence.](https://getaimath.com/diagrams/llm-fundamentals.png)
*Napkin Diagram (LLM Fundamentals): Language models don’t plan whole essays at once—they play a super-smart game of "guess the very next word" over and over.*

## What is an example of Encoder?

A search engine might use an encoder to turn your question into numbers so it can find pages with similar meaning.

## Why does Encoder matter?

Encoders power search, classification and the "understanding" part of many AI systems.

## Encoder vs. Decoder

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 | Encoder | [Decoder](https://getaimath.com/dictionary/decoder/) |
| --- | --- | --- |
| Attention direction | Sees words both before and after at once | Causal—only sees earlier tokens |
| Best at | Embeddings, search reranking, classification | Chat, writing, coding, open-ended generation |
| Classic family | BERT, RoBERTa | GPT, Llama, Claude |

## Related Concepts

- [GPT (Generative Pre-trained Transformer)](https://getaimath.com/dictionary/gpt-generative-pre-trained-transformer/): GPT stands for Generative Pre-trained Transformer, a family of language models by OpenAI that generate text after being pre-trained on huge amounts of data.
- [Decoder](https://getaimath.com/dictionary/decoder/): A decoder is the part of a model that produces output, one piece at a time, such as writing a sentence word by word.
- [Transformer](https://getaimath.com/dictionary/transformer/): A Transformer is a type of neural network design that reads all the words in a passage at once and works out how they relate, using attention.
- [Encoder-Decoder Architecture](https://getaimath.com/dictionary/encoder-decoder-architecture/): An encoder-decoder architecture is a model design with two parts: one that reads and understands the input, and one that writes the output.
- [Language Model](https://getaimath.com/dictionary/language-model/): A language model is an AI that learns how language works so it can predict or produce words and sentences.
- [Autoregressive Model](https://getaimath.com/dictionary/autoregressive-model/): An autoregressive model creates output one piece at a time, using everything it has created so far to choose the next piece.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/encoder/)
