liveBook · Manning

Attention score

As explained in The AI Pocket Book

A numerical value used by an attention mechanism to weight the relevance of one element relative to others.

An attention score is a number that tells an attention mechanism how relevant each token is to another token. During contextualization, the scores divide attention across the context so the model can resolve meaning. section 1.20

Disambiguating “bark”

In “dog’s bark,” the model gives the most attention to “dog,” then “bark,” and finally “’s.” Information from “dog” therefore influences the embedding for “bark,” making its meaning more specific. section 1.20

The scores come from mathematical operations such as projections that compare embedding vectors. Their detailed calculation is deferred, while learned projection matrices supply many of the numerical settings. Afterward, the scores guide updates to the token embeddings. section 1.20 section 1.24

Figure 1.10 The attention mechanism calculates the relative relevance of all tokens in the context window to contextualize or disambiguate the last token.

A figure showing how the mechanism compares tokens and assigns their relative relevance while contextualizing the final token. section 1.20

How The AI Pocket Book covers it

How deep it goes
Explains token weighting, projections, learned matrices, and embedding updates but defers the detailed mathematical operations.
Examples
Uses “dog’s bark” to show how relative token relevance resolves meaning.
What it assumes
Assumes familiarity with tokens and embedding vectors while introducing attention scores through a concrete language example.
What you can do after
Evaluate how token relevance guides contextualized embeddings in a language model.
How it connects
Connects attention scores to attention mechanisms, embeddings, context windows, projection matrices, and machine learning.

Also explained in

Compare how 4 books explain attention score →

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.