What is a large language model (LLM)?
A large language model (LLM) is a neural network trained on a very large amount of text to predict the next token in a sequence. By repeating that prediction one token at a time, it can answer questions, write code, summarise documents and follow instructions. GPT, Claude, Gemini and Llama are all LLMs.
Every answer an LLM gives is built one small piece of text at a time, each piece chosen because it is a likely continuation of everything before it. That single mechanism, repeated thousands of times, produces essays, code and conversation. Understanding it explains both what these models do well and why they fail.
How does a large language model work?
A large language model works by predicting the next token, a word or part of a word, given all the text so far. It turns the input into numbers, passes them through many layers of a neural network called a transformer, and outputs a probability for every token in its vocabulary. The application picks one token from that distribution, appends it to the text, and runs the model again. A 500-word answer takes several hundred of these steps.
The model has no separate database of facts and no memory between requests. What it "knows" is stored as patterns in its parameters, the billions of numbers adjusted during training. What it can see right now is limited to its context window.
How are LLMs trained?
Modern LLMs are trained in stages, and each stage changes what the model is good at.
- 1PretrainingThe model reads trillions of tokens of public text and code and learns to predict the next token. This is where it picks up grammar, facts, reasoning patterns and coding ability. It is by far the most expensive stage.
- 2Instruction tuningThe model is fine-tuned on examples of instructions paired with good responses, so it answers questions instead of just continuing text.
- 3Preference trainingHumans or other models compare pairs of answers, and the model is trained to prefer the better one, a family of methods that includes RLHF. This shapes tone, helpfulness and refusals.
- 4Reasoning trainingNewer reasoning models are further trained with reinforcement learning on problems with checkable answers, such as maths and code, so they learn to work through problems step by step.
The effect of the later stages is large. In OpenAI's 2022 InstructGPT paper, people preferred the outputs of a 1.3 billion parameter model trained with human feedback over the original 175 billion parameter GPT-3, even though it was more than 100 times smaller.
What makes a language model "large"?
"Large" refers to both the number of parameters and the amount of training data. GPT-3, published in 2020, had 175 billion parameters and showed that a model of that size could perform new tasks from a few examples in the prompt, without retraining. Since then, frontier models have grown further, and labs often no longer publish exact sizes. Scaling laws describe how performance improves predictably as parameters, data and compute grow together.
- Parameter
- One of the numbers inside the network that training adjusts; large models have billions
- Pretraining
- The first, largest training stage: predicting the next token on a huge text corpus
- Inference
- Running a trained model to produce output, which is what an API call does
- Foundation model
- A large model trained on broad data that many applications build on
- Open-weight model
- A model whose parameters are published so anyone can run it, such as Llama or Mistral
What can LLMs do well, and where do they fail?
LLMs are strong at tasks where the answer is a plausible, well-formed piece of language: drafting, summarising, translating, classifying, extracting fields from messy text and writing code in popular languages. They are weak wherever being plausible is not the same as being right.
| Strong at | Weak at |
|---|---|
| Rewriting, summarising and translating text | Exact arithmetic on large numbers without a tool |
| Extracting structured data from documents | Facts after their training cutoff |
| Writing and explaining common code | Obscure facts they saw rarely in training |
| Following a clear format or style | Saying "I don't know" reliably |
| Reasoning through well-specified problems | Tasks that need information not in the prompt |
The most important failure is hallucination: a fluent, confident answer that is false. It follows directly from the mechanism. The model is trained to produce likely text, and a false sentence can be very likely.
How do engineers make LLMs reliable?
Engineers make LLMs reliable by controlling what goes into the model and checking what comes out, rather than trusting the model alone. The main tools are clear prompts, retrieval to supply current facts, tool calling for calculations and live data, structured output for machine-readable answers, and evals to measure quality before and after every change.
Frequently asked questions
What is the difference between an LLM and ChatGPT?
An LLM is the underlying model. ChatGPT is a product built around LLMs, adding a chat interface, conversation history, tools such as web search, safety systems and more. Claude and Gemini are similar products built on their companies' own models.
Do LLMs understand what they are saying?
This is debated. LLMs clearly build internal representations that let them reason, generalise and follow instructions, but they do this by learning patterns in text rather than by experiencing the world. In practice, treat their output as capable but unverified.
How is an LLM different from a search engine?
A search engine retrieves existing documents and shows you where they came from. An LLM generates new text from patterns learned in training, which lets it synthesise and explain but also means it can produce statements no source supports. Many products now combine the two.
What is an open-weight LLM?
An open-weight LLM is one whose trained parameters are published, so anyone can download and run it on their own hardware. Meta's Llama and models from Mistral, Qwen and DeepSeek are examples. Closed models are only available through the provider's API.
Why do LLMs give different answers to the same question?
Because each token is sampled from a probability distribution rather than always taking the single most likely option. The [temperature](/ai-engineering/temperature/) setting controls how much randomness that sampling allows.
Last checked for accuracy on . Written by the solidcoder team.