liveBook · Manning

Attention weight

An attention weight is a computed coefficient, often normalized, that determines how strongly an input element or value contributes to an attention-based representation.

How 2 Manning books explain it

Build a Large Language Model (From Scratch)

A normalized relevance coefficient derived from attention scores that determines how much each value contributes to the context vector.

How it is used
Uses normalized relevance values to combine input or value vectors into context representations within self-attention.
How deep it goes
Derives weights from dot products through softmax and matrix operations, then extends them to projected queries and keys.
Examples
Demonstrates one query over six token vectors, row-wise normalization, vectorized weights, and a resulting three-dimensional context vector.
What you can do after
Build it from scratch with PyTorch using dot products, softmax, projected queries, keys, values, and matrix multiplication.

Read how Build a Large Language Model (From Scratch) explains attention weight →

Build a Text-to-Image Generator (from Scratch)

A normalized attention score that determines how strongly a value contributes to an attention output.

How it is used
Uses normalized query-key similarities to combine value vectors into contextually enriched token representations.
How deep it goes
Traces projections, scaled dot products, softmax, and value aggregation, then extends the process to multi-head attention.
Examples
Uses the contextual meaning of “bank,” PyTorch attention functions, masks, dropout, and four-head vision-transformer attention.
What you can do after
Build attention weights from query, key, and value tensors using scaled dot products, softmax, masking, and optional dropout.

Read how Build a Text-to-Image Generator (from Scratch) explains attention weight →

Related concepts

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.