AI Glossary / Natural language and speech / Intermediate

Encoder-decoder

Definition

An encoder-decoder is a model architecture in which an encoder represents an input and a decoder uses that representation to produce an output. In sequence-to-sequence language tasks, the input and output can have different lengths and word orders. Translation and summarization are common examples of tasks that can use this design.

What it means

The encoder turns the input into representations useful for the task. The decoder conditions its output on those representations, often generating a sequence one token at a time.
The names describe complementary roles rather than one mandatory implementation. Recurrent networks, transformers, and other suitable architectures can serve these roles. A simple design may pass one fixed context vector; attention-based designs can let the decoder access multiple input representations during generation.
An encoder-decoder does not necessarily compress the source without loss or reconstruct it exactly. The intended output depends on the training task: a translation, a summary, or another representation may be appropriate.

How it works

Process the input through the encoder to obtain contextual representations. The decoder then predicts the output according to its architecture and conditioning mechanism.
In an autoregressive version, each next-token distribution depends on the encoded input and the preceding output tokens. Generation continues until a stopping condition, such as an end-of-sequence token, is reached.
Training commonly compares predicted output distributions with target sequences and adjusts parameters using the task loss. During teacher-forced training, prior target tokens may be supplied to the decoder; during generation, it must use its own selected tokens. This difference matters when evaluating complete outputs rather than isolated next-token predictions.

Three practical examples

  • A translation model encodes a source sentence and decodes a target-language sentence with a different word order.
  • A summarizer encodes a report and produces a shorter sequence expressing its main content.
  • A speech-recognition architecture encodes acoustic features and decodes a text sequence, with input frames and output tokens having different lengths.

Think of it this way

Think of one stage preparing a structured briefing and another composing the requested response from that briefing. The analogy captures the division of roles. It is limited because learned representations are numerical, may be imperfect, and need not correspond to human-readable notes or preserve every source detail.

Worked example

Consider an invented summarization input: “The workshop moved from Room 2 to Room 5 because the projector in Room 2 failed.” A desired short output is “Workshop moved to Room 5 after projector failure.”
The encoder represents the whole input, including the old location, new location, and stated reason. The decoder produces a shorter sequence rather than returning one output token for every source token.
For an autoregressive model, the prediction after “Workshop moved to Room” should depend on both the source representation and the output prefix. The two room numbers appear in the source, so merely noticing that “2” and “5” occur is insufficient; the model must preserve their different roles.
If it generates “Room 2,” the output can remain fluent while reversing the practical update. This demonstrates why architecture alone does not establish faithfulness. Evaluation must check the complete result against the input, including entities, roles, and qualifications. The example illustrates an intended mapping and an error mode, not measured model behavior.

Illustrative case study

Fictional case: SummaryStudio compares an encoder-decoder prototype on internal event notices. A token-level training metric improves, but reviewers find several generated summaries that confuse previous and revised locations.
The team adds complete-output examples to its evaluation and checks whether dates, locations, and reasons are preserved. It also documents whether the decoder attends over input representations or receives a single fixed context.
The resulting report separates architecture description, training objective, and observed output quality. This fictional case illustrates why a technically correct model description is not a substitute for task-level verification; it makes no claim about production accuracy or a guaranteed benefit from one attention design.

Common misconceptions and mistakes

Do not assume every encoder-decoder passes just one fixed vector. Attention-based versions can use a sequence of encoded representations.
Do not equate “decoder” here with reversing an encryption scheme or recovering the input exactly. The task defines what should be generated.
Avoid assuming that a fluent output is faithful to its source. Also distinguish a full encoder-decoder architecture from encoder-only or decoder-only models, even when those models can be adapted to related tasks.

Business use

The term helps teams understand how an AI system transforms one kind of input into another output. It is useful when comparing translation, summarization, and speech-processing designs.
A practical review should state what the encoder receives, what the decoder generates, and how the two are connected. It should also describe generation settings, stopping behavior, and task-level evaluation. These details affect latency and output quality, while the architectural label alone says little about whether a particular system meets the user's needs.

People also ask

Must input and output lengths match?

No. Sequence-to-sequence encoder-decoders can map between sequences of different lengths.

Are encoder-decoders always recurrent networks?

No. Recurrent networks and transformers are among the possible implementations.

Does the encoder guarantee complete understanding of the source?

No. It produces learned representations for the task, and the resulting output still needs evaluation for accuracy and faithfulness.

Check your understanding

A summary model outputs the old meeting location instead of the revised one, although both locations occur in the source. Does mentioning a source-supported room number make the summary correct?

Answer: No. The model must preserve the number's role in the update. Copying a genuine source token can still produce a false overall statement.

Related terms

  • Encoder
  • Decoder
  • Attention
  • Teacher forcing
  • Machine translation
  • sequence-to-sequence model
  • autoregressive generation
  • contextual representation

Learn next

Trace how one input sentence conditions a short generated output. Compare a fixed-context recurrent model with an attention-based encoder-decoder, then inspect errors where fluent generation loses a source relationship rather than simply inventing a word.

  • Attention

More in Natural language and speech

  • Effect size - Effect size is a numerical description of how large a difference or association is.
  • Elman Networks - Elman networks are simple recurrent neural networks that feed the previous hidden state into the computation of the next hidden state.
  • Emission probabilities - Emission probabilities describe how likely particular observations are given a hidden state in a probabilistic model such as a hidden Markov model, or HMM.
  • End-to-end training - End-to-end training uses a downstream task objective to adjust parameters across a connected model, including earlier representation-building components.
  • Endpointing - Endpointing is deciding when a spoken utterance or input segment is complete enough for a speech system to finalize recognition or move to its next action.
  • Energy in frame - Energy in a frame is a measure of signal strength over a short segment of audio.

Sources

Sources: Jurafsky and Martin, Speech and Language Processing, RNNs and LSTMs, encoder-decoder and attention sections: https://web.stanford.edu/~jurafsky/slp3/14.pdf ; Machine Translation: https://web.stanford.edu/~jurafsky/slp3/13.pdf Independently checked the recurrent encoder-decoder, teacher-forcing and attention passages, plus the translation chapter’s transformer cross-attention formulation.

Previous: Encoder Next: Encoder models

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer