{ "lesson": "10-attention-mechanism", "title": "Attention Mechanism — The Breakthrough", "questions": [ { "stage": "pre", "question": "What problem in seq2seq did Bahdanau attention solve?", "options": [ "Tokenization mismatch", "Beam search latency", "The fixed-size context-vector bottleneck where the decoder only saw the encoder's final state", "Vanishing gradients in encoders" ], "correct": 2, "explanation": "Attention lets the decoder consult every encoder state, not just the last one." }, { "stage": "pre", "question": "What is the attention context vector at decoder step t?", "options": [ "The encoder's final hidden state", "The decoder's input embedding", "A random projection", "A weighted average of encoder hidden states where the weights come from a query-key score" ], "correct": 3, "explanation": "Context = sum of alpha_i * h_i, a step-dependent weighted average of encoder states." }, { "stage": "check", "question": "In Bahdanau (additive) attention, what role does the vector v_a play?", "options": [ "It encodes positions", "It biases the softmax", "It controls dropout", "It is the projection that turns the attention-dim hidden combination into a scalar score per encoder position" ], "correct": 3, "explanation": "v_a dot-products with tanh(W_a s + U_a h) to collapse a d_attn vector into a scalar score." }, { "stage": "check", "question": "In Luong's 'dot' attention variant, what constraint must hold?", "options": [ "Beam search is required", "Decoder state and encoder state must share the same dimensionality (d_s == d_h)", "Softmax must be log-space", "The encoder must be bidirectional" ], "correct": 1, "explanation": "dot uses s^T h with no projection, so dimensions must match exactly." }, { "stage": "check", "question": "Which Q/K/V mapping describes classical (Bahdanau/Luong) attention?", "options": [ "Q from encoder, K and V from decoder", "Q, K, V are three independent learned projections of the source", "Q = decoder state; K and V = encoder states (same tensor)", "Q is random, K and V are learned" ], "correct": 2, "explanation": "In classical attention, keys and values are both encoder states; transformers split K and V via learned projections." }, { "stage": "post", "question": "Why is reporting raw attention weights as 'explanation' considered fragile?", "options": [ "Research (e.g. Jain and Wallace, 2019) showed attention distributions can be permuted without changing predictions on some tasks", "Attention weights are not differentiable", "Attention weights leak labels", "They are too small to plot" ], "correct": 0, "explanation": "Attention weights are correlated with predictions but not faithful explanations without ablation/counterfactual checks." }, { "stage": "post", "question": "Which step bridges Bahdanau attention to transformer self-attention?", "options": [ "Querying a sequence against itself with separately learned Q, K, and V projections, run in parallel heads", "Dropping beam search", "Replacing softmax with sigmoid", "Adding more RNN layers" ], "correct": 0, "explanation": "Self-attention queries the same sequence, with split K and V projections, parallelized across heads." }, { "stage": "post", "question": "What is one practical use case for masking in attention?", "options": [ "Replacing dropout", "Encoding positions", "Setting attention weight for padding tokens to zero so they do not contribute to the context vector", "Reducing model size" ], "correct": 2, "explanation": "Masking padding (or future tokens in a decoder) prevents the softmax from spreading weight onto invalid positions." } ] }