← back to the archiveCover illustration for “Transformer: the neural network design behind LLMs”
TERMday 179·today·Published ·by Andy Padia

Transformer: the neural network design behind LLMs

In short: A transformer is the neural network architecture behind modern language models, built on attention so every token can look at every other token at once.

A transformer is a neural network architecture that processes a sequence by letting every token weigh its relationship to every other token, a step called self-attention. It was introduced in the 2017 paper Attention Is All You Need, which dropped recurrence and convolution entirely. The large language models behind chat assistants are generally built from transformer layers.

Transformer in plain words

Older models read a sentence the way you read a ticker tape, one word at a time, holding a fading memory of what came before. A transformer reads the whole page at once and draws a line from each word to the words that matter for it.

How it works

  1. Text is split into tokens, and each token becomes a vector. Because the model has no built-in sense of order, the original design adds positional encodings to those vectors.
  2. In each layer, every token produces a query, a key and a value. Comparing one token's query with every key gives attention weights, and the token's new representation is the weighted mix of the values. The paper runs eight of these attention heads in parallel, so different heads can track different relationships.
  3. Layers are stacked. The original model used six encoder layers and six decoder layers, and the decoder produced the output one token at a time.

Google's August 2017 explainer names the practical gain: any two words are related in a small, constant number of steps instead of a long chain, and the work parallelises well on modern hardware. The paper reports that its larger model trained in 3.5 days on eight GPUs.

Example

As an illustration, in "The trophy did not fit in the suitcase because it was too big", attention can let the token "it" put high weight on "trophy" in one layer, so later layers carry that link forward when predicting what comes next.

Where you'll meet it

  • Model cards that describe a "decoder-only transformer"
  • Context-window limits and long-context pricing
  • Inference servers and their KV cache settings
  • Variants such as mixture-of-experts layers

What it changes for you

Attention compares every token with every other token, and the paper's own complexity table shows that cost growing with the square of sequence length. That one fact explains a lot of what you pay for: why long prompts cost more, why caching matters and why context windows have limits. You do not need the maths to build with LLMs, but this shape helps you reason about latency and price.

Transformer vs recurrent neural network

A recurrent network (RNN) processes tokens in order and passes a hidden state forward, so distant words are linked through many steps. A transformer relates any pair of tokens directly in each layer and processes the sequence in parallel during training.

Common mistake

My view: treating "transformer" as a quality label. It names an architecture, and two transformer models can differ hugely in data, size and tuning. Judge a model on your own evals, not on the word in its spec sheet.

Large language model · Token · Context window · KV cache · Mixture of experts · Embeddings

Transformer names the architecture, so judge a model on your own evals.

#field-guide#models#llm#fundamentals#architecture

Sources

  1. arxiv.org/abs/1706.03762
  2. research.google/blog/transformer-a-novel-neural-network-architecture-for-language-understanding
← older drop
Eighteen repos are not a video stack
newer drop →
Agentic commerce: AI agents that shop and pay for you

related drops

explore all 570 drops →
← back to the archiveday 179