Copy Mechanism › Attention Visualization for Copy

Michael BrenndoerferUpdated May 19, 20253 min read
Language AI HandbookAll chapters
Part 12 of 67Sequence-to-Sequence
Chapter 89Copy Mechanism › Attention Visualization for Copy
Reading section 9 of 14 · Attention Visualization for Copy · 3 minSection 9 of 14 · 3 min

Section 9 of 14 · 3 min read

Copy Mechanism › Attention Visualization for CopySection view · Sections in this chapter9 / 14 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

Visualizing attention patterns reveals when and what the model copies. High attention on specific source positions often indicates copying, especially when pgenp_{\text{gen}} is low.

The visual signature of copying is distinctive: when the model copies a token, attention concentrates sharply on the corresponding source position, often with more than 80% of the probability mass on a single position. When the model generates a token, attention is typically more diffuse, spread across several source positions that provide context without any single position being the "source" of the output token. This difference in attention sharpness is not just visually useful; it can be used diagnostically to understand what the model is doing at each step, and it has been used in research to study how well the model's copy decisions align with human judgments about which tokens should be copied.

VisualizationOut [26]
CollapseExpand
Heatmap showing attention weights between generated summary tokens and source document tokens.
Attention heatmap during summarization with copy mechanism. Each row shows attention weights when generating a summary token. High attention (darker cells) on source tokens like 'Chen' and 'Stanford' indicates copying, while diffuse attention during generation of common words like 'announced' shows the model drawing context from multiple positions.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy