Learn AI Math

Encoder

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.

What does Encoder look like?

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.

DimensionEncoderDecoder
Attention directionSees words both before and after at onceCausal—only sees earlier tokens
Best atEmbeddings, search reranking, classificationChat, writing, coding, open-ended generation
Classic familyBERT, RoBERTaGPT, Llama, Claude

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.