Let $x, y \in \mathbb{R}^d$ be the input and output vectors in a seq2seq setup with one self-attention head. When we compute dot-product attention using queries and keys, given by, $q^Tk = x^TW_q^TW_k x$, we, as is standard in deep learning, choose $W_q, W_k$ to minimize loss on our training set, which is presumably a text corpus in the language we want to translate from (and through teacher forcing we generate output, which gives us our loss when we compare to ground truth in the language we want to translate to). I don't understand how to interpret what the matrices $W_i$ are learning here. Attention is supposed to capture weighted dot product similarity between word embeddings, and somehow measure their "dependence." My understanding is training the transformer on the input "The cat is big" (with associated French output "Le chat est grand" will hardcode into $W_q, W_k$ (somehow) that "cat" and "big" have some dependence. How could this possibly help or cause translation of an unrelated sentence like "Racecars are very fast" which is completely different?

Or is the idea that the training corpus is so big that pretty much every pairwise combination of words that can be seen, is seen, at least once or a few times, so dependence (of all these possible pairs) is encoded into $W_q, W_k$, which are then used for translation by producing attention score outputs when those words are encountered in a test translation task? Overall, just confused about how the weight matrices are actually applied in training vs test tasks (on an implementational/mechanistic level), and how to interpret the values they're learning.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.