# Attention Mechanism: Why use context vector instead of attention weights?

In attention, the context vector ($$c$$) is derived from the sum of the attention weights ($$\alpha$$) multiplied by the encoder hidden states ($$h$$), where the weights are obtained by multiplying the decoder hidden state and the encoder states.

$$c_i = \Sigma_j^{T_x} \alpha_{ij} h_j$$

My question is, why calculate this context vector and simply not forward the attention weights, as these could indicate how much to focus on each of the encoder states.

Could somebody explain the intuition behind this?

## 2 Answers

The attention weights themselves do not carry any information about the encoded sentence. It only tells you something like: the $$n$$-th and $$m$$-th word carry important information for generating the next word, but not what the words actually are. Moreover, it is a variable-length vector (of the same length as the input size), it would be hard to do anything with it in the decoder.

You could pass the attention and the encoder hidden states over to whichever place on the decoder you want and let it do the same weighted sum there. At the end of the day the weighted sum (context) has to be derived before the prediction.

The real question is - Can we make any other use of these attention weights. Luong et al came up with a very nice idea of passing these attention weights to the subsequent timesteps - the idea being that past history of attention could help the model in subsequent time steps. This turned out to be a good insight and makes a lot of difference