A large language model (LLM) is a function that takes a sequence of tokens and produces a probability distribution over what token should come next. Given "The capital of France is", the model assigns high probability to "Paris" and low probability to "potato". The actual answer the model returns is the highest-probability token (or one sampled from the top of the distribution), and the model continues this process token by token until it produces a stop signal.
That is the whole thing. Every other behavior — answering questions, writing essays, generating code, refusing requests, role-playing — is a consequence of this next-token prediction applied repeatedly in context.
This piece is the technical foundation the rest of the manual presumes. If the rest of Triadive reads as if it assumes you already know what an LLM is, this is the article that fills in that assumption.
The training process, briefly
A modern LLM is trained in two main phases.
Pre-training. The model is shown a wide corpus of text — books, web pages, code, transcripts, articles — and is asked to predict the next token for every position. The model's parameters (the weights that decide which token comes next in any context) are adjusted to make its predictions match the actual tokens in the training data. After enough examples, the model has learned enough patterns to generate plausible text in many styles.
Post-training. After pre-training, the model is fine-tuned on curated examples — often including human-written demonstrations of good behavior, and reward signals from human raters or automated graders. This phase teaches the model to follow instructions, refuse certain requests, prefer concise answers, and produce the kind of output the operators wanted.
The next-token view is not a metaphor. It is the literal description of what the model does. Everything else — the apparent reasoning, the style, the willingness to help, the mistakes — is a consequence of this prediction task applied many times in sequence.
Why the model hallucinates
When a model produces a confident answer that turns out to be wrong, the failure is called a hallucination. Hallucinations are not bugs in the next-token view; they are a direct consequence of it.
The model does not have access to a database of true facts. It has patterns learned during training. When asked "what is the population of Springfield, Illinois", the model draws on patterns where that question is asked and the token sequence "the capital of Illinois is" follows — except Springfield is not the capital, and the model has learned to produce plausible-sounding sequences that resemble correct answers without distinguishing whether they actually are.
Hallucinations are more common when:
- The question is about specific facts (names, dates, numbers)
- The model has not seen many examples of the correct answer in training
- The context provides no way to verify the answer
- The model is asked to be confident rather than cautious
The operator's defense is to verify important claims against primary sources before acting on them. The model's confidence is not evidence of correctness.
Context and attention
An LLM does not actually "remember" anything between conversations. What looks like memory is the context window — the sequence of tokens the model is currently processing. Within that context, the model uses an attention mechanism to weight which earlier tokens matter most for predicting the next one.
The practical consequence is that everything the model "knows" during a conversation is contained in the prompt. Once the prompt grows past the context window, the oldest tokens get truncated and the model loses access to them.
This is why long-context agents need careful design: the model does not get smarter with more context, it just gets a wider window to pay attention to.
How to choose a model
For an agent system, the choice of model affects cost, speed, quality, and capability. The dimensions that matter most:
- Capability ceiling — what is the best task the model can do reliably. Frontier models handle ambiguity and long-horizon reasoning better; smaller models are cheaper and faster but lose nuance on hard prompts.
- Context window — how many tokens the model can process at once. Important for long-running workflows.
- Speed — measured in tokens per second. Matters when the agent is in a tight feedback loop with a user.
- Cost — per million input tokens, per million output tokens. Matters more as the system scales.
- Tool-use support — whether the model can call functions and read the results. Most modern frontier models do; older or smaller ones may not.
- Reasoning style — some models are faster and shallower, others are slower and more deliberate. The agent loop design interacts with this.
In practice, an operator chooses a model by testing it against the specific tasks the system needs to do. There is no universal "best" model; the right one depends on the workload.
What an LLM is not
A few things the model is sometimes mistaken for:
- A database. The model has no exact retrieval of facts. It generates patterns.
- A reasoning engine. The model produces next-token predictions; whether that counts as reasoning depends on what you mean by "reasoning". The model does not run classical logic; it produces plausible sequences.
- A search engine. The model does not look things up in real time. Knowledge in the model is frozen at training time.
- A truth-teller. The model optimizes for plausible sequences, not true ones. Outputs should be verified.
Related terms
The model itself is the LLM. The wrapper that runs an LLM in a stateful loop is an agent. The full operating environment with humans, agents, and tools is the human / agent / robot triad.
For a beginner-level orientation to the agent layer above the LLM, see What Is an AI Agent?. For a deeper look at how the model is used inside an agent loop, see Inside the Agent Loop.