- LLMs are neural networks trained on massive text datasets to predict the next token in a sequence.
- The transformer architecture from 2017's 'Attention Is All You Need' paper enables self-attention mechanisms in virtually all modern LLMs.
- Models are trained for months on thousands of GPUs using filtered internet text, costing tens of millions of dollars per training run.
- Reinforcement Learning from Human Feedback transforms base models into assistants by training on human preference judgments.
- The Chinchilla scaling laws showed that increasing model parameters and training data proportionally leads to predictable performance improvements.
- Well-trained LLMs can perform diverse tasks like coding, translation, and reasoning without task-specific modifications.
What Is a Large Language Model
A large language model (LLMLLMLarge Language Model — a neural network trained on vast amounts of text data that can understand and generate human-quality language across a wide range of tasks.Learn more →) is a neural network trained on massive amounts of text to predict what words come next in a sequence. That simple objective, predicting the next tokenTokenThe basic unit of text that an LLM processes — roughly corresponding to a word or word-piece. Models read input and produce output in tokens, which is also how API usage is measured and billed.Learn more →, turns out to be a remarkably powerful learning signal. To predict what word comes next, the model must learn grammar, facts, reasoning patterns, and much of what we might call knowledge about the world.
The 'large' in LLM refers to two things: the number of parametersParametersThe numerical weights inside a neural network that are learned during training — the 'knowledge' of the model, measured in billions for modern LLMs.Learn more → (the adjustable weights in the neural network) and the size of the training dataset. Modern frontier models have hundreds of billions of parameters and are trained on trillions of tokens of text. The sheer scale of training data and model size produces capabilities that smaller models do not have.
LLMs are autoregressiveAutoregressiveA text generation approach where models produce sequences one token at a time, with each new token conditioned on all previously generated tokens.Learn more → models. They generate text one token at a time, with each token conditioned on all previous tokens. A token is roughly four characters or three-quarters of a word in English. The model maintains no persistent state between generations. Each new generation starts from the beginning of the conversation context and runs the entire forward pass again. This is one of the reasons LLMs are computationally intensive at inferenceInferenceThe process of running a trained AI model to generate outputs — what happens when you send a prompt and receive a response.Learn more → time.
The transformerTransformerThe neural network architecture that underpins virtually all modern LLMs, introduced in 2017, built around self-attention mechanisms that process entire sequences in parallel.Learn more → architecture, described in the 2017 paper 'Attention Is All You Need,' is the foundation of virtually all modern LLMs. The self-attention mechanismAttention MechanismA technique that allows each token in a sequence to 'pay attention' to all other tokens, enabling the model to understand context and relationships across long distances.Learn more → allows the model to process relationships between all tokens in its context windowContext WindowThe maximum amount of text (measured in tokens) that a model can read and reason over in a single interaction, including your prompt, any documents, and previous conversation history.Learn more → simultaneously, regardless of how far apart they are in the sequence. This is what enables LLMs to take a question and a long document, understand how they relate, and answer the question accurately.
LLMs are general-purpose models. Unlike specialized systems trained for a single task, a well-trained LLM can write code, translate languages, answer factual questions, compose poetry, analyze legal documents, and engage in multi-step reasoning, all without any task-specific modification. This generality is what makes them so remarkable and so potentially valuable.
Pre-Training: Learning from the Internet
Pre-training is the first and most resource-intensive phase of building an LLM. The model is trained on a massive corpus of text, typically hundreds of billions to trillions of words drawn from the internet, books, scientific papers, code repositories, and other sources. The training objective is simple: given the preceding tokens, predict the next token. The model is repeatedly shown text, generates predictions, compares them to the actual next tokens, and updates its weights to make better predictions.
The training corpus is not simply a raw dump of everything on the internet. Quality filtering removes spam, machine-generated text, adult content, and other undesirable material. Deduplication removes repeated content, which is important because the model should not memorize specific documents but rather learn generalizable patterns. Language filtering ensures appropriate language balance. The composition of the training corpus has a profound effect on what the model knows and how it reasons.
Training a frontier LLM takes months on a cluster of thousands of specialized GPUs. The total compute required is measured in floating-point operations, typically in the range of tens to hundreds of zettaflops for frontier models. The cost of a single training run is tens of millions of dollars. This creates a significant barrier to entry and concentrates frontier modelFrontier ModelThe most advanced and capable AI models at the cutting edge of the field, typically developed by well-funded research labs with massive computational resources.Learn more → development in a small number of well-capitalized organizations.
Scaling lawsScaling LawsEmpirical power-law relationships showing how model performance improves predictably with increases in model size, training data, and compute resources.Learn more → describe how model performance improves with scale. Empirically, increasing the model size (number of parameters) and the amount of training data, in proportion, leads to predictable improvements in performance on language benchmarks. The Chinchilla scaling laws, published by DeepMind in 2022, showed that previous large models had been undertrained: they had more parameters than was optimal for their compute budget, and would have performed better if they had been trained on more data with fewer parameters at the same total compute cost.
Pre-training produces a base model, sometimes called a foundation modelFoundation ModelA large AI model trained on broad data at massive scale that can be adapted to a wide variety of downstream tasks, forming the 'foundation' for specialized applications.Learn more →. A base model is very good at completing text in the style of whatever it was trained on. It is not yet useful as an assistant. Given a question, a base model might respond with more questions, or with a list of similar questions from its training data, rather than answering. The next phases of development transform the base model into a usable assistant.
Fine-Tuning and RLHF
Supervised fine-tuningSupervised Fine-TuningSupervised Fine-Tuning (SFT) is the process of training a pre-trained base model on curated instruction-response pairs to teach it specific tasks before preference alignment.Learn more → (SFT) is the first step in transforming a base model into an assistant. Human contractors write examples of ideal assistant behavior: questions with high-quality answers, instructions with complete and helpful responses. The model is trained on these examples to imitate the demonstrated behavior. SFT significantly changes the model's output distribution, making it much more likely to produce helpful, direct responses.
Reinforcement Learning from Human Feedback (RLHFRLHFReinforcement Learning from Human Feedback — a training technique that uses human preferences to teach AI models to be helpful, honest, and harmless.Learn more →) goes further. Human raters compare pairs of model outputs and indicate which they prefer. These preference judgments are used to train a reward modelReward ModelA model trained on human preference data that scores AI outputs, enabling reinforcement learning systems to optimize for human-aligned responses.Learn more →, a separate neural network that predicts which outputs humans would prefer. The language model is then fine-tuned using reinforcement learning to maximize the reward model's score.
RLHF was the key innovation that transformed GPTGPTGenerative Pre-trained Transformer — the model architecture and family name behind OpenAI's most famous models, from GPT-2 to GPT-5.Learn more →-3, a powerful but hard-to-use base model, into InstructGPT and ultimately ChatGPT. The paper describing InstructGPT showed that a 1.3 billion parameter model fine-tuned with RLHF was preferred by human raters over a 175 billion parameter model fine-tuned without RLHF on many tasks. AlignmentAlignmentThe process of ensuring AI models behave according to human values and intentions through training techniques, evaluation methods, and safety measures.Learn more → through human feedback was more important than raw model scale.
Constitutional AI, developed by Anthropic, is an alternative alignment approach. Rather than relying on human preference judgments for every training signal, the model is trained using AI-generated feedback based on a set of explicit principles (the 'constitution'). The AI critiques and revises its own outputs according to these principles. This reduces the labor required for human feedback while maintaining alignment with human values.
Direct Preference OptimizationDirect Preference OptimizationA training method that aligns language models with human preferences directly from preference pairs, bypassing the need for separate reward models or reinforcement learning.Learn more → (DPO), introduced in 2023, offers a simpler alternative to RLHF. Rather than training a separate reward model, DPO directly optimizes the language model's policy to increase the probability of preferred responses and decrease the probability of dispreferred ones. It achieves comparable alignment results with a simpler training pipeline. Most frontier models now use some variant of DPO or related techniques.
Architecture: Tokens, Embeddings, and Layers
Text is converted into tokens by a tokenizer before being fed to an LLM. A tokenizer breaks text into subword units using algorithms like Byte-Pair EncodingByte-Pair EncodingA subword tokenization algorithm that iteratively merges the most frequent pairs of bytes or characters to build a vocabulary that balances size and sequence length.Learn more → (BPE) or SentencePiece. Common words are often a single token. Rare words are split into multiple tokens. The tokenizer's vocabularyVocabularyThe fixed set of tokens (words, subwords, characters) that a language model can recognize and generate, typically ranging from thousands to millions of unique elements.Learn more → is fixed at training time, typically containing 30,000 to 100,000 tokens. The choice of tokenizer affects how efficiently different languages and domains are represented.
Each token is mapped to an embeddingEmbeddingA numerical vector representation of text, code, or images that captures semantic meaning — similar items have similar vectors, enabling search, clustering, and retrieval.Learn more → vector, a high-dimensional numerical representation. Embeddings capture semantic relationships: words with similar meanings have similar embeddings. The embedding dimension of frontier models is typically in the range of 4,000 to 12,000 dimensions. The embedding layer is learned during training and encodes much of the model's basic knowledge about language.
The transformer layers process the sequence of token embeddings. Each layer consists of a multi-head self-attention block and a feedforward network, with residual connections and layer normalizationLayer NormalizationA normalization technique that standardizes activations across features within each layer to stabilize training and improve convergence speed.Learn more →. The self-attention block allows each token to attend to all other tokens in the context. The feedforward network applies a learned transformation to each token independently. Information is progressively integrated and transformed through the layers.
The context window is the maximum number of tokens the model can process in a single forward pass. Early LLMs had context windows of 2,048 tokens. Recent frontier models have context windows of 128,000 (128K) to 1,000,000 (1M) tokens. A larger context window allows the model to work with longer documents, maintain longer conversation histories, and process more code at once. Extending context windows is technically challenging because the quadratic complexity of self-attention becomes prohibitive at very long sequences.
After the final transformer layer, a linear projection maps the output embeddings to a vocabulary-sized vector, and a softmaxSoftmaxA mathematical function that converts a vector of raw logits into a probability distribution, with temperature controlling the sharpness of the output.Learn more → function converts these to probabilities over all tokens in the vocabulary. The token with the highest probability is selected as the next token, though in practice a samplingSamplingThe method used to select each next token from a probability distribution during text generation, controlling the randomness and creativity of model outputs.Learn more → strategy with a temperatureTemperatureA parameter controlling the randomness of model outputs — lower values produce more focused, deterministic responses; higher values produce more creative, varied text.Learn more → parameter is used to introduce appropriate randomness. Temperature controls the sharpness of the probability distribution: low temperature makes the model more deterministic, high temperature makes it more varied.
Emergent Capabilities
One of the most striking and controversial aspects of large language models is the emergence of capabilities that were not explicitly trained. As models scale, new abilities appear suddenly, qualitatively changing what the model can do. These are called emergent capabilities. Examples include multi-step arithmetic, chain-of-thought reasoning, in-context learningIn-Context LearningThe ability of an LLM to learn from examples provided directly in the prompt, without any weight updates or training — just from seeing patterns in context.Learn more → from a few examples, and the ability to follow complex instructions.
In-context learning is perhaps the clearest example of emergence. Given a few examples of a task in the promptPromptThe input text sent to a language model — the question, instruction, or context that triggers a response.Learn more →, a large model can generalize to new instances of that task without any weight updates. A small model given the same examples cannot. This capability appears abruptly at around 100 billion parameters and improves further with scale. It is not clear from first principles why training on text prediction should produce this capability. It simply emerges.
Chain-of-thought reasoning, where the model reasons through a problem step by step before giving a final answer, significantly improves performance on multi-step reasoning tasks. Smaller models do not benefit from chain-of-thought prompting. For large models, it can be transformative, increasing accuracy on math word problems and logical reasoning by substantial margins. The model is using its own generated text as an external workspace for computation.
The concept of emergence is debated. Some researchers argue that many apparent emergences are artifacts of how capabilities are measured. If you measure performance on a binary correct/incorrect metric, improvement can appear suddenly even when the underlying model probability improves smoothly. Other researchers argue that there are genuine phase transitions in model capability as scale increases. The debate has not been fully resolved.
Emergent capabilities are important practically because they mean that evaluating a model at one scale gives limited information about what a larger model will be able to do. Capabilities that seem absent at one scale may appear suddenly at larger scales. This makes it difficult to predict what frontier-scale models will be able to do before they are trained. It is one of the factors that makes the trajectory of AI development hard to forecast.
Hallucination: Why LLMs Make Things Up
HallucinationHallucinationWhen an AI model generates text that is factually incorrect, fabricated, or unsupported by its context, stated with confident fluency as if it were true.Learn more → is the phenomenon where an LLM generates text that is factually incorrect but stated with apparent confidence. The model might cite a paper that does not exist, attribute a quote to the wrong person, describe events that never happened, or invent technical specifications for a product. Hallucination is one of the most significant reliability challenges facing LLMs in high-stakes applications.
The fundamental cause of hallucination is that LLMs are trained to generate plausible text, not necessarily true text. The training objective is next-token prediction: predict what word comes next in a sequence drawn from the training corpus. The training corpus itself contains misinformation, inconsistencies, and biases. The model learns to generate text that looks like the training corpus, including plausible-sounding but incorrect claims.
The confidence problem compounds this. LLMs do not have direct access to their own uncertainty. A language model assigns some probability to every possible next token, but the probability mass for incorrect tokens is not zero. When a model encounters a question about something it has seen rarely or inconsistently in training, it may generate a confident-sounding answer that happens to be wrong, because it lacks any mechanism for detecting its own knowledge gaps.
Several techniques reduce hallucination. Retrieval-Augmented Generation (RAGRAGRetrieval-Augmented Generation — a technique that enhances LLM responses by first retrieving relevant documents from an external knowledge base and including them in the prompt.Learn more →) provides the model with relevant passages from a knowledge base before asking it to answer a question. This grounds the generation in source material that can be verified. RLHF training can be tuned to reward hedging and uncertainty expression. Chain-of-thought prompting can expose reasoning errors that would otherwise be hidden in a direct answer. Constitutional AIConstitutional AIAnthropic's technique for training safe AI models using a written set of principles (a 'constitution') that the model uses to evaluate and revise its own outputs.Learn more → explicitly trains models to acknowledge uncertainty.
Hallucination rates vary significantly across models and tasks. Factual question answering about well-documented topics in the training data has low hallucination rates. Questions about obscure topics, recent events, or technical details at the edge of the training distribution have higher hallucination rates. Applying LLMs to high-stakes tasks like medical diagnosis, legal analysis, or financial advice requires robust hallucination mitigation strategies and should always involve human verification.
Context Windows and Memory
The context window is the amount of text an LLM can process in a single forward pass. Everything the model knows about the current conversation or task must fit within this window. Early GPT-3 had a context window of 4,096 tokens, roughly 3,000 words. Claude 3.5 has a 200,000-token context window. Llama 4 Scout has a 10 million-token context window. The expansion of context windows has been one of the most significant practical improvements in LLMs over recent years.
A larger context window enables longer documents to be analyzed, longer conversation histories to be maintained, larger codebases to be processed, and more examples to be included in the prompt for in-context learning. Many practical limitations of early LLMs, such as forgetting earlier parts of a conversation or being unable to answer questions about long documents, were context window limitations. Expanding the window addresses these limitations directly.
But context windows are not free. The quadratic complexity of self-attention means that processing a context twice as long requires four times as much computation. Techniques like Grouped Query Attention (GQA) and Sliding Window Attention reduce this computational cost for very long contexts. But there are fundamental limits to how efficiently long-context processing can be done with the standard transformer architecture.
The 'lost in the middle' problem is a known issue with long contexts. Models tend to attend more strongly to tokens at the beginning and end of the context window. Information buried in the middle of a very long contextLong ContextThe ability of AI models to process extremely large inputs spanning tens of thousands to millions of tokens, enabling comprehensive analysis of entire documents, codebases, or datasets in a single context.Learn more → is attended to less reliably. This means that while a model may technically have a 200K token context window, performance may degrade for information that is many thousands of tokens from the beginning or end of the context.
LLMs have no persistent memory between conversations. Each new conversation starts with an empty context. This means the model does not remember previous interactions with a user unless a summary or the full previous conversation is included in the current context. External memory systems, where important information is stored in a vector databaseVector DatabaseA database optimized for storing and searching embedding vectors, enabling fast semantic similarity search across millions of text chunks or documents.Learn more → and retrieved into the context as needed, are the standard approach to giving LLMs something like long-term memory.
Multimodality: Beyond Text
The most capable current LLMs are not limited to text. They can process images, audio, and video, and many can generate images and audio as well as text. These multimodalMultimodalCapable of processing and generating multiple types of data — such as text, images, audio, and video — within a single model.Learn more → models represent an extension of the transformer architecture to handle different types of input and output, each requiring its own encoding and decoding machinery.
Vision language models (VLMs) process images by dividing them into patches and encoding each patch as a token. These visual tokens are then combined with text tokens in the same transformer. The model can attend across text and images simultaneously, enabling tasks like describing an image, answering questions about an image, or reading text in an image. GPT-4V, Claude 3, and Gemini are all vision language models.
Audio processing follows a similar pattern. Speech is converted to a spectrogram, a two-dimensional representation of how energy is distributed across frequencies over time. Transformers trained on spectrograms can perform automatic speech recognition, speaker identification, and sound classification. OpenAI's Whisper is an example of a highly capable speech recognition model based on this approach.
Generating images from text descriptions requires different architectures. Diffusion models, which learn to reverse a process of progressively adding noise to images, have become the dominant approach for image generation. They are often combined with a text encoderEncoderThe transformer component that processes input sequences into contextual representations, forming the foundation of understanding-focused models like BERT.Learn more → based on a transformer, allowing text prompts to guide the denoising process. DALL-E 3 and Midjourney are based on this approach.
Native multimodality, where a single model architecture processes all modalities together during training, produces better models than combining separately trained models. When a model learns from text and images jointly, it can develop representations that capture multimodal relationships, such as understanding that the word 'red' refers to a visual property. GPT-4o and Gemini Ultra are natively multimodal, trained on text and images simultaneously rather than as separate systems joined after training.
How to Compare Models
Evaluating LLMs is harder than it might seem. Academic benchmarks measure specific, narrowly defined capabilities. A model that tops the leaderboard on MMLUMMLUA comprehensive benchmark evaluating language models across 57 academic subjects from elementary to professional level using multiple-choice questions.Learn more → (broad factual knowledge) or HumanEvalHumanEvalA benchmark dataset of 164 Python programming problems used to evaluate code generation capabilities of language models through unit test pass rates.Learn more → (Python code generation) may underperform another model on your specific use case. The most important evaluations are the ones you run on your own tasks, with your own prompts, measuring what matters for your application.
Standardized benchmarks provide a useful starting point. MMLU tests knowledge across 57 subjects from elementary mathematics to professional law and medicine. GPQAGPQAA graduate-level, 'Google-proof' multiple-choice benchmark of hard science questions designed to resist easy lookup and test deep reasoning.Learn more → tests graduate-level science reasoning. HumanEval and SWE-BenchSWE-BenchA benchmark that measures an AI agent's ability to resolve real GitHub issues from open-source repositories — a rigorous test of practical software engineering capability.Learn more → test coding ability. HellaSwagHellaSwagA commonsense reasoning benchmark where AI models must select the most plausible continuation from four options for everyday scenarios.Learn more → tests commonsense reasoning. MATH and AIMEAIMEAIME (American Invitational Mathematics Examination) problems are challenging high-school competition math questions used to evaluate advanced mathematical reasoning capabilities in AI models.Learn more → test mathematical problem-solving. Models that do well across multiple benchmarks are generally more capable.
Human preference evaluations are an important complement to benchmarkBenchmarkA standardized test or set of tasks used to evaluate and compare the capabilities of different AI models on a common scale.Learn more → scores. The LMSYS Chatbot ArenaChatbot ArenaA public platform where users anonymously compare language models in head-to-head battles, with results aggregated into Elo ratings to create crowdsourced leaderboards.Learn more → asks humans to compare pairs of model outputs without knowing which model produced each, then uses these comparisons to produce an Elo ratingElo RatingA rating system borrowed from chess that ranks AI models based on head-to-head comparisons from human preference battles.Learn more →. This captures aspects of quality that are difficult to measure with automated benchmarks, such as tone, naturalness, and helpfulness. Models that top the Elo leaderboard are generally considered the most pleasant to interact with.
Speed and cost matter enormously in practice. A model that is 10% more capable but costs 5x as much and has 3x the latencyLatencyThe delay between sending a request to an LLM and receiving the first token of the response, often measured as Time to First Token (TTFT).Learn more → may be the wrong choice for most applications. Measuring tokens per secondTokens per SecondTokens per second measures how quickly an LLM generates text during inference, serving as the primary throughput metric for comparing model speed.Learn more →, time to first tokenTime to First TokenTime to First Token (TTFT) measures the latency from sending a request to receiving the first streamed token, primarily determined by the prefill phase.Learn more →, and cost per thousand tokens on your specific usage patterns is as important as measuring quality. The model you choose is a product of capability, cost, and speed together.
Running the same prompt across multiple models simultaneously is the most direct way to compare them. Tools like Keimodel let you do exactly that: submit a single prompt and see every model's response side by side. The differences between models that look similar on paper often become immediately apparent when you compare their actual outputs on your actual tasks. No benchmark captures this kind of task-specific comparison.
The Future of LLMs
The trajectory of LLM development points toward systems that are more capable, more efficient, and more integrated into workflows. Reasoning capabilities, where models spend more compute at inference time to think through difficult problems, are improving rapidly. Models that can engage in hours of extended reasoning on complex problems, rather than seconds of fast pattern matching, represent a qualitative change in capability.
AgentAgentAn LLM-powered system that can take actions, use tools, and pursue multi-step goals autonomously without human input at each step.Learn more → systems, where LLMs use tools and take sequences of actions to complete long-horizon tasks, are the next major application area. An LLM that can browse the web, write and execute code, manage files, send emails, and coordinate with other AI systems represents a fundamentally different kind of tool than a chatbot. Building reliable, safe, and capable agents is the central engineering challenge of the next several years.
Multimodal reasoning, combining language, vision, audio, and other modalities in integrated reasoning chains, will become standard. A model that can watch a video, read a document, examine a spreadsheet, and synthesize insights across all three modalities is dramatically more useful than a model limited to text. The infrastructure for this kind of multimodal reasoning is being built now.
Efficiency improvements will continue to make frontier capabilities more accessible. DistillationDistillationA technique where a smaller student model is trained to replicate the behavior of a larger teacher model, achieving similar performance with reduced computational requirements.Learn more → produces compact models that inherit much of the capability of much larger models. QuantizationQuantizationA compression technique that reduces model size and inference cost by storing weights in lower-precision numerical formats, trading a small amount of accuracy for much lower memory and compute requirements.Learn more → makes large models run on consumer hardware. Speculative decodingSpeculative DecodingA technique where a small draft model proposes multiple tokens that a larger model verifies in parallel, maintaining identical output while reducing generation latency.Learn more → speeds up inference without changing outputs. These techniques ensure that the gains achieved at the frontier propagate down to smaller, cheaper, more widely deployed systems.
The longer-term trajectory raises more fundamental questions. If LLMs continue to improve at their current rate, how far do they go? Artificial general intelligence, broadly defined as AI that can perform any cognitive task a human can perform, is explicitly the goal of several major labs. Whether current LLM architectures can achieve AGI through scaling, or whether fundamentally new ideas are needed, is the most important open question in AI research.