The pattern behind translation, summarization, code generation
Some tasks map one sequence to another of different length: translation (English → Korean), summarization (article → abstract), code generation (description → code). These follow the encoder-decoder pattern.
The encoder reads the entire input sequence and produces a context representation (typically a sequence of hidden states). The decoder generates output token by token, conditioned on both the encoder context (via cross-attention) and the tokens it has already generated (via self-attention).
For production 2026: don't implement seq2seq from scratch unless you're doing research. KerasHub provides T5, BART, and Whisper pretrained with a one-line load. Fine-tune them on your task; the architectural details are handled.