Blog / Build with AI /
How large language models work, explained simply
A large language model (LLM) is a program trained on a huge amount of text to predict what text should come next. That’s the whole trick, and everything else follows from it: the fluent writing, the working code, the confident mistakes.
You don’t need a degree to understand the basics. And if you build tools or run websites with AI, knowing the basics will save you from several expensive misunderstandings. This guide keeps it plain.
The core idea: predicting the next piece
Think of the autocomplete on your phone. You type “See you at” and it suggests “the”, “home” or “7”. It has learned, from lots of text, what tends to follow.
An LLM is that idea at enormous scale. It has read a vast amount of writing, including books, articles, websites, discussion threads and code, and learned the patterns of language deeply enough to continue almost any text sensibly.
Ask it a question and, in effect, it is answering “what would a good reply to this look like?”, one small piece at a time.
Step 1: text becomes tokens
Models don’t read words the way we do. They break text into tokens: chunks that may be a whole word, part of a word, or a piece of punctuation. A common word like “the” is one token. A rare or long word may be split into several.
Why it matters:
- Cost and limits are counted in tokens, not words. How AI pricing works: tokens explained goes into this.
- Different languages use tokens differently. Some languages need more tokens to say the same thing, which affects cost and how much fits in one request.
- Odd mistakes follow from it. A model sees chunks, not letters, so counting the letters in a word can trip it up.
Step 2: tokens become meaning
Each token is turned into a long list of numbers that represents its meaning in relation to other tokens. Words used in similar ways end up with similar numbers. “Doctor” sits near “nurse”; “bank” sits near different things depending on whether the sentence is about money or a river.
You can picture a vast map where related ideas sit close together. The model doesn’t hold definitions the way a dictionary does. It holds relationships.
Step 3: attention decides what matters
The key design behind modern LLMs is called a transformer, and its central trick is attention: when the model works out the next token, it looks back at all the earlier tokens and weighs which ones matter most.
Take: “The trophy didn’t fit in the suitcase because it was too big.” What does “it” refer to? Attention helps the model link “it” to “trophy”. Change the sentence to “…because it was too small” and “it” now points to the suitcase. Handling that kind of link, across long stretches of text, is what made these models so capable.
Step 4: the prediction
After all this processing, the model produces a set of probabilities for the next token. “Paris” might be very likely after “The capital of France is”, with tiny chances for other options.
It then picks one. How it picks is controlled by settings like temperature: low temperature favours the most likely token and gives steady, predictable answers; higher temperature allows more variety and surprise. Temperature and creativity settings explained covers it, and it’s why AI answers change every time you ask.
The chosen token is added to the text, and the whole process repeats for the next token, and the next, until the reply is complete.
How it learns: training
Training is how the model gets its abilities. In simplified terms:
- Pre-training. The model is shown enormous amounts of text with words hidden, and learns to predict the missing parts. It repeats this billions of times, adjusting its internal numbers (called parameters or weights) a tiny bit each time to get less wrong.
- Fine-tuning and feedback. The raw model is then trained further on examples of helpful conversations, and often refined using human feedback about which answers are better. This is what turns a text-continuer into something that behaves like an assistant. For more on adapting models, see fine-tuning explained for non-developers.
Two consequences are worth knowing:
- Its knowledge has a cut-off. The model knows what was in its training data and nothing after, unless it’s given tools like search or documents to read.
- It doesn’t “look things up” by default. Its knowledge is baked into the numbers. That’s why it can get facts wrong without realising.
An analogy
Imagine someone who has read an enormous library but is now locked in a room with no books, no internet and no way to check anything. You slip questions under the door, and they write answers from memory and from a deep feel for how language works.
They’ll be brilliant at many questions. They’ll be fluent on all of them. And on a few, they’ll fill gaps with plausible-sounding invention, because stopping to say “I don’t know” isn’t what their training mostly rewarded.
That is a decent mental model of an LLM.
Why it sounds confident when it’s wrong
The model is always producing the most plausible continuation. Plausible and true overlap a lot, but they aren’t the same. When it meets a gap, such as an obscure fact, a recent event or a detail it never saw, it still produces something that sounds right. People call this hallucination.
It’s not lying in the human sense, because it has no intent. It’s doing what it does: generating likely text. That’s why important facts, numbers, quotes and citations from AI need checking against a real source.
What this means for people who build with AI
- Give it context. It only knows what is in the conversation plus its training. The more relevant material you put in the request, the better the answer. System prompts explained for non-developers shows one way to do that.
- Be specific. It predicts from your words. Vague prompts produce average answers.
- Verify anything that matters. Facts, figures and anything legal, financial or medical.
- Use it where it shines: drafting, rewording, summarising, explaining, brainstorming and writing code. Be cautious where exactness is the whole point, such as arithmetic.
- Expect variation. The same prompt may not return the same answer.
- Mind privacy. What you type may be sent to a company’s servers. Check the terms before pasting anything sensitive.
- Keep a human in the loop for anything customer-facing.
What it means for someone running a website
LLMs now sit inside search tools, chat assistants and writing tools. They summarise pages, answer questions and generate drafts. For a site owner, that has two implications. First, content that is clear, specific and trustworthy is easier for both people and AI systems to use correctly. Second, AI-generated text without checking can put errors on your site that you’d never knowingly publish. Use it as a first draft, not a final one.
Common myths
“It understands like a person.” It models language patterns very well. Whether that amounts to understanding is debated, but it doesn’t have experiences, intentions or a body.
“It stores and copies the internet.” It doesn’t keep a database of pages to retrieve. It learned statistical patterns, though it can sometimes reproduce passages it saw often.
“Bigger is always better.” Size helps, but smaller models can be good enough for focused jobs, and cheaper and faster too.
“It’s just autocomplete.” The core mechanism is prediction, but at this scale and with this training, it can do things simple autocomplete cannot. Both halves of that sentence are true.
“If it sounds sure, it’s right.” Tone is not evidence.
FAQ
Do language models think?
They process text and produce outputs through learned patterns. Whether to call that thinking is a philosophical question. For practical purposes, treat them as powerful pattern-based tools, not as minds.
Why do they need so much computing power?
Because they hold billions of numbers that all take part in producing each token. Training involves adjusting those numbers over vast amounts of text, which takes enormous computing resources. Running a trained model is cheaper, but still heavy for the largest ones.
Can an LLM learn from my conversation?
Within one conversation, it can use what you’ve said. It doesn’t permanently change its underlying numbers because of your chat, though providers may use conversations to improve future models, depending on their settings and policies. Check the privacy terms.
What is a “context window”?
The amount of text a model can consider at once, measured in tokens. Beyond it, earlier parts are forgotten or cut off.
Key takeaways
- An LLM predicts the next token, over and over, using patterns learned from huge amounts of text.
- Tokens, meaning, attention and probability are the four ideas to remember.
- It sounds confident because fluency is what it’s built for; accuracy needs checking.
- Give it context, be specific, verify what matters and mind privacy.
Related reading
Which part of this surprised you most?