liveBook · Manning

Transformer architecture

As explained in LLMs in Production

A transformer architecture is a neural-network architecture that models sequence relationships primarily through attention rather than recurrence or convolution.

For a task such as translation, a model must process the input before generating an output. A full transformer combines an encoder, which processes input, with a decoder, which generates output. The decoder receives the encoder’s representation through a multihead attention block. Attention replaces recurrence as the architecture’s central mechanism, allowing inputs to be processed in parallel rather than sequentially as in an LSTM. section 2.3.3 section 2.3

Choose the arrangement and training plan together:

  • Use the full encoder–decoder arrangement when both input processing and generation matter, as in translation or summarization. T5 is an example. The full arrangement is bulkier and slower than either half alone. section 2.3.3
  • Expect substantial training demands: transformers are memory-intensive and require large amounts of data and VRAM. Parallelism makes large-scale computation practical, but does not remove those costs. section 2.3.3 section 5.2
  • When training from scratch, choose the layer arrangement for the task, dataset and available compute; then prepare and tokenize diverse text before optimizing the model. section 5.2.1
Figure 2.7 A full transformer visualized. A full transformer combines the encoder and the decoder and does well on all of the tasks of each, as well as conditional generation tasks such as summarization and translation. Because transformers are bulkier and slower than each of their halves, researchers and businesses have generally opted to use those halves over the whole transformer.
figure

The diagram shows where encoder output enters the decoder and why the combined arrangement suits conditional generation. section 2.3.3

Strong language-model performance is not the same as complete linguistic understanding. Even state-of-the-art transformers are described here as making semantic approximations; typical uses do not model pragmatics or phonetics. section 2.3.3

How LLMs in Production covers it

How deep it goes
Explains encoder–decoder roles, parallelism and training trade-offs, but does not derive attention calculations in the supplied passages.
Examples
Uses translation, summarization and T5 to illustrate the full architecture, alongside a PyTorch training-from-scratch listing.
What it assumes
Introduces tokenization as conversion of text to numerical tokens while placing transformers after earlier language-model approaches.
What you can do after
Evaluate/understand architecture choices against task fit, parallelism, data needs and training memory.
How it connects
Connects attention and multihead attention to encoders, decoders, LSTMs, tokenization and language-model training.

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 LLMs in Production. The section links point to the parts of the book it draws on.