What is the primary objective of an encoder-decoder architecture used for sequence-to-sequence (seq2seq) tasks, such as machine translation?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Seq2seq architectures exist for one core reason: real-world tasks like translation don't have a neat one-to-one length match between input and output. A five-word English sentence might become a seven-word French sentence. The encoder reads the whole input sequence and builds up a representation, and the decoder then generates an output sequence of whatever length makes sense, one token at a time. That flexible variable-length-in, variable-length-out mapping is the whole point, so it's the correct answer. Classifying a sequence into one single label is a totally different task, more like sentiment analysis, not sequence generation. A decoder is absolutely required — without it you'd have no way to produce an output sequence at all. And there's no rule that output length must match input length; that's precisely the flexibility seq2seq is designed to provide.
Full explanation below image
Full Explanation
The primary objective of an encoder-decoder (sequence-to-sequence) architecture is to learn a mapping from an input sequence of one length to an output sequence of a potentially different length, without requiring a fixed, predetermined alignment between input and output positions. This is essential for tasks like machine translation, where a source sentence in one language may have a different number of tokens than its translation in the target language, or summarization, where a long input document maps to a much shorter summary. The encoder processes the entire input sequence and compresses it into an internal representation, historically a single fixed-length context vector in early RNN-based seq2seq models, and more recently a set of context-aware representations accessed via attention in Transformer-based models. The decoder then uses this representation to generate the output sequence one element at a time, conditioning each generated token on both the encoded input and the tokens it has generated so far, continuing until it produces an end-of-sequence signal, which naturally allows the output length to differ from the input length.
The first distractor, classifying an entire sequence into a single fixed category, describes a sequence classification task (such as sentiment analysis or topic classification), which typically uses an encoder alone (or an RNN/Transformer with a classification head) and produces one label per sequence, not a generated output sequence; this differs fundamentally from the generative, variable-length output objective of seq2seq models.
The second distractor, compressing input into a fixed-size vector with no decoder needed, describes only half of the architecture (the encoding step) and omits the decoder entirely; without a decoder, there is no mechanism to produce an output sequence at all, which defeats the purpose of a sequence-to-sequence task like translation.
The third distractor, guaranteeing the output sequence is always exactly the same length as the input, is incorrect and actually describes a constraint that seq2seq models are specifically designed to avoid; a defining strength of the encoder-decoder approach is that it does not require the input and output sequences to share the same length, since the decoder generates tokens autoregressively until it decides the sequence is complete.
Memory aid: think seq2seq as 'read the whole input first, then write out an appropriately-sized output,' which is exactly why it works for translation, summarization, and transcription, tasks where the input and output naturally differ in length.