liveBook · Manning

Transformer architecture

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

A transformer architecture is a neural-network architecture that processes sequences primarily through attention mechanisms rather than recurrence.

A transformer architecture processes sequential data, such as text, primarily by selectively attending to relevant input segments instead of relying on strictly word-by-word reading. Attention assigns relevance scores that help preserve context throughout a sequence. section 11.3.2

Attention supports several practical goals:

  • Prioritize the input parts most relevant to predicting each word. section 11.3.2
  • Maintain and propagate context from the beginning to the end of long sequences. section 11.3.2
  • Reduce confusion caused by long sentences and complex phrases. section 11.3.2

Reading a long sentence

A conventional sequence model reads a sentence in order and may lose its initial context by the end. A transformer can focus on different parts of the sentence as it predicts each word, dynamically emphasizing the most relevant relationships. section 11.3.2

Figure 11.10 Multi-head attention with H = 3 heads by node 5. α52, α54, and α55 are the attention coefficients between the nodes. The aggregated features from each head are averaged to obtain the final embedding of the node.

Inspect multi-head attention coefficients to see how separate attention heads weight relationships before combining their aggregated features. section 11.3.2

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Defines attention intuitively as relevance scores but does not detail Transformer layers, equations, or training.
Examples
Uses word-by-word reading, long sentences, translation, and attention coefficients as explanatory examples.
What you can do after
Understand how attention can reduce context loss and confusion in long or complex sequences.
How it connects
Connects attention to sequence processing, context propagation, forgetting, and graph attention networks.

Also explained in

Compare how 28 books explain transformer architecture →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.