AI Fundamentals

How ChatGPT and Large Language Models Work

A structured walkthrough of how large language models are trained, how tokens and prediction work, and where these systems break down.

15 min read · InfoGridCore

What a Large Language Model Actually Is

A large language model, or LLM, is a statistical system trained to predict the next piece of text given some preceding text. Despite the conversational feel of tools like ChatGPT, the underlying machinery is doing something narrower and more mechanical than it appears: estimating, at every step, which fragment of language is most likely to come next.

The word large refers to two things at once. First, the model itself contains billions of internal parameters — numerical weights that determine how it transforms input into output. Second, the training dataset is enormous, typically composed of substantial portions of publicly available text drawn from books, websites, and other written sources.

Training Data and What It Means

Before an LLM can answer questions, it goes through a long training process. During training, the model is shown text and repeatedly asked to predict missing or upcoming words. Each time it guesses, its internal weights are adjusted very slightly to make better guesses next time. Repeated billions of times across enormous amounts of text, this simple procedure produces a model that has absorbed an extraordinary amount of statistical knowledge about language.

The composition of the training data matters more than most users realize. The model can only learn from what it sees, and the proportions, quality, and recency of that data shape everything the model can do. A topic well represented in the training set is likely to be handled fluently; a topic that is rare, contested, or absent will be handled poorly or fabricated.

Training data also has a cutoff date. After that date, the model has no information about world events unless it is connected to external tools such as search engines. This is why a chat assistant might confidently describe something that has since changed.

Tokens: The Real Unit of Language

Language models do not see words. They see tokens, which are short fragments of text — sometimes a whole word, sometimes part of one, sometimes a punctuation mark. The sentence "Understanding helps" might be split into three or four tokens, depending on the tokenizer.

This matters because the model's memory and pricing are measured in tokens, not words. A long document might be tens of thousands of tokens. Each model has a context window — a maximum number of tokens it can consider at once. Information that falls outside this window is, from the model's perspective, simply not there.

Tokens also explain why models sometimes stumble over uncommon words, names, or numbers. Rare tokens are harder for the model to predict accurately, which is why arithmetic, exotic proper nouns, and specialized jargon are common failure points.

The Prediction System Inside

At inference time — when you are using the model — it works one token at a time. You provide a prompt, the model computes a probability distribution over all possible next tokens, and one is sampled. That token is appended to the input, and the process repeats until a stopping condition is reached.

The architecture that makes this practical is called the transformer. Without going into the mathematics, the key idea is attention: at each step, the model can weight different parts of the preceding text differently. This allows it to remain coherent over long passages and to keep track of who, what, and when the conversation is about.

Modern chat models also go through a second phase of training called alignment or instruction tuning, often with human feedback. This phase teaches the raw model to follow instructions, avoid certain kinds of harmful output, and present its responses in a helpful format. The base predictive engine is the same; the conversational behavior is layered on top.

Where Language Models Fail

Because LLMs are trained to produce plausible text, they will produce plausible text even when they have no reliable knowledge. This is the source of what is commonly called hallucination: confident, well-formed answers that are simply wrong. The model is not lying; it is doing exactly what it was built to do, which is to generate likely-sounding continuations.

Other consistent limitations include weak arithmetic and counting, unreliable citation of sources, sensitivity to how questions are phrased, and the absence of any genuine understanding of cause and effect. The model has no body, no senses, and no memory of past conversations unless explicitly given one through an external system.

These are not bugs that a future patch will quietly fix. They are properties of the underlying approach. Mitigations exist — retrieval systems, calculator tools, verification steps — but the model itself remains a predictor of likely text.

Using LLMs Intelligently

The most reliable way to use a language model is to treat it as a knowledgeable but error-prone assistant rather than an authoritative source. It excels at drafting, summarizing, brainstorming, translating, and structuring information. It is far less reliable when asked to recall specific facts, perform precise calculations, or reason about events outside its training data.

Clear, specific prompts tend to produce clear, specific answers. Providing relevant context, asking the model to show its reasoning, and verifying important outputs against trusted sources are not optional polish — they are essential parts of working with this technology responsibly.

You may also like

Three connected articles to deepen this thread.