Given these matrices we can compute all the requisite query-key comparisons simultaneously by multiplying Q and K in a single matrix multiplication (the product is of shape N × N; Fig. 9 .17 shows a visualization). Taking this one step further, we can scale these scores, take the softmax, and then multiply the result by V resulting in a matrix of shape N × d: a vector embedding representation for each token in the input. We've reduced the entire self-attention step for an entire sequence of N tokens to the following computation: