3.5.8 · D5Sequence Models

Question bank — Encoder-decoder architecture

1,200 words5 min readBack to topic

True or false — justify

The context vector can store all information from an arbitrarily long input.
False — a fixed-size vector is an information bottleneck; long inputs (50+ tokens) lose detail, especially from early positions. This is exactly what attention fixes.
A basic seq2seq model requires the input and output to have the same length.
False — the whole point is variable-length mapping; encoding to one vector decouples input length from output length .
The encoder and decoder must be the same type of recurrent cell.
False — you can pair, say, an LSTM encoder with a GRU decoder; they only need to agree on the shape/interface of .
Teacher forcing is used at test/inference time as well as during training.
False — at inference there are no ground-truth tokens, so the decoder must feed its own predictions back (free-running). Teacher forcing only exists during training.
Taking the log of the sequence probability changes which output sequence is most likely.
False — is monotonically increasing, so the argmax over sequences is unchanged; log is used only for numerical stability and to turn products into sums.
Greedy decoding always returns the highest-probability full sequence.
False — greedy is locally optimal per step; a lower first-step token can lead to much higher-probability continuations, which beam search can recover.
The context vector is always literally the encoder's final hidden state .
False — that's the common default, but can be any function of the states (mean-pool, learned combination, etc.).
An encoder-decoder is basically an autoencoder.
False in general — an autoencoder reconstructs its input; seq2seq maps an input to a different target sequence (translation, summary), and lengths/vocabularies can differ.
Reversing the order of the input tokens can never affect the output.
False — the encoder recursion is order-dependent, so "I love AI" and "AI love I" produce different states and outputs.

Spot the error

"We initialise so the decoder ignores the input after step 1."
The decoder never re-reads the input, but flows forward through every decoder state via the recurrence, so its influence persists across all steps — it isn't "used up".
"Softmax over the vocabulary can output negative probabilities for rare words."
Impossible — and dividing by a positive sum keeps every value in ; they also sum to exactly .
"With teacher forcing the model learns to recover from its own mistakes."
Backwards — teacher forcing hides the model's mistakes by always feeding the correct previous token, causing exposure bias; the model never trains on its own error states.
"Beam search with beam width 1 is different from greedy decoding."
They are identical — keeping only one hypothesis per step is greedy decoding; beam search only differs when the width exceeds 1.
"The training loss maximises , so we should do gradient ascent."
The stated objective is a likelihood to maximise, but frameworks minimise the negative log-likelihood; you either negate it or ascend, not descend on the positive form.
"A 512-dim float vector obviously holds enough bits for any 50-word sentence."
No — 512 float32 numbers give only bits, while a length-50 sequence over a vocabulary needs bits; the compression is enormous.
"During decoding we always feed the true previous token ."
Only in teacher-forced training; at inference the true token is unknown, so the model feeds its own (the sampled/argmax prediction).

Why questions

Why take the log of the joint probability instead of using the raw product?
Multiplying many small probabilities underflows to zero in floating point; converts the product into a numerically stable sum and preserves the argmax.
Why is the decoder autoregressive rather than emitting all tokens at once?
Each token depends on what was already generated (); feeding back lets the hidden state carry that history so outputs stay coherent.
Why does seq2seq performance degrade sharply past ~20 words?
The single fixed-size becomes a bottleneck; long-range and early-sequence details get overwritten in the encoder's recurrence — motivating attention.
Why does the encoder use a recurrence instead of averaging the token embeddings?
Averaging discards order and long-range structure; the recurrence accumulates context sequentially so position and dependencies are encoded.
Why prefer softmax over just normalising raw scores by their sum?
Raw scores can be negative, and softmax's keeps everything positive while sharpening the distribution toward the largest logit — a valid, peaked probability.
Why does teacher forcing speed up early training?
Feeding ground-truth prefixes stops early errors from compounding, so gradients are computed from correct contexts and the model converges faster (at the cost of exposure bias).
Why is backprop through time needed to train the encoder?
The encoder's states are chained across time steps, so the gradient of the loss must be unrolled backward through every step to update the shared recurrent weights.

Edge cases

What is for an empty input sequence ()?
There are no tokens to process, so falls back to the initial state (usually zeros) — the decoder then generates purely from its prior/START token.
What stops the decoder from generating forever?
Generation halts when the model emits the special token (or hits a max-length cap); without this stopping rule autoregression would never terminate.
What happens at the very first decoder step when there is no previous output?
A special token is fed as so the recurrence has an input to condition the first prediction on.
If two beams in beam search have equal accumulated probability, what happens?
Both are kept up to the beam width; ties are broken arbitrarily (or by length/order), and pruning only occurs once more candidates than the width exist.
What if the target token isn't in the vocabulary ?
It's mapped to an (unknown) token; softmax can only assign probability to symbols in , so out-of-vocabulary words are unrepresentable directly.
For a one-token output (), does teacher forcing matter?
No — there is no previous generated token to feed back, so teacher-forced and free-running training coincide for that single step.
Recall Quick self-check

One-sentence: what single change removes the fixed- bottleneck? ::: Attention — letting the decoder attend to all encoder hidden states instead of only the last one.