What is a large language model (LLM)? A beginner's guide

The engine behind ChatGPT, Claude and Gemini does one surprisingly simple thing, billions of times over. Here is what it is, how it learns, and why it sometimes gets things wrong.

Illustration of a stack of books and documents feeding a friendly machine labelled LLM. A person at a laptop types "The capital of India is", and a panel shows the machine's guesses for the next word, with "New" at 91 percent.
Fig. 1 — An LLM learns patterns from huge amounts of text, then predicts what comes next, one piece at a time.

Start typing a message on your phone and it suggests the next word. Type “Happy” and it offers “birthday”. Type “See you” and it offers “tomorrow”. Your keyboard has noticed which words usually follow which, and it is guessing.

Now imagine a guesser that has read a large part of the internet, millions of books and huge amounts of code, and has become very good at that one game: what comes next? Ask it a question, and its best guess for what comes next is a good answer. That, in one paragraph, is a large language model, or LLM.

This guide explains what an LLM is, where it fits in the world of AI, how it actually produces an answer, how it learns, and why it sometimes says things that are confidently wrong. You don’t need any maths or coding background.

What is a large language model?

A large language model is an AI model trained on enormous amounts of text to predict what comes next. Given some text, it works out which piece of text is most likely to follow, adds it, and repeats.

Every part of the name tells you something:

  • Large: it contains billions of learned numbers, and it was trained on trillions of words.
  • Language: it works with text: questions, answers, essays, emails, code.
  • Model: it is a program whose behaviour comes from numbers it learned from data, not from rules a person wrote by hand.

ChatGPT, Claude, Gemini, Copilot and Llama are all built on LLMs. When you chat with one of these tools, an LLM is the part doing the thinking (or, more precisely, the predicting).

Where LLMs fit in the world of AI

“AI”, “machine learning”, “neural networks” and “generative AI” get used as if they mean the same thing. They don’t. Each one sits inside the one before it, like a set of boxes.

Nested boxes: artificial intelligence contains machine learning, which contains neural networks and deep learning, which contains generative AI, which contains large language models such as ChatGPT, Claude, Gemini and Llama.
Each idea sits inside the one before it. An LLM is a very specific kind of AI.
  • Artificial intelligence (AI) is the big umbrella: computer systems that do tasks which normally need human intelligence, such as recognising faces, predicting traffic, deciding which email is spam, or writing text.
  • Machine learning (ML) is a kind of AI that learns patterns from examples instead of following rules a person wrote. Rather than coding “if the email mentions a lottery, it’s spam”, you show it thousands of emails labelled spam and not spam, and it works out the pattern itself.
  • Neural networks are a kind of machine learning model built from many small connected units, a bit like the neurons in a brain, arranged in layers. Deep learning simply means neural networks with many layers.
  • Generative AI is AI that creates new content (text, images, music, code) instead of only sorting things into categories.
  • Large language models are generative AI models that work with text.

So an LLM is a neural network, trained with machine learning, that generates text. Everything you will read below follows from that. (New to these ideas? Our guide to what artificial intelligence is explains machine learning and neural networks from scratch.)

The one trick: predicting the next token

Here is the idea that surprises most people. An LLM does not plan its answer, write a draft, and then show it to you. It writes one small piece at a time.

Say you ask, “What is Java?” The model looks at your question and predicts the most likely first piece of the answer: “Java”. It adds that piece to the text. Then it looks at everything again (your question plus “Java”) and predicts the next piece: “is”. Then “a”. Then “programming”. Then “language”. It keeps going like that until it predicts that the answer is finished.

Five rows showing an answer being built. Each row sends the text so far into the LLM, which outputs one next token with a chance: Java 41 percent, is 78 percent, a 86 percent, programming 64 percent, language 93 percent. Each token is added to the next row.
Predict, add, repeat. The percentages are illustrative.

That really is the heart of it. Every answer an LLM has ever given, every email it has drafted and every program it has written, was produced this way: predict the next token, add it, repeat. The intelligence you see comes from how good those predictions are.

How it chooses: chances, not certainties

When the model predicts, it doesn’t produce just one answer. It gives every token it knows a score, and then turns those scores into chances that add up to 100%. For “The capital of India is”, it might give “New” a 91% chance, “the” 4%, “a” 2%, and tiny chances to thousands of other tokens.

Then one token is picked. Usually the likely one wins, but not always: the model often samples, which means it picks by chance, weighted by those percentages. Think of a jar of marbles: 91 marbles say “New”, 4 say “the”, 2 say “a”. You reach in without looking. You will nearly always pull out “New”, but not every single time.

This is why asking the same question twice can give you two differently worded answers. It is also why AI tools have a setting called temperature:

  • Low temperature makes the likely tokens even more likely. Answers become predictable and consistent, which is good for facts and code.
  • High temperature evens the chances out, so less likely tokens get picked more often. Answers become more varied and creative, and more likely to wander off.
“An LLM never decides “the answer”. It only ever says how likely each next token is.”

Where does its knowledge come from? Training

So how does the model know that “New” should follow “The capital of India is”? Nobody typed that fact in. It learned it.

Inside an LLM are billions of numbers called weights (also called parameters). Before training, they are random, and the model’s predictions are nonsense. Training fixes that, one tiny step at a time:

  1. Take a real piece of text, for example “my puppy name is river”.
  2. Hide the next word and ask the model to predict it. After “my”, what comes next?
  3. Compare its guess with the real answer (“puppy”).
  4. Nudge the weights slightly, so that next time “puppy” gets a higher score after “my”.
  5. Repeat, across trillions of words.
Two grids of numbers. Before training, the grid holds small random values. After training on the sentence 'my puppy name is river', the cell for each word's real next word holds a high value, such as 2.89 for my followed by puppy, and the other cells are negative.
A toy model with 16 weights. Training turns random numbers into numbers that score the real next word highly.

After enough nudges, the numbers stop being random. They now capture patterns from the text: which words follow which, how sentences are built, what facts tend to appear together, how code is structured, how a polite email sounds. Everything the model “knows” is stored in those numbers. There is no database of facts inside, and no list of sentences. There are just learned numbers, and fixed maths that uses them.

The toy model above has 16 weights. The same idea, scaled up enormously, gives you an LLM.

What makes it “large”?

The ideas above work at any size. What makes an LLM large is scale, in three ways:

A tiny teaching model A real LLM
Weights dozens billions (GPT-2, from 2019, had 124 million; Llama 3 8B has 8 billion; some models have hundreds of billions)
Training text one sentence trillions of words
Training time seconds on a laptop weeks to months on thousands of specialised chips

Size is what turns “guess the next word” from a simple trick into something that can explain a concept, summarise a contract, or write working code. With billions of weights trained on that much text, it picks up grammar, facts, reasoning steps and writing style.

From text predictor to helpful assistant

A model trained only to predict the next token is called a base model. It is very good at continuing text, but it isn’t a good assistant yet. Ask a base model “What is the capital of France?” and it might continue with “What is the capital of Germany? What is the capital of Spain?”, because a list of quiz questions is a perfectly likely continuation.

So real LLMs are built in stages:

Four cards in a row: 1 Pre-training, random weights learn to predict the next token on huge amounts of text. 2 Post-training, the base model learns to follow instructions. 3 Save, the final weights are written to a file and frozen. 4 Inference, every chat reads the frozen weights. Steps 1 and 2 are marked as training, where weights change; steps 3 and 4 as using it, where weights are only read.
The life of an LLM. Only the first two stages change the weights.
  1. Pre-training. The huge first stage: starting from random weights, the model learns to predict the next token across an enormous amount of text. The result is the base model.
  2. Post-training. The base model is trained further to follow instructions and be helpful. This usually combines learning from example conversations, learning which of two answers people prefer, and being rewarded for good results. Fine-tuning is the general name for training an already trained model further on more specific data.
  3. Save. The final weights are written to a file. That file is the model: the thing companies run on their servers, and the thing you download if you run an open model on your own computer.
  4. Inference. This is the technical name for using the model. Your prompt goes in, the saved weights are read, and the answer comes out, one token at a time.

What happens when you chat with an LLM

When you send a message to an AI assistant, the model is in that last stage, inference. Its weights are frozen: they are read, not changed. Two practical things follow from that.

It is not learning from your conversation. Correcting the model in a chat doesn’t update its weights. If it seems to “remember” your correction later in the same chat, that is because your earlier messages are still part of the text it is reading. (Some products separately save notes about you, or use conversations to help train future versions of the model, but that happens outside the model itself, not live while you chat.)

It can only see so much at once. The model reads your messages and its own replies as one long piece of text, but only up to a limit called the context window, measured in tokens. Many models today can take in over 100,000 tokens, roughly a few hundred pages, but anything that falls outside the window is invisible to the model. That is why a very long chat can “forget” its beginning.

Why LLMs sometimes get things wrong

LLMs can produce answers that sound confident and are completely false. This is called hallucination, and once you know how an LLM works, it is not mysterious at all.

The model predicts what is likely, not what is true. It also always produces something: the chances always add up to 100%, so some token always wins, even when the model has no good basis for any of them.

Here is a tiny example. Suppose a model learned from this text: “My puppy’s name is River. My cat’s name is Ruby. River likes Ruby.” After “My puppy’s name is”, both “River” and “Ruby” have appeared after “name is”, so it might give each about a 50% chance. If the marble draw picks “Ruby”, it will happily write “My puppy’s name is Ruby.” Every single step looked reasonable, and the sentence is wrong.

Real models are far more capable, but the same thing can happen with a date, a citation, a statistic or a function that doesn’t exist. So treat an LLM like a brilliant, well-read colleague who never says “I’m not sure”: helpful, fast, and worth double-checking on anything that matters.

What LLMs are used for

Because so many tasks can be framed as “here is some text, continue it well”, one LLM can do a wide range of jobs:

  • Answering questions and explaining concepts at any level
  • Summarising long documents, meetings and email threads
  • Writing and editing: drafts, rewrites, translations, tone changes
  • Writing and explaining code
  • Customer support chatbots and help desks
  • AI agents, where an LLM is given tools (web search, a calendar, a booking app) and works in a loop: decide the next step, use a tool, check the result, repeat

Underneath every one of these, it is the same engine doing the same thing: predicting the next token.

Common misconceptions

“The LLM looks things up in a database.” Not by itself. Its knowledge is stored in its weights, as patterns. Some AI tools add a search step and pass the results to the model as extra text, but the model alone has no database to search.

“It understands things the way I do.” It has learned extremely rich patterns in language, so it can do things that look like understanding and reasoning. But it has no experiences, no goals of its own, and no built-in sense of what is true.

“It is learning from me as we chat.” Its weights are frozen while you use it. See what happens when you chat.

“Tokens are words.” Often, but not always. Tokens can be parts of words, punctuation or spaces.

“Bigger is always better.” Larger models are generally more capable, but smaller models are cheaper, faster and good enough for many tasks, and some run on a laptop or phone.

Key takeaways

  • An LLM is a neural network trained on huge amounts of text to predict the next token.
  • It writes answers one token at a time: predict, add, repeat.
  • It gives every possible next token a chance and then picks one, which is why answers can vary.
  • Its knowledge lives in billions of learned numbers called weights, found during training.
  • When you chat, the weights are frozen: the model isn’t learning from you.
  • It predicts what is likely, not what is true, so it can hallucinate. Check what matters.

Frequently asked questions

What does LLM stand for?

LLM stands for large language model: an AI model trained on huge amounts of text to predict the next token. “Large” refers to its size: billions of learned numbers, trained on trillions of words.

Is ChatGPT an LLM?

ChatGPT is an app built on top of LLMs (OpenAI’s GPT models). The same goes for Claude, which runs on Anthropic’s Claude models, and Gemini, which runs on Google’s Gemini models. The app adds a chat interface and extra features around the model; the LLM generates the text.

What is the difference between AI and an LLM?

AI is the whole field of making computers do tasks that need human-like intelligence. An LLM is one specific kind of AI: a generative neural network trained on text. Every LLM is AI, but most AI is not an LLM. A spam filter or a face-unlock system is AI, but not an LLM.

How many parameters does an LLM have?

Anywhere from around a billion for small models that can run on a phone, to hundreds of billions for the largest. GPT-2 from 2019 had 124 million; Llama 3 8B has 8 billion. More parameters can capture more patterns, but they also cost more to train and to run.

Can an LLM think?

It depends on what you mean by “think”. An LLM doesn’t have thoughts running in the background; each token comes from running your text through its weights. But the patterns it learned let it work through problems step by step in its output, which can look a lot like reasoning, and is often useful for exactly that.

Why does the same question give different answers?

Because the model picks each token by chance, weighted by its predictions. With a higher temperature the picks vary more; at very low temperature the answers become nearly identical each time.

Try it yourself

The best way to make this click is to watch it happen. The Tiny LLM Lab is a real language model small enough to see every number inside it. It runs in your browser with nothing to install. Type in a sentence, train the model, and watch its weights change. Then freeze them and see it predict the next word, chances and all, exactly as described above. For a closer look at how the lab works and its code, see the Tiny LLM Lab page.

See it in action

Prefer watching? This video walks through the same ideas with live, hands-on demos.

Video thumbnail: What is a large language model (LLM)? A beginner's guideWatch on YouTube ↗

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.