studentsintermediate

How do chatbots like ChatGPT actually work?

Chatbots such as ChatGPT, Gemini and Claude are powered by large language models (LLMs). The core idea is surprisingly simple.

The big idea: predict the next word

Finish this sentence: “Chai with a plate of hot ___”

You probably thought pakoras or samosas. You didn’t look it up. You’ve seen enough sentences to know what usually comes next. An LLM does the same thing, at enormous scale. Given some text, it predicts a likely next word (strictly, a token, a word or piece of a word). Then it adds that word and predicts the next one, and the next, until the answer is done.

Where the “knowledge” comes from

  1. Pre-training: the model reads a huge amount of text (books, websites, code) and practises predicting the next token trillions of times. Along the way it picks up grammar, facts, reasoning patterns and writing styles.
  2. Fine-tuning: people then train it further on examples of helpful conversations, and rate its answers so it learns to be useful, polite and safe.

The result is a model that’s very good at producing text that sounds right.

Why that matters

Sounding right and being right aren’t the same thing. Because an LLM generates likely-looking text:

Modern chatbots reduce these problems with web search, tools and better training, but they don’t remove them.

Use them well

LLMs are great for explaining ideas, brainstorming, summarising, practising a language and drafting. For facts that matter, ask for sources and check them. Read Why AI makes mistakes next.

Check yourself

  1. At its core, what does a large language model do?

  2. What is a "hallucination" in AI?

  3. Why might a chatbot not know about last week's news?

  4. What is fine-tuning for?

Go deeper

More for you: 🎒 Students · 🧑‍🏫 Parents and teachers · 📰 Journalists and media · ✍️ Bloggers and writers · 🧭 Job seekers