AI Basics

Large Language Models Explained Simply

How LLMs work: next-word prediction at scale, context windows, why they sound sure but can be wrong, and prompting as steering.

LLMslanguage models

Tutorial overview

What you will learn

  • Explain next-word prediction as the core mechanism of an LLM
  • Describe what a context window is and why it matters
  • Use prompting as steering to get noticeably better answers

By the end, you will have

  • A working mental model of LLMs that predicts when to trust them and when to check

Introduction

A large language model, or LLM, is a system trained on vast amounts of text to do one deceptively simple thing: predict the next small chunk of text, called a token, given everything that came before. Type the cat sat on the and a language model predicts mat is likely. Do this prediction extremely well, at enormous scale, and something remarkable emerges: the ability to answer questions, write essays, translate languages, and draft code. Chat assistants like ChatGPT, Claude, and Gemini are all built on this mechanism.

This lesson gives you a mental model of how LLMs work that correctly predicts both their fluency and their failures.

What you will build or practice

You will practice three things: explaining next-token prediction in one sentence, testing the limits of a model's context window, and steering an answer with a better prompt. Each maps to one core LLM concept.

Before you begin

You need a browser and access to any chat assistant. Reading Generative AI Explained for Beginners first gives useful background, since LLMs are the engine behind generative text tools.

Key concept

Three ideas explain most LLM behavior.

Prediction, not lookup. An LLM does not search a database of answers. It generates text one token at a time, each choice shaped by patterns learned from training. Because the patterns come from mountains of human writing, the output sounds knowledgeable. But sounding right and being right are produced by the same mechanism, which is why an LLM can state a falsehood with perfect confidence.

Training at scale. During training the model read enormous quantities of text, adjusting billions of internal settings to get better at prediction. Its knowledge is frozen at training time, so it can be unaware of recent events unless the product adds search or other tools on top.

The context window. The model can only consider a limited amount of text at once: your conversation, pasted documents, and its own replies. Everything inside that window shapes its predictions; anything outside it effectively does not exist. This is why long conversations can drift and why pasting relevant material into the chat improves answers so much.

Step 1: Explain the mechanism in one sentence

Write your own version of: an LLM writes by repeatedly predicting the most fitting next token based on everything currently in its context. Keep this sentence; it inoculates you against both hype and dismissal.

Step 2: See prediction in action

Ask an assistant to finish a famous-style opening line, then ask it the same question twice in fresh chats. Small differences between answers reveal that you are watching probabilistic generation, not retrieval of a stored answer.

Step 3: Feel the context window

Paste a page of your own notes and ask specific questions about them. Notice how sharply accuracy improves compared with asking from memory alone. What you place in the window is the most powerful lever you control.

Step 4: Steer with prompting

Ask a question plainly, then again with role, audience, format, and constraints, for example: explain mortgages to a teenager in five bullet points, no jargon. Prompting works because your words become part of the context that conditions every next-token prediction. That is the entire foundation of prompt engineering basics.

Practice exercise

Pick a topic you know deeply. Ask an assistant three questions about it, from basic to obscure. Grade the answers. You will typically see strong performance on well-documented ground and shakier performance at the edges, exactly what a prediction-from-patterns mechanism would produce.

Common mistakes

  • Treating an LLM like a search engine with guaranteed-true results.
  • Expecting knowledge of events after its training data ends.
  • Blaming the model for vague answers to vague prompts.
  • Assuming confidence signals correctness; fluency is the default, not a truth marker.

Check your understanding

  1. What single operation does an LLM repeat to produce a paragraph?
  2. Why does pasting a document into the chat improve answers about it?
  3. Why can an LLM be fluent and wrong at the same time?

Key takeaways

  • LLMs generate text by predicting the next token, conditioned on their context window.
  • Their knowledge comes from training text and is frozen at training time.
  • Prompting is steering: what you put in the window shapes everything that comes out.

Next steps

Turn this mental model into skill with prompt engineering basics, then practice verification habits from how to verify AI answers.

Related resources

Newsletter or next lesson

Join the newsletter for clear weekly lessons, or continue to Prompt Engineering Basics