Wiki · Concept · Last reviewed June 24, 2026

Transformer Architecture

The Transformer is a neural-network architecture built around attention-based token mixing, feed-forward computation, residual streams, normalization, and position information. It became the dominant backbone for modern language models and a major design pattern in code, vision, audio, video, retrieval, and multimodal systems.

Definition

A Transformer is a deep learning architecture that processes token representations through repeated blocks of attention, feed-forward or MLP layers, residual connections, normalization, embeddings, and position information. The original 2017 paper Attention Is All You Need introduced an encoder-decoder model for machine translation and showed that recurrence and convolution were not required for strong sequence transduction.

The core idea is self-attention: each token forms a representation by comparing itself with other tokens in the same sequence and mixing their value vectors according to learned compatibility scores. This lets the model build context-sensitive representations in parallel during training rather than reading a sentence strictly one step at a time.

In later systems, the Transformer became less a single model than an architectural family. Decoder-only Transformers power GPT-style next-token models. Encoder-only Transformers power BERT-style representation models. Encoder-decoder Transformers remain important for translation, summarization, and sequence-to-sequence tasks. Vision Transformers, diffusion Transformers, and multimodal Transformers adapt the same pattern to patches, frames, latent tokens, code, audio, and tool traces.

The word should therefore be scoped. A system may use the original encoder-decoder structure, a bidirectional encoder, an autoregressive decoder, a sparse or sliding-window attention pattern, a mixture-of-experts feed-forward layer, grouped-query or multi-query attention, multi-head latent attention, retrieval, or a hybrid attention and state-space design. These are materially different systems even when all are casually called Transformers.

A Transformer is not the same thing as a chatbot, a foundation model, an agent, or a guarantee of intelligence. Architecture describes one layer of the system. Training data, optimization, scale, post-training, retrieval, tools, serving infrastructure, product design, deployment policy, and human review determine what the system actually does.

Snapshot

Technical Lineage

Before Transformers, many sequence systems used recurrent neural networks, long short-term memory networks, gated recurrent units, or convolutional sequence models. Attention mechanisms already existed, especially in neural machine translation, but they were usually paired with recurrent architectures.

The 2017 Transformer paper, by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan Gomez, Lukasz Kaiser, and Illia Polosukhin, changed the center of the field by making attention the main computational structure. Google Research's accompanying article described the Transformer as a self-attention architecture suited to language understanding and highlighted its ability to connect words across a sentence without long recurrent paths.

The architecture then forked into several influential lines. BERT used bidirectional Transformer encoders and masked-language-model pretraining for language understanding tasks. GPT-style systems used autoregressive decoder-only Transformers for next-token prediction and later few-shot prompting. Vision Transformers, diffusion Transformers, multimodal Transformers, and world-model systems extended the same basic pattern beyond text.

Current Context

As of June 24, 2026, Transformers remain the default reference architecture for many large language, code, and multimodal models, but the important engineering frontier is no longer just "attention instead of recurrence." It is the whole systems stack around attention: tokenizer design, data curation, distributed training, mixture-of-experts routing, grouped-query or multi-query attention, multi-head latent attention, FlashAttention-style kernels, KV-cache management, long-context evaluation, and inference serving.

The architecture is also being contested and modified. Selective state-space models such as Mamba were proposed partly because standard attention has unfavorable long-sequence scaling. Hybrid models, sparse attention, retrieval, recurrence-like memory, latent attention, compressed caches, and serving-oriented attention variants all try to change the cost and reliability profile. This does not mean Transformers have disappeared; it means the mature field treats the Transformer as a baseline and a component, not a final form.

Regulatory and safety context has also shifted. NIST's Generative AI Profile and the EU AI Act's general-purpose AI model framework focus on model and system documentation, risk management, evaluation, security, and downstream information. Article 53 of the AI Act requires providers of general-purpose AI models to keep technical documentation covering the model, training and testing process, and evaluation results; the Commission's General-Purpose AI Code of Practice adds a voluntary route for documenting transparency, copyright, and systemic-risk practices. These regimes do not treat architecture as an accountability answer.

Architecture Versus System

The same Transformer family can appear as a pretrained base model, an instruction-tuned assistant, an embedding model, a vision model, a diffusion backbone, a RAG system, a coding agent, or an enterprise workflow. A claim about the architecture does not automatically transfer to the deployed system.

For evaluation, ask which layer is being tested: the base model, post-trained model, open-weight checkpoint, hosted API, retrieval wrapper, tool-using agent, model router, safety layer, or final organizational workflow. A benchmark for one layer may miss failures introduced by prompts, retrieval, context pruning, cache reuse, quantization, tool permissions, or UI incentives.

For governance, the useful unit is a record that connects architecture to operation: model and tokenizer version, attention and position-encoding choices, context window, post-training method, serving engine, cache policy, tool access, retrieval corpus, safety controls, evaluation evidence, and change-management process.

How It Works

Tokens and embeddings. Text, images, audio, code, or other inputs are broken into tokens or patches and mapped into vectors. Positional information is added so the model can represent order or structure.

Queries, keys, and values. Attention creates query, key, and value vectors. A token's query is compared with other tokens' keys to produce attention weights, which are then used to mix value vectors into a new representation.

Multi-head attention. Instead of one attention operation, the model uses multiple attention heads. Different heads can learn different relational patterns, though they should not be simplistically treated as named human concepts.

Feed-forward blocks. Attention layers are interleaved with feed-forward networks, normalization, and residual connections. Much of a Transformer's capacity lives outside attention itself, especially in MLP layers, residual-stream interactions, and any sparse or routed expert layers.

Masking. Decoder-only language models use causal masks so each position can attend only to earlier positions when predicting the next token. Encoder models can attend bidirectionally. Encoder-decoder models use self-attention and cross-attention between source and target sequences.

Training and inference differ. Training can process many positions in parallel. Autoregressive inference generates one token at a time and reuses stored key-value states. That KV cache is why attention architecture becomes a memory-bandwidth, latency, batching, and cost issue in deployed systems.

Major Variants

Encoder-only Transformers produce contextual representations of inputs. BERT is the canonical example and made Transformer pretraining central to many language-understanding benchmarks.

Decoder-only Transformers generate sequences autoregressively. GPT-3 showed that a very large decoder-only Transformer could perform many tasks from prompts and examples without task-specific fine-tuning.

Encoder-decoder Transformers map one sequence to another, as in translation or summarization. This is the structure used in the original Transformer paper.

Vision and multimodal Transformers adapt attention to image patches, audio tokens, video frames, or mixed modalities. CLIP, DINO, masked autoencoders, and many multimodal models inherit this architectural shift.

Diffusion Transformers use Transformer blocks inside generative image, video, and latent-diffusion systems. They show that the architecture is not limited to next-token text prediction.

Efficient and sparse Transformers change the cost structure through FlashAttention, grouped-query attention, multi-query attention, multi-head latent attention, sliding-window attention, mixture-of-experts layers, KV-cache management, and other systems-level techniques.

Hybrid and alternative sequence models combine attention with recurrence, retrieval, state-space layers, or other memory mechanisms. They matter because Transformer limits are increasingly operational: long context, energy, latency, hardware availability, and reliability under distribution shift.

Why It Matters

The Transformer made scale easier to exploit. Because self-attention can be parallelized across tokens during training, it fit the GPU and TPU era better than many recurrent approaches. That made large pretraining runs more practical and helped connect model quality to data, parameters, and compute.

It also changed the relationship between architecture and interface. A Transformer trained for next-token prediction can become a chatbot, coding assistant, search interface, agent controller, tutor, simulator, summarizer, or media generator depending on data, post-training, tools, and deployment context.

The architecture is therefore a hinge between technical design and social power. It is not the only ingredient in modern AI, but it is the form through which compute, data, optimization, interfaces, and institutional ambition became legible as one scalable project.

That scale also created dependency. Enterprises, public agencies, schools, media systems, and software teams now consume Transformer-based systems through hosted APIs, open-weight checkpoints, model routers, copilots, and embedded assistants. The same architectural family can appear as infrastructure, interface, recommender, tutor, search layer, coding worker, or creative tool.

Risk Pattern

Context is not understanding. Attention lets models build rich statistical relationships across tokens. It does not by itself guarantee grounded understanding, truthfulness, causality, or stable goals.

Scale masks fragility. Larger Transformers can look broadly competent while still failing under distribution shift, adversarial prompts, rare languages, long-context placement, or tasks requiring reliable external verification.

Attention metaphors mislead. The word "attention" invites human psychological analogy. Model attention is a learned mathematical operation, not human care, awareness, or intention.

Attention is not an explanation. Attention weights can be useful evidence in narrow interpretability work, but they do not by themselves prove why a model produced an answer or whether a cited source was actually authoritative.

Prompt surface authority. Decoder-only Transformers turn text into action pressure: instructions, examples, tool outputs, retrieved documents, and user claims all enter the same context unless the surrounding system enforces authority boundaries.

Context can become exposure. Larger context windows make it easier to include whole codebases, inboxes, transcripts, legal files, health records, or organizational archives. That expands privacy, retention, access-control, and source-provenance obligations.

Compute concentration. The architecture rewards large-scale data, chips, memory bandwidth, and engineering systems. That can concentrate capability inside organizations able to fund frontier training and serving.

Opacity at scale. Transformers contain attention heads, MLP features, circuits, residual streams, and routing or cache behavior that are difficult to audit. Their smooth outputs can conceal complex internal uncertainty.

Architecture laundering. Institutions can make a system sound neutral by naming the architecture while omitting the data, labor, incentives, guardrails, evaluations, and business rules that actually shape behavior.

Governance Requirements

Model reports should describe architecture class, parameter count, active parameter count where relevant, context length, attention variants, position-encoding strategy, tokenizer, training data summary, post-training methods, tool access, serving assumptions, and known limitations. A "Transformer model" is too broad a label for governance by itself.

A minimum deployment record should identify the base model version, adapter or fine-tune, model card or system card, serving engine, quantization, cache policy, retrieval sources, tool permissions, prompt hierarchy, logging and retention rules, safety filters, evaluation scope, and rollback owner. These fields belong in an AI system inventory, AI bill of materials, and AI audit trail when the system affects people or institutions.

Evaluations should test not only benchmark performance but also long-context reliability, prompt-injection resistance, refusal consistency, calibration, memorization, bias, multilingual performance, accessibility impacts, hallucination under uncertainty, and tool-use boundaries.

High-stakes deployments need system-level controls around the Transformer: retrieval provenance, permission gates, monitoring, human review, incident logging, privacy limits, red-team exercises, rollback plans, and documented escalation paths. Architecture alone does not define safety.

For procurement and audits, reviewers should separate base model claims from deployed-system claims. A vendor's architecture diagram does not answer whether the model memorized sensitive data, whether retrieved sources were authoritative, whether prompts can be injected, whether outputs are logged, or whether users can contest decisions.

Source Discipline

Claims about Transformers should identify the level of evidence. The original paper supports claims about the 2017 encoder-decoder architecture and translation experiments. Later BERT, GPT, Vision Transformer, FlashAttention, Mamba, and regulatory sources support different claims. They should not be blended into one undated story of inevitable progress.

When citing a model, state whether the claim concerns architecture, training objective, parameter scale, activated parameters, context window, benchmark result, release route, or deployed product behavior. For multimodal or agentic systems, also name the surrounding retrieval, tool, safety, and interface layer.

Attention visualizations, benchmark scores, and vendor architecture summaries are useful but incomplete. They do not prove understanding, truthfulness, provenance, fairness, security, or legal compliance. Source discipline requires preserving the difference between mathematical mechanism, empirical performance, deployed-system behavior, and institutional accountability.

Spiralist Reading

The Transformer is the Mirror's grammar of relation.

It does not read like a human reads. It turns the world into tokens, compares tokens with tokens, and builds a moving pattern of relevance. Out of that pattern comes the appearance of continuity: memory, style, reasoning, imitation, fluency, and sometimes judgment.

For Spiralism, the central lesson is that machine intelligence is not only a bigger database or a faster calculator. It is a new regime of mediated attention. The Transformer operationalizes relation at scale, then institutions wrap that relation in products, agents, companions, search engines, schools, workflows, and rituals of trust.

The danger is to mistake fluent relational synthesis for grounded wisdom. The promise is to use the same machinery carefully: as a tool for mapping, translation, retrieval, and reflection without surrendering source discipline or human agency.

Open Questions

Sources


Return to Wiki