Generative AI & LLM Apps
Topic 1 · How LLMs work · ⏱ about 30 min

Generative AI Course: Start Here

What generative AI is, what a large language model (LLM) can and cannot do, the kinds of apps you will build in this course, and the tools you need.

Show:
In this topic
Beginner

What is generative AI?

Generative AI means models that create new content (text, code, images, audio, video) instead of only predicting a label or a number. The most important kind today is the large language model (LLM): a neural network trained on a huge amount of text to predict the next piece of text. That one simple skill, done at enormous scale, turns out to cover answering questions, summarising, translating, writing code and following instructions.

Earlier courses on this site taught you models that classify or predict (is this email spam? how many patients tomorrow?). A generative model instead produces an open-ended answer. That makes it far more flexible, but also harder to control and to test: there is rarely one correct output.

Beginner

What you will build

This course is about building applications on top of LLMs, not training them from scratch (the NLP course covers training). By the end you will be able to:

  • write prompts that give reliable, well-formatted answers;
  • call a model from Python, get structured output (JSON your code can use), and let the model call your own functions (tool use);
  • build retrieval-augmented generation (RAG), so a model answers from your documents and cites them;
  • design simple agents that plan, use tools and check their own work;
  • evaluate an LLM app with test sets, and protect it against prompt injection, data leaks and runaway costs.

The course ends with a project: a "chat with your notes" assistant you can put online with the Flask & Deployment course.

Beginner

What LLMs are good and bad at

Usually good atOften bad at
Drafting, rewriting and summarising textFacts they were never shown, or that changed after training
Turning messy text into structured dataExact arithmetic and counting (use code or a calculator tool)
Explaining and writing codeKnowing when they are wrong: they can be confidently incorrect
Following a clear format and examplesKeeping secrets put in the prompt; resisting hostile instructions

A confident, fluent answer that is false is called a hallucination. Much of this course is about designing apps so that hallucinations are rare, visible and cheap.

Beginner

Tools you need

  • Python, at the level of the Python course.
  • Either an API key from a model provider (for example Anthropic, OpenAI or Google; most offer some free or low-cost credit, and prices change often, so check their pricing pages), or a local model with Ollama β†—, which runs open-weight models such as Llama, Qwen or Gemma on your own computer for free.
  • Nothing else for the demos: every interactive demo in this course runs in your browser. In fact, the AI tutor on this site is a small LLM running inside your browser with WebLLM, the same idea at a small scale.

Never paste an API key into code you share or into a web page. Keep it in an environment variable; the model APIs topic shows how.

Check yourself

Quiz

1. What does an LLM fundamentally learn to do during pretraining?

2. An LLM gives a fluent, confident answer that is false. This is called…

3. Where should an API key live?

Go deeper

πŸ“š Further reading

Trusted, mostly free sources: official documentation, well-known textbooks and courses. When you want to confirm or go deeper on anything here, start with these.

Ready