liveBook · Manning

Value

As explained in Learn Generative AI with PyTorch

In attention, a value is a vector representation of input content that is combined with other values according to attention weights to produce an output.

A value is a projected representation used to produce attention’s output. In self-attention, the input embedding passes through a neural layer with weights W_V; attention weights determine how the resulting values are combined. section 9.1.1

Library search

In a library-search analogy, book titles and descriptions act as keys, while the recommended books act as values. Query-key similarity determines which results receive higher attention. section 1.3.1

Figure 9.1 A diagram of the self-attention mechanism. To calculate attention, the input embedding X is first passed through three neural layers with weights, WQ, WK, and WV, respectively. The outputs are query Q, key K, and value V. The scaled attention score is the product of Q and K divided by the square root of the dimension of K, dk. We apply the softmax function on the scaled attention score to obtain the attention weight. The attention is the product of the attention weight and value V.

Follow the diagram from input embedding X through the value projection to the weighted attention output. section 9.1.1

How Learn Generative AI with PyTorch covers it

How deep it goes
Traces values from input embedding through the W_V projection to their weighted combination in the attention output.
Examples
Illustrates values with recommended books in a library-search analogy and an English-to-French translation task.
What it assumes
Assumes input embeddings and neural projections; introduces query-key-value roles through a retrieval analogy.
What you can do after
Build self-attention from scratch by projecting inputs into values and combining them with attention weights.
How it connects
Links values with queries, keys, attention weights, scaled dot-product attention, and Transformers.

Also explained in

Compare how 8 books explain value →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.