attention head

/uh-TEN-shun hed/ · noun · AI & Machine Learning · Origin: 2017

Definitions

  1. Attention Head is a single attention mechanism within a multi-head attention layer of a transformer neural network. In the transformer architecture (introduced in the 2017 Attention Is All You Need paper), each attention layer contains multiple parallel attention heads, each independently learning to focus on different types of relationships in the input data. One head might learn to attend to syntactic relationships (subject-verb connections), while another captures semantic similarity, positional patterns, or co-reference links. Each head projects the input into its own query, key, and value spaces, computes attention scores, and produces an output. The outputs from all heads are concatenated and linearly transformed to produce the layer's final output. Having multiple heads allows the model to jointly attend to information from different representation subspaces. Research in mechanistic interpretability studies what individual attention heads learn, revealing specialized behaviors like induction heads (pattern completion) and name-mover heads. GPT-4 class models contain thousands of attention heads across dozens of layers.

    In plain English: One of several 'eyes' inside an AI model, each looking at a different aspect of the text to understand meaning.

    Example: The researchers found that certain attention heads in GPT-4 specialize in tracking subject-verb agreement across long distances.

Etymology

2017
Vaswani et al. introduced multi-head attention in 'Attention Is All You Need.' Each attention head independently learns different relationship patterns across input tokens.
2019
Research by Clark et al. and others analyzed what individual attention heads learn, finding heads specialized for syntax, coreference, positional patterns, and other linguistic features.
2020
The 'induction head' concept emerged from mechanistic interpretability research, identifying specific head circuits responsible for in-context learning in Transformers.
2022-Present
Attention head analysis became central to AI interpretability. Techniques like attention head pruning showed that many heads are redundant, enabling model compression.

Origin Story

The Specialized Spotlight Inside a Transformer

An attention head is a single instance of the attention mechanism within a multi-head attention layer, the core component of the Transformer architecture. The concept was introduced in the landmark 2017 paper 'Attention Is All You Need' by Ashish Vaswani and colleagues at Google Brain and the University of Toronto. Rather than computing a single attention function, the authors found that splitting the input into multiple parallel 'heads,' each attending to different aspects of the data, dramatically improved model performance. Each head independently learns its own query, key, and value projections, allowing one head to focus on syntactic relationships, another on semantic meaning, another on positional patterns, and so on. The outputs from all heads are then concatenated and projected back to the model's dimension. The original Transformer used 8 heads; modern large language models like GPT-4 use 96 or more. This design proved so effective that it became the backbone of nearly every state-of-the-art NLP model. Researchers have since discovered that individual heads can be remarkably interpretable, with specific heads reliably tracking grammatical structures like subject-verb agreement across sentences.

Coined by: Ashish Vaswani et al.

Context: Introduced in the 2017 paper 'Attention Is All You Need' as part of the multi-head attention mechanism in Transformers.

Fun fact: Researchers at Google discovered a single attention head in BERT that almost perfectly tracked syntactic dependency relations, prompting the quip that the model had independently 'learned to parse' without any explicit grammar training.

Related Terms