20 min readInteractive

How does generative AI work?

How machines write and paint. Explained without a single equation.

What this section assumesNothing. Start anywhere.

Try it

Try this first

Finish the sentence. Which word feels most likely to come next?

Sentence 1 of 3

The cat sat on the  ? 

How language models learn to generate text

Predict what comes next, add it, and repeat. This is the basic mechanism behind text generation in modern language models.

Before you ever typed anything, the model went through training. During its initial training, it learned patterns from very large amounts of data. Modern chatbot models usually go through additional training afterwards to make them better at following instructions, answering questions, and behaving in useful ways.

This is much more powerful than the autocomplete on your phone. From these learned patterns, language models can produce grammatical sentences, adapt to different writing styles, recall many factual associations, answer questions, and perform surprisingly complex tasks.

Curious?Curious how text is actually split up?

Models don’t quite work word-by-word. Text is split into pieces called tokens, often chunks of words. “Understanding” might be split into “under” + “standing.” The model predicts the next token, not the next word. This is a detail you’ll meet in tech articles; the mental model of “predicting the next small piece” stays exactly the same.

Try it

See it split

Pick a sentence and split it the way a model would. Watch where the breaks land: they are not syllables, and they are not always words.

Generative AI is surprisingly useful.

Splits are shown the way a typical model would break these sentences. Every model has its own vocabulary, so the exact pieces differ between them. The shape of the idea does not.

Try it

Notice what changed

Same unfinished sentence, different context. Switch the context and watch how the likely completion shifts.

The cat sat on the …

  • mat62%
  • sofa21%
  • piano2%

Percentages are illustrative, not real model output.

Switch to another context to see the shift.

Your prompt is part of the context

When you type a request to an AI chatbot, your prompt becomes part of the context the model uses to produce its answer. Depending on the system, that context can also include earlier messages, instructions given to the model, retrieved information, or results from tools.

What you write still matters. A vague request gives the model less information about your audience, purpose, or desired format, so it has to make more assumptions. A more specific request gives it more useful context to work from.

Try it

Build a better request

Start with a vague prompt and add direction step by step. Watch how the response changes, and why.

Your prompt

Explain climate change.

The response

Climate change refers to long-term shifts in global temperatures and weather patterns, primarily driven by human activities such as burning fossil fuels, which increase greenhouse gas concentrations in the atmosphere… (continues generically for several paragraphs)

Why this changes things: With little direction, the model has to infer what kind of explanation you want. Adding an audience, purpose, or format gives it more useful context and usually makes the response more relevant to your goal.

The whole picture in three steps

Training: Before you use the chatbot, the underlying model has already learned patterns from large amounts of data and usually gone through additional training to make it better at following instructions.

Context: Your prompt, relevant parts of the conversation, and sometimes other information provided by the AI system become the context the model works from.

Generation: For text, the language model generates its response token by token, with each new token based on the context and what has already been generated.

Curious?Why can the same prompt give two different answers?

Because the model works in likelihoods rather than certainties, there is usually more than one plausible next token. Many language models use sampling when choosing between them, which means the same prompt can produce different generations. Ask the same question twice and the path of small choices can diverge, producing two different answers that are often both reasonable.

Curious?How are images generated?

Image generators learn patterns too, but visual ones: which shapes, textures, and compositions go together, and how they connect to descriptions. A common technique starts from pure visual noise and refines it step by step toward an image that matches your description. Different mechanics, same core idea: new content constructed from learned patterns, guided by your prompt.

Try it

From noise to picture

Drag the slider to walk a diffusion-based image generator from noise to a finished picture.

Prompt A red house beside a lake

Noise. The starting point is random visual noise. Nothing in it is a house yet.

Simplified visualization, not the actual internal states of an image model.

Curious?Why does ChatGPT behave differently from Claude or Gemini?

Training material is only one of the reasons. The underlying models are different to begin with, and companies train and post-train them in different ways, wrap them in different instructions, connect them to different tools like web search, and apply different safety and behaviour policies. Product design choices sit on top of all of that. Same underlying idea, different ingredients and decisions at every stage, which is why products have distinct personalities, strengths, and rules. Our upcoming model directory will compare them in plain language.

How we know this

The checkable claims in this section are backed by sources you can open yourself. Where a statement is our judgment or practical advice rather than an established finding, the text says so. Spot an error? See our corrections policy on the About page.

  • The central claim of this section: language models trained at large scale can learn broad patterns from data and develop capabilities across many different language tasks. When generating text, autoregressive language models produce it one token at a time.

    Research paper Tom Brown et al. (2020). Language Models are Few-Shot Learners, NeurIPS 2020

  • The tokens deep-dive: why models generate text as tokens rather than whole answers at once, and how randomness during generation can make the same prompt produce different outputs.

    Explainer Timothy B. Lee & Sean Trott (2023). Large language models, explained with a minimum of math and jargon, Understanding AI (the best jargon-free walkthrough if you want one level deeper than this section goes)

  • A key example of how supervised fine-tuning and reinforcement learning from human feedback can make a pretrained language model better at following instructions.

    Research paper Long Ouyang et al. (2022). Training language models to follow instructions with human feedback, NeurIPS 2022

  • The foundation of diffusion image generation: a model learns to reverse a gradual noising process, allowing it to generate images from noise.

    Research paper Jonathan Ho, Ajay Jain & Pieter Abbeel (2020). Denoising Diffusion Probabilistic Models, NeurIPS 2020

  • The part of the image deep-dive about a text prompt guiding the process: diffusion conditioned on a description, which is what the slider above walks through.

    Research paper Robin Rombach et al. (2022). High-Resolution Image Synthesis with Latent Diffusion Models, CVPR 2022

Last reviewed . AI changes fast; anything here that has gone stale is a mistake worth reporting.

Keep going

Where AI fails

Why AI makes things up with total confidence, and how to catch it.

18 min · Interactive