liveBook · Manning

Transformer architecture

As explained in Build a Large Language Model (From Scratch)

a neural network architecture based on self-attention mechanisms that enables processing of sequential data and underpins many large language models.

Transformer architecture is a deep neural network design built around self-attention. The original form uses an encoder to represent input text and a decoder to generate output text, supporting translation and later LLM designs. section 1.4

Its main components divide the language-processing flow into:

  • Encoder: processes input tokens into contextual numerical representations. section 1.4
  • Decoder: uses encoded representations to generate output text one word at a time. section 1.4
  • Self-attention: weighs tokens relative to one another to capture long-range dependencies and contextual relationships. section 1.4
Figure 1.4 A simplified depiction of the original transformer architecture, which is a deep learning model for language translation. The transformer consists of two parts: (a) an encoder that processes the input text and produces an embedding representation (a numerical representation that captures many different factors in different dimensions) of the text that the (b) decoder can use to generate the translated text one word at a time. This figure shows the final stage of the translation process where the decoder has to generate only the final word (“Beispiel”), given the original input text (“This is an example”) and a partially translated sentence (“Das ist ein”), to complete the translation.
figure

Trace the encoder-decoder data flow through a translation example, ending with the decoder predicting “Beispiel” from partial context. section 1.4

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Defines encoder, decoder, and self-attention, but defers self-attention implementation and input preprocessing to later treatment.
Examples
Uses English-to-German translation, including generating “Beispiel” after “Das ist ein.”
What you can do after
Evaluate/understand how encoder-decoder flow and self-attention support translation and GPT-like text generation.
How it connects
Connects self-attention with encoder-decoder models, BERT, GPT, machine translation, and large language models.

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 Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.