What is the core idea of an attention mechanism in a neural network?
Show the answer and explanation
Correct answer: C, For each output, it takes a weighted average of the input representations, weighting each input by its relevance.
Explanation Attention
Attention lets the model decide, for each output, which inputs to look at. It scores every input representation for relevance to the current query, turns the scores into weights with a softmax (so they are positive and sum to 1), and returns the weighted average of the inputs. The weights are recomputed from the content of every new input.
Why the other ideas are wrong:
- Compressing the input into one fixed-length vector is the bottleneck of early RNN encoder–decoders; attention was introduced (Bahdanau et al., 2014, for translation) precisely to remove it.
- Fixed per-position weights ignore content; attention weights depend on the actual tokens, so they change from sentence to sentence.
- Randomly dropping inputs is a regularization trick in the spirit of dropout, not attention.
Interview tip: say "a learned, content-dependent weighted average" and mention that the weights also give a rough view of what the model focused on.