liveBook · Manning

Attention

As explained in The AI Pocket Book

The transformer computation that assigns attention scores and uses them to weigh contextual influence among tokens.

Attention assigns relative importance to tokens, then uses those scores to let relevant context influence a token’s embedding. It helps disambiguate meaning within the context window. section 1.20

Disambiguating “bark”

In “dog’s bark,” attention focuses mainly on “dog,” then “bark,” then “’s.” Information from “dog” consequently rubs off on “bark,” clarifying its meaning. section 1.20

The mechanism works in three broad moves:

  • Calculate an attention score for each token in the context. section 1.20
  • Compare embeddings through mathematical operations such as projections. section 1.20
  • Use the scores to guide how token information changes contextualized embeddings. section 1.20
Figure 1.10 The attention mechanism calculates the relative relevance of all tokens in the context window to contextualize or disambiguate the last token.

Use the figure to see how tokens receive relative relevance when contextualizing the final token. section 1.20

How The AI Pocket Book covers it

How deep it goes
Explains scores, projections, learned matrices, and embedding influence, but defers the mathematical details of the operations.
Examples
Uses “dog’s bark” and Figure 1.10 to show relevance and contextual influence.
What it assumes
Assumes embeddings and introduces projections as the mechanism for comparing them.
What you can do after
Evaluate how attention uses token relevance to clarify meaning and alter contextualized embeddings.
How it connects
Links contextualization with embeddings, projection matrices, machine learning, and the context window.

Also explained in

Compare how 28 books explain attention →

Related concepts

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