Skip to main content
mostly formatting
Source Link
Soltius
  • 281
  • 2
  • 9

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


Q$Q$, K$K$ and V$V$ values are defined in the paper, and they do come from multiplication with learnt projection matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing.
The The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead(Q,K,V$Q,K,V$) equation where they represent inputs, ie$i.e.$ what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention(Q,K,V$Q,K,V$) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, ie$i.e.$ what they call $V$ is $XW^V_i$ in my suggested re-writing.

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


Q, K and V values are defined in the paper, and they do come from multiplication with learnt matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing.
The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead(Q,K,V) equation where they represent inputs, ie what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention(Q,K,V) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, ie what they call $V$ is $XW^V_i$ in my suggested re-writing.

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


$Q$, $K$ and $V$ values are defined in the paper, and they do come from multiplication with learnt projection matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing. The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead($Q,K,V$) equation where they represent inputs, $i.e.$ what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention($Q,K,V$) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, $i.e.$ what they call $V$ is $XW^V_i$ in my suggested re-writing.
better figure
Source Link
Soltius
  • 281
  • 2
  • 9

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


Q, K and V values are defined in the paper, and they do come from multiplication with learnt matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing.
The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description hereenter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead(Q,K,V) equation where they represent inputs, ie what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention(Q,K,V) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, ie what they call $V$ is $XW^V_i$ in my suggested re-writing.

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


Q, K and V values are defined in the paper, and they do come from multiplication with learnt matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing.
The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead(Q,K,V) equation where they represent inputs, ie what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention(Q,K,V) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, ie what they call $V$ is $XW^V_i$ in my suggested re-writing.

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


Q, K and V values are defined in the paper, and they do come from multiplication with learnt matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing.
The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead(Q,K,V) equation where they represent inputs, ie what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention(Q,K,V) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, ie what they call $V$ is $XW^V_i$ in my suggested re-writing.
Source Link
Soltius
  • 281
  • 2
  • 9

(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.


Q, K and V values are defined in the paper, and they do come from multiplication with learnt matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.

The confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing.
The equation would be be clearer if it read : ![enter image description here And Figure 2 right could be modified accordingly :
enter image description here

In this new notation, $X$ and $Y$ are the inputs to the current attention unit.

  • For self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).
  • For cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.

Technically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :

  • in the multihead(Q,K,V) equation where they represent inputs, ie what they call $V$ is $X$ in my suggested re-writing ;
  • in the attention(Q,K,V) equation where they represent "true" query/key/values, meaning inputs multiplied by projections matrices, ie what they call $V$ is $XW^V_i$ in my suggested re-writing.