Course 6 · Generative AI & LLMs · about 10 min
From recognising to creating
By the end of this course you can explain how chatbots generate text, how image generators work, and why their output must be checked.
Most AI you've met so far recognises: spam or not, cat or dog. Generative AI learns the patterns of its training data so well that it can create new examples that fit those patterns: text, images, audio, music and code.
It doesn't copy and paste from a database. It produces new combinations, which is powerful and also why it can be confidently wrong.
Try itGenerative or not?
CheckWhat does a generative model learn?
Step 2
Writing one token at a time
A large language model (LLM) splits text into tokens, pieces of words. Given the text so far, it calculates a probability for every possible next token, picks one, adds it, and repeats.
How it picks is controlled by the temperature. Low temperature: almost always the most likely token, so answers are predictable. High temperature: unlikely tokens get a real chance, so answers become varied and sometimes strange.
Try itSet the temperature
The model has to continue "My favourite fruit is …". Change the temperature, then generate a few times.
CheckWhat does raising the temperature do?
Step 3
How LLMs are trained
Chat models are built in stages:
- Pretraining: predict the next token across a huge amount of text. This is where grammar, facts and patterns come from.
- Fine-tuning: train further on examples of good instructions and answers, so the model becomes a helpful assistant.
- Learning from human feedback (RLHF): people compare answers, and the model learns which ones they prefer.
Try itPut the training stages in order
Tap the first stage, then the next.
CheckWhat does pretraining teach a language model?
Step 4
Images from noise
Most image generators are diffusion models. In training, they take real images, add random noise step by step, and learn to undo each step. To create a new image, they start from pure noise and remove it step by step, guided by your text prompt, until a picture appears.
Try itRemove the noise
Drag the slider to run the denoising steps.
CheckHow does a diffusion model begin generating an image?
Step 5
Hallucinations, and using models in apps
LLMs produce text that sounds right. They don't check facts, so they sometimes invent sources, numbers or quotes with full confidence. This is called a hallucination. Defences: give the model the source text to work from, ask for citations, and verify anything important.
Apps use models through an API: your code sends a prompt plus settings like temperature, and gets text back. Providers usually charge per token, so long prompts cost more.
PredictYou ask a chatbot for three research papers on a niche topic. It lists three, with authors and years. What should you do?
CheckWhy do LLMs hallucinate?
Step 6 · Recap
What you learned
- Generative AI creates new text, images, audio and code from learned patterns.
- LLMs write one token at a time; temperature controls how adventurous the choices are.
- Pretraining builds knowledge, fine-tuning and human feedback shape behaviour.
- Diffusion models create images by removing noise step by step, guided by a prompt.
- Models can hallucinate. Ground them in sources and verify what matters.
Quick reviewThree questions from memory. No scrolling back.
Course 7 teaches machines to see: computer vision. Mark this course complete below when you're ready.