Much of today’s generative AI is built on an architecture called the transformer. Transformers changed how machines process language by allowing models to represent relationships between words, tokens and other pieces of information across a sequence. Large language models build on that architecture at enormous scale.

We now use AI systems to summarise documents, generate code, translate languages, answer questions, draft content and support complex workflows. Behind many of those capabilities sits the same broad technical idea: transform language into numbers, model the relationships between those numbers, and predict what should come next.
The transformer is not literally a “brain”. It is a mathematical architecture. But as a metaphor, the phrase captures why transformers matter: they form the core processing structure inside many of the AI systems people interact with today.
A transformer learns which parts of an input are relevant to one another, then uses those relationships to build increasingly useful numerical representations.
What is a transformer?
A transformer is a neural-network architecture designed to process sequences of information. It was introduced in the 2017 paper Attention Is All You Need and rapidly changed the direction of natural-language processing.
Before transformers, many language systems relied heavily on recurrent architectures that processed sequences step by step. Transformers introduced an attention-based design that made it much easier to model relationships across a sequence and to parallelise much of the training computation.
This design makes transformers especially effective for language, but transformer architectures are also used with images, audio, video and multimodal data.
Tokens: how language enters the model
A language model does not usually process text as whole sentences in the way a person reads them. The text is first converted into smaller units called tokens.
A token may represent a whole word, part of a word, punctuation or another frequently occurring text fragment.
The model works with numerical token identifiers rather than directly manipulating written words.
Different models use different tokenisation systems, so the same sentence may be divided differently by different models.
Embeddings: turning tokens into useful numbers
A token ID by itself contains very little useful meaning. The model therefore maps tokens into embeddings: vectors containing many numerical values.
These vectors allow the model to represent relationships between pieces of language in a mathematical space.
A piece of text represented by an identifier.
A vector that gives the model a richer representation of that token.
The model also needs information about where tokens occur in the sequence.
Later transformer layers update representations according to surrounding tokens.
A token’s representation is not static throughout the network. As it passes through transformer layers, the representation becomes increasingly contextual.
Why position matters
Attention alone does not inherently know whether one token came before or after another. Transformers therefore include positional information so the model can represent sequence order.
That matters because:
The tokens may be similar, but their positions fundamentally change the meaning of the sentence.
Modern transformer families use different techniques for representing positional relationships, but the purpose is the same: allow the model to understand not only which tokens are present, but how their positions relate to one another.
Self-attention: the core transformer mechanism
The most important idea inside the transformer is self-attention.
Self-attention allows each token representation to incorporate information from other relevant tokens in the same sequence.
Consider:
“The bird that flew across the sky landed gently on the roof.”
To interpret the sentence, the model needs to represent relationships between words that may be separated by several other words. The word “landed”, for example, is related to “bird”.
Attention provides a mathematical mechanism for assigning different strengths to those relationships.
Queries, keys and values
Inside an attention layer, token representations are transformed into three sets of vectors commonly called:
Represents what the current token is looking for from other tokens.
Represents information used to determine how relevant another token may be.
Represents the information that can be contributed when a token is attended to.
Combines relevance scores with value vectors to create a context-sensitive representation.
A standard scaled dot-product attention operation can be written as:
The query and key vectors produce relevance scores. Softmax converts those scores into attention weights, and those weights determine how strongly the value vectors contribute to the result.
For each token, the model asks: which other tokens matter here, how much do they matter, and what information should I take from them?
Multi-head attention: looking at relationships in different ways
Transformers do not rely on only one attention calculation. They typically use multiple attention heads.
Different heads can learn to represent different kinds of relationships. One head may become useful for short-range grammatical relationships, while another may capture longer-range contextual dependencies or other patterns.
A transformer block contains more than attention
Attention is the best-known component, but a transformer block contains additional operations.
A simplified block includes:
Large models stack many transformer blocks. As representations pass through those layers, the model can build increasingly sophisticated relationships between the tokens in the input.
What is a large language model?
A large language model, or LLM, is a model trained at substantial scale to process and generate language. Many modern LLMs use transformer architectures.
The word “large” can refer to several dimensions of scale:
- the number of learned parameters;
- the amount and diversity of training data;
- the computational resources used during training;
- the size and complexity of the resulting model and training process.
There is no single parameter count that makes a model an LLM, and not every modern model publicly discloses its exact architecture or parameter count.
Numerical values adjusted during training that shape how the model transforms information.
Large collections of text and other data provide the patterns from which the model learns.
Large-scale training relies on substantial accelerator, memory, networking and storage resources.
One trained model can often perform many tasks through prompting rather than task-specific programming.
How an LLM is trained
The exact training pipeline varies between models, but a modern language-model lifecycle can be understood in several broad stages.
Pretraining: learning by prediction
For autoregressive language models, pretraining commonly involves predicting the next token from the tokens that came before it.
The model compares its prediction with the actual next token and adjusts its parameters to improve future predictions.
Repeated across enormous datasets, this apparently simple objective can produce remarkably rich representations of language, facts, style, syntax, concepts and relationships.
It is important, however, not to describe this as straightforward human-like understanding. The model is optimising a prediction objective over numerical representations.
Post-training: making a base model more useful
A pretrained model can be powerful but may not naturally behave like a helpful assistant.
Modern AI systems therefore often undergo post-training. Depending on the system, this can include:
Train the model on examples of useful instructions and responses.
Use comparisons or preference signals to steer model behaviour towards more desirable responses.
Some systems use reinforcement-learning techniques as part of the post-training process.
Models are tested and adjusted against capability, reliability and safety objectives.
RLHF — reinforcement learning from human feedback — is one well-known approach, but it is not the only way modern models are post-trained.
Inference: what happens when you send a prompt
Training builds the model. Inference is what happens when the trained model is used.
For an autoregressive LLM, generation proceeds token by token.
This distinction matters because transformers parallelise much of their computation during training, but autoregressive text generation still produces the response sequentially: one new token becomes part of the context used to generate the next.
Context windows: how much information can the model consider?
The context window is the amount of information a model can consider within a single interaction or processing sequence.
A larger context window can make it possible to work with longer conversations, documents or collections of information. But a larger context does not guarantee that every part of that information will be used equally well.
Information present in the current context window is not the same as permanent memory. A model may also be connected to separate memory, retrieval or database systems, but those are additional service components.
Why transformers work so well
Several characteristics help explain the success of transformer-based models.
Attention allows representations to incorporate information from relevant parts of the sequence.
Transformer architectures work effectively with large datasets, substantial compute and large model capacity.
A broadly trained model can often perform many tasks through prompting or additional adaptation.
Attention-based architectures allow substantial parallel computation compared with strictly recurrent sequence processing.
But more parameters, more data or more compute do not automatically guarantee a better model. Architecture, training quality, data quality, evaluation and post-training all matter.
What can large language models do?
A single LLM can support a surprisingly broad range of tasks.
Emails, reports, summaries, explanations, structured content and other forms of text generation.
Respond to questions using model knowledge, supplied context or connected retrieval systems.
Generate, explain, review and transform code when supported by appropriate context and tooling.
Translate and transform content across languages and communication formats.
Provide a natural-language layer over processes, tools, knowledge bases and operational services.
Extract, classify, compare and summarise information from supplied material.
An LLM is not the entire AI service
It is easy to focus on the model and forget everything around it.
In a production AI-enabled service, the LLM may be only one layer.
Interfaces, prompts, workflows, tools, retrieval, routing and business logic.
Token processing, attention, learned representations and language generation.
Access, monitoring, logs, evaluation, human oversight, risk management and accountability.
A more complete AI stack might contain:
Retrieval does not retrain the model
Many AI systems connect an LLM to external documents, databases or search tools using techniques such as retrieval-augmented generation, often shortened to RAG.
Retrieval gives the model additional information at inference time. It does not automatically change the model’s trained parameters.
This distinction is important when designing enterprise AI services because updating a knowledge base can be much simpler and safer than retraining a large model.
The limits of large language models
Transformers and LLMs are powerful, but capability should not be mistaken for certainty.
A model can generate fluent, plausible information that is incorrect or unsupported.
Training and evaluation data can contain historical, cultural and representational biases.
It can be difficult to trace a complex output to a simple human-readable chain of internal causes.
Connected AI services must consider prompt injection, sensitive data exposure, permissions and tool misuse.
The model only has access to information present in its parameters, context or connected tools.
Training and operating large models can require substantial computing resources and infrastructure.
Why hallucinations happen
An LLM is fundamentally trained to generate probable continuations, not to operate as a guaranteed database of verified facts.
The model may therefore produce language that fits the statistical and contextual pattern of a good answer even when the underlying factual claim is wrong.
Fluency is not evidence. A confident-sounding answer still needs appropriate verification when the decision matters.
From transformer architecture to AI governance
Understanding transformers helps us understand why modern AI is capable. AI governance asks a different set of questions: how should those capabilities be used, monitored and controlled?
Architecture, context, capabilities, limitations, evaluation and model behaviour.
User journeys, workflow, hand-offs, evidence, escalation and human intervention.
Purpose, data, access, risk, logs, monitoring, accountability and challenge.
Useful governance questions include:
- Which model is being used, and why?
- What data can be sent to the model?
- What external tools or systems can it access?
- What evidence is retained for important outputs?
- How are hallucinations detected or mitigated?
- When must a person review the response?
- Can users challenge or correct an AI-supported decision?
- How are prompts, retrieval sources and model versions monitored?
- What happens when the model or provider changes?
- Who is accountable for the resulting service outcome?
The transformer may generate the answer, but the quality of the AI service depends on everything around it: context, workflow, tools, controls, people and accountability.
Transformers are powerful because they are general-purpose
One of the biggest changes introduced by large transformer models is that the same underlying model can support many different tasks.
Instead of building a completely separate model for every interaction, organisations can increasingly combine a general-purpose model with:
- instructions;
- retrieved organisational knowledge;
- specialist tools;
- workflow orchestration;
- business rules;
- permissions;
- human review.
That flexibility is one reason LLMs are becoming infrastructure rather than simply standalone chatbots.
Final reflections
Transformers changed modern artificial intelligence by providing an effective way to represent relationships across sequences and to scale neural-network training.
Large language models take that architecture and train it across enormous amounts of data and compute. Through tokenisation, embeddings, attention, many stacked transformer blocks and large-scale optimisation, they learn representations that can support an extraordinary range of language tasks.
But the model is only one component of a useful AI service.
Transformers explain much of how modern language AI works. Service design determines how those capabilities fit into real journeys and operations. AI governance determines how they are used responsibly and held accountable.
Understanding all three levels — architecture, service and governance — gives us a much more useful picture of modern AI than treating the LLM as a mysterious black box.
Continue reading
This article forms part of the DigiFixIT AI learning series. Continue with: