Skip to main content
deleted 274 characters in body
Source Link
Arya McCarthy
  • 9k
  • 1
  • 24
  • 58

The queries, keys and values are computed from the embeddings $x$ using matrix multiplication: \begin{align} q &= xW_Q \\ k &= xW_K \\ v &= xW_V, \end{align} where $W_Q$, $W_K$ and $W_V$ are trainable parameters of the attention layer. Basically the attention layer learns how to map the embeddings to queries, keys and values.

Probably the only trainable parameter currently in your attention layer is the matrix $W_O$, that is used for combining the outputs from the multiple heads (described in 3.2.2 of the paper). You could modify your attention layer to contain three additional trainable parameters - the matrices $W_Q, W_K, W_V$.

I read your comment that you don't want to look at any code unless absolutely necessary, but still I want to share this blog post that I wrote:
https://pi-tau.github.io/posts/transformer
I would be happy to get some feedback once you finish your implementation!

The queries, keys and values are computed from the embeddings $x$ using matrix multiplication: \begin{align} q &= xW_Q \\ k &= xW_K \\ v &= xW_V, \end{align} where $W_Q$, $W_K$ and $W_V$ are trainable parameters of the attention layer. Basically the attention layer learns how to map the embeddings to queries, keys and values.

Probably the only trainable parameter currently in your attention layer is the matrix $W_O$, that is used for combining the outputs from the multiple heads (described in 3.2.2 of the paper). You could modify your attention layer to contain three additional trainable parameters - the matrices $W_Q, W_K, W_V$.

I read your comment that you don't want to look at any code unless absolutely necessary, but still I want to share this blog post that I wrote:
https://pi-tau.github.io/posts/transformer
I would be happy to get some feedback once you finish your implementation!

The queries, keys and values are computed from the embeddings $x$ using matrix multiplication: \begin{align} q &= xW_Q \\ k &= xW_K \\ v &= xW_V, \end{align} where $W_Q$, $W_K$ and $W_V$ are trainable parameters of the attention layer. Basically the attention layer learns how to map the embeddings to queries, keys and values.

Probably the only trainable parameter currently in your attention layer is the matrix $W_O$, that is used for combining the outputs from the multiple heads (described in 3.2.2 of the paper). You could modify your attention layer to contain three additional trainable parameters - the matrices $W_Q, W_K, W_V$.

Source Link
pi-tau
  • 141
  • 2

The queries, keys and values are computed from the embeddings $x$ using matrix multiplication: \begin{align} q &= xW_Q \\ k &= xW_K \\ v &= xW_V, \end{align} where $W_Q$, $W_K$ and $W_V$ are trainable parameters of the attention layer. Basically the attention layer learns how to map the embeddings to queries, keys and values.

Probably the only trainable parameter currently in your attention layer is the matrix $W_O$, that is used for combining the outputs from the multiple heads (described in 3.2.2 of the paper). You could modify your attention layer to contain three additional trainable parameters - the matrices $W_Q, W_K, W_V$.

I read your comment that you don't want to look at any code unless absolutely necessary, but still I want to share this blog post that I wrote:
https://pi-tau.github.io/posts/transformer
I would be happy to get some feedback once you finish your implementation!