Context and applications / 6 of 7

Encoder, decoder, and encoder-decoder models

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Encoder, decoder, and encoder-decoder models” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

Transformer families differ in how positions can use context. Encoders commonly read both sides of an input. Causal decoders read only prior positions. Encoder-decoder models transform an input sequence into an output sequence.

Language varies by speaker, setting, and purpose. A text representation is useful only in relation to a task. Keep the original source when possible so you can inspect what preprocessing discarded. English performance does not establish Indonesian performance, especially for slang, dialect, or mixed-language inputs.

Under the hood

An encoder representation supports tasks such as classification and retrieval. A decoder supports autoregressive generation. Cross-attention in an encoder-decoder lets output positions attend to encoded input features.

A useful caution

The architecture name alone does not determine quality for a particular language or task.

A worked example

Translation can encode a source sentence then generate a target sentence. Search can encode a query and documents into comparable vectors.

How to use this way of thinking

Trace text through normalization, tokenization, representation, and prediction. Include language variation in evaluation and inspect examples that share words but differ in meaning. For generated language, assess faithfulness and task success separately from grammatical fluency.

Try it yourself

Choose a model role for document retrieval and one for drafting an answer.

Key takeaways

  • An encoder-decoder model
  • The architecture name alone does not determine quality for a particular language or task.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1Which model commonly uses cross-attention to a separate source representation?
2True or false: An encoder-decoder can use cross-attention to connect outputs with encoded inputs.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Hugging Face NLP course (opens a new tab)Attention Is All You Need (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close