liveBook · Manning

Transformer architecture

As explained in Domain-Specific Small Language Models

A neural network architecture for sequence modeling built around self-attention and parallel processing, underlying both large and small language models.

Transformer architecture is a sequence-modeling design that replaces recurrent processing with self-attention, allowing an entire text sequence to be processed in parallel. This improves training speed and scalability compared with RNN, LSTM, and GRU approaches. section 1.2

Self-attention relates positions across a sequence to build contextual representations, while word embeddings represent words as vectors whose relationships encode semantic and syntactic information. Transformer variants divide responsibilities differently: encoder-only BERT models support classification and prediction, while decoder-only GPT models support text generation. section 1.2 section 1.7

Operational implications include:

  • Parallel processing reduces the sequential bottleneck that limits recurrent architectures. section 1.2
  • Pretrained Transformer models provide lower-cost starting points than developing and training a model from scratch. section 1.4
  • Inference still requires attention to execution speed, accuracy, compute cost, scalability, and deployment constraints. section 1.4 section 4.1

GPT-Neo as an inference reference

GPT-Neo large, with 2.7 billion trainable parameters, illustrates a decoder-style Transformer used for content generation. The example connects the architecture to Hugging Face Transformers and Accelerate libraries and to quantization-related inference decisions. section 4.1

How Domain-Specific Small Language Models covers it

How deep it goes
Explains motivation, self-attention, embeddings, and encoder-decoder roles, but stops short of mathematical attention internals.
Examples
Uses GPT-Neo large, Hugging Face Transformers, Accelerate, and companion Colab notebooks to ground inference discussion.
What it assumes
Assumes familiarity with neural sequence models while defining recurrent limitations, self-attention, embeddings, and encoder-decoder roles.
What you can do after
Evaluate Transformer variants and choose pretrained models with clearer expectations for parallelism, inference cost, and deployment.
How it connects
Connects self-attention with word embeddings, RNNs, BERT, GPT, self-supervised learning, transfer learning, and quantization.

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 Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.