Natural Language Processing · Advanced level

Advanced level · Module 4: Sequence-to-Sequence Architectures · Lesson 1 of 3

Encoder-Decoder Models

Learners study how an encoder compresses an input sequence into a state that a decoder uses to generate an output sequence, and why this design suits translation, summarisation and normalisation.

In this lesson you will

  • Describe encoder and decoder roles
  • Identify seq2seq tasks

Key concepts

encoderdecodercontext vector<sos> and <eos> tokensvariable-length output

The lesson

Many language tasks map one sequence to another of different length: translation, summarisation, spelling normalisation and converting free-text dates into a standard format. An encoder (for example a GRU) reads the input and produces a context vector; a decoder generates the output one token at a time, starting from <sos> and stopping at <eos>.

Training real translation models needs large parallel corpora and powerful hardware. To learn the mechanics on a laptop, this module uses a synthetic task: turning written dates such as '3rd of March 2026' or '03/03/26' into '2026-03-03'.

Synthetic data can be generated in unlimited amounts with a Python script, and correct answers are known exactly, which makes evaluation simple.

Step by step

  1. List five seq2seq tasks relevant to local organisations.
  2. Write a generator that produces 20,000 (written date, ISO date) pairs in varied formats.
  3. Split the pairs into training, validation and test sets.
  4. Build character vocabularies for input and output.

Practice activity

Generate and document the synthetic date-normalisation dataset.

Expected result: A varied dataset with clear splits and vocabularies.

Check your understanding

  1. What does the encoder produce?

    Show answer

    A representation (context) of the input sequence for the decoder.

  2. Why use a synthetic task here?

    Show answer

    It runs on a laptop and has exactly known correct answers.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.