AI Learning Courses
AI Learning Courses › Chapters › Chapter 7
CHAPTER 7 OF 15

Generative AI and Large Language Models

Large language models are the technology behind ChatGPT, Claude, Gemini and many other assistants. Understanding how they work will make you a far better user - and builder - of AI.

▶ Watch the 11 narrated lessons Take the chapter quiz

Tokens: how AI reads text ▶ Watch

LLMs do not read letters or whole words. They read tokens - chunks of text that are often a word or part of a word. "Unbelievable" might become "un", "believ", "able". In English, one token is roughly three-quarters of a word, so 1,000 tokens is about 750 words. AI services usually charge and set limits by tokens.

The core trick: predicting the next token ▶ Watch

An LLM scores every possible next token, picks one, adds it, and repeats.
An LLM scores every possible next token, picks one, adds it, and repeats.
▶ Play this diagram as a visual lesson

At its heart an LLM does one thing: given the text so far, it predicts the most suitable next token. It adds that token and predicts again, building answers word by word. Because it was trained on an enormous amount of human writing, doing this well requires learning grammar, facts, reasoning patterns, styles and even programming.

How an LLM is trained ▶ Watch

The main stages that turn raw text into a helpful assistant.
The main stages that turn raw text into a helpful assistant.
▶ Play this diagram as a visual lesson
  1. Pre-training - the model reads a huge, diverse collection of text and code and learns to predict the next token. This produces a powerful but unfocused "base model".
  2. Supervised fine-tuning - it is trained on high-quality example conversations so it learns to follow instructions.
  3. Alignment - techniques such as RLHF (reinforcement learning from human feedback) and AI feedback guided by written principles make it more helpful, honest and safe.
  4. Deployment and improvement - it is released, monitored, and improved in later versions.

Important LLM settings and terms ▶ Watch

TermMeaning
Context windowHow much text (in tokens) the model can consider at once: your prompt, files and the conversation so far.
TemperatureControls randomness. Low = focused and consistent; high = more creative and varied.
System promptBackground instructions that set the assistant's role and rules for the whole conversation.
Max tokensThe maximum length of the answer.
Knowledge cutoffThe date after which the model has no training data.
MultimodalAble to work with images, audio or video as well as text.
Tool useThe model can call external functions such as web search or a calculator.

How AI creates images: diffusion ▶ Watch

A diffusion model starts from random noise and removes it step by step, guided by the text prompt.
A diffusion model starts from random noise and removes it step by step, guided by the text prompt.
▶ Play this diagram as a visual lesson

Image generators are trained by taking real pictures, adding noise to them, and teaching a network to remove the noise. To create a new image, the model starts from pure noise and removes it step by step, steered by your text description, until a clear picture appears. The same idea is used for video and audio generation.

Multimodal AI ▶ Watch

Modern models increasingly handle several types of data in one system. You can photograph a maths problem and ask for an explanation, upload a chart and ask for insights, or have a spoken conversation in real time. Multimodality makes AI far more natural to use.

Chapter summary

  • LLMs read and write in tokens and work by predicting the next token, over and over.
  • Training goes through pre-training, fine-tuning and alignment.
  • Context window, temperature and system prompts control how a model behaves.
  • Diffusion models create images by removing noise; multimodal models combine text, images and audio.