liveBook · Manning

Multi-head attention

As explained in The AI Pocket Book

A transformer attention mechanism that splits representations into multiple heads to attend to different relationships in parallel.

Multi-head attention splits an attention mechanism into separate heads. Each head analyzes a different chunk of an embedding vector, so the model can specialize in several kinds of relationships at once. section 1.20

Specialized segments

Imagine one segment of an embedding vector handling animal-related information while another handles tree-related information. The vectors remain difficult to interpret, but separating the work into heads performs better in practice than using one head for the whole vector. 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 attention figure to connect multiple heads with the broader task of comparing token relevance while contextualizing or disambiguating the last token. section 1.20

How The AI Pocket Book covers it

How deep it goes
Defines separate vector chunks and explains their specialization, but stops short of detailing attention calculations or head outputs.
Examples
Illustrates specialization with hypothetical animal-related and tree-related embedding segments.
What it assumes
Assumes attention and embedding vectors, while relating them to contextualization and transformer layers.
What you can do after
Evaluate how separate attention heads can specialize representations and outperform a single whole-vector attention head.
How it connects
Connects attention with embedding vectors, contextualization, transformer layers, and language models.

Also explained in

Compare how 14 books explain multi-head 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.