Dot-product attention
Dot-product attention computes query–key relevance scores using inner products and uses normalized scores to form weighted combinations of value representations.
Natural Language Processing in Action, Second Edition
Dot-product attention scores queries and keys with scalar products and uses those scores to weight values.
- How it is used
- Implements attention in transformers through optimized matrix multiplications over packed query, key, and value matrices.
- How deep it goes
- Explains projections, scaling, softmax normalization, and weighted values, while stopping before multi-head attention details.
- Examples
- Uses a toy attention matrix to represent connections between words in an input sequence.
- What you can do after
- Evaluate how scaled query-key scores become normalized weights and weighted value outputs.
Read how Natural Language Processing in Action, Second Edition explains dot-product attention →
Building Specialized AI Systems
Dot-product attention calculates relevance between queries and keys with dot products and combines values using the resulting weights.
- How it is used
- Explains how Transformer tokens select and combine contextual information through self-attention.
- How deep it goes
- Defines projections, scaling, softmax, and value aggregation, then stops short of parameter-learning details.
- Examples
- Uses a cat-and-pronoun sentence and a three-stage visualization of scores, weights, and context-aware outputs.
- What you can do after
- Evaluate/understand how attention scores become weighted contextual representations.
Read how Building Specialized AI Systems explains dot-product attention →
Deep Learning with R, Third Edition
Dot-product attention computes attention relevance scores from the dot products of query-like and source-like vectors and uses them to form a weighted representation.
- How it is used
- Uses relevance-weighted source representations to help sequence models predict target tokens.
- How deep it goes
- Explains dot products, softmax normalization, weighted sums, sequence-shaped score matrices, and tensor implementation.
- Examples
- Demonstrates translation prediction, source-target score matrices, and image retrieval through query-key matching.
- What you can do after
- Build it from scratch using tensor contractions, softmax scores, and weighted source representations.
Read how Deep Learning with R, Third Edition explains dot-product attention →
What to know first
- softmaxSoftmax is a function that exponentiates each value in a score vector and normalizes the results to produce positive values summing to one, forming a probability distribution.
- language modelA language model is a computational model of linguistic sequences that estimates their probabilities or predicts tokens from context, enabling it to generate or evaluate language.
- linear layerA linear layer is a neural-network layer that applies a learned affine transformation to its input, typically using weights and a bias.
- embeddingAn embedding is a numerical vector representation of an item in a feature space that encodes selected properties or relationships for computational tasks.
Related concepts
- attentionkind of · Attention is a neural-network mechanism that computes input-dependent relevance weights to combine information from representations for a context-dependent computation.
- query-key-value frameworkkind of · The query-key-value framework represents each input with query, key, and value vectors to compute attention-weighted outputs.
- decoupled rotary position embeddingused by · Decoupled rotary position embedding is an attention design that separates content-based and position-based computation into parallel streams before combining their scores.
- decoupled attention architectureused by · A decoupled attention architecture separates semantic-content processing from relative-position processing and fuses their attention scores.
Questions about dot-product attention
What is dot-product attention?
Dot-product attention computes query–key relevance scores using inner products and uses normalized scores to form weighted combinations of value representations.
Which Manning books explain dot-product attention?
Natural Language Processing in Action, Second Edition, Building Specialized AI Systems and Deep Learning with R, Third Edition.
What should I know before learning dot-product attention?
Manning books that teach dot-product attention usually introduce softmax, language model, linear layer and embedding first.
What is dot-product attention a kind of?
Dot-product attention is a kind of attention. Attention is a neural-network mechanism that computes input-dependent relevance weights to combine information from representations for a context-dependent computation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


