liveBook · Manning

Transformer architecture

As explained in Introduction to Generative AI, Second Edition

A transformer is a neural-network architecture for sequence modeling that uses attention, especially self-attention, rather than recurrence.

A transformer is a neural-network architecture for sequence modeling that uses attention—especially self-attention—instead of recurrence. It became a foundation for large language models (LLMs) and modern generative AI. section 1.2 section 1.23

Attention assigns greater weight to information that matters for interpreting a sequence. Self-attention repeatedly builds a new representation for each word using the whole input, allowing the model to capture long-term dependencies while computing representations in parallel. section 1.2

Transformers changed language modeling in several connected ways:

  • They discarded the lengthy sequential steps used by earlier architectures, making processing faster and more parallelizable. section 1.2
  • They made it practical to train on much larger quantities of data, helping launch the modern LLM era. section 1.2
  • They support general-purpose models such as GPT, which can be fine-tuned for tasks including translation, sentiment analysis, classification, and text generation. section 1.2

Following the important words

In “That cat chased a mouse, but it didn’t catch it,” attention can emphasize “cat” and “mouse” when interpreting “it,” rather than treating every word as equally relevant. The same mechanism supported strong early results on English-to-German and English-to-French translation. section 1.2

Figure 1.2 The distribution of attention for the word “it” in different contexts.
A screenshot of a video game

AI-generated content may be incorrect.

Shows how attention for the word “it” changes across contexts, making the mechanism’s focus on relevant sequence information concrete. section 1.2

The architecture enabled major gains, but systems built from it can still encode bias, hallucinate, and require substantial computational resources. Its capabilities therefore do not remove the need for evaluation and responsible deployment. section 1.23

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Defines attention and self-attention through intuition and history, but stops short of implementation details, mathematics, or training procedures.
Examples
Uses a cat-and-mouse sentence, translation benchmarks, GPT, and attention visualizations to illustrate the architecture.
What you can do after
Evaluate/understand it by relating parallel self-attention to long-range context, scalable training, and LLM applications.
How it connects
Connects attention mechanism, self-attention, recurrent architectures, machine translation, large language models, and GPT.

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 Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.