SONUB home EN English 한국어 日本語 中文 हिन्दी বাংলা اردو Español Português Français Deutsch Русский العربية Bahasa Indonesia Tiếng Việt ไทย Türkçe

How to enable notifications

Notifications are unavailable in this browser or on this address. Try a supported browser on the secure SONUB site.

If notifications are blocked, allow them in your browser settings.

  1. Open the site controls beside the address bar, or your browser’s site settings. Set Notifications for this site to Allow.
  2. In your device settings, allow notifications for your browser and check Do Not Disturb or Focus.
  3. Return to SONUB, reload the page, and use the bell to enable notifications.

On iPhone or iPad, add SONUB to your Home Screen, open it there, then allow notifications.

Textbooks

AI Course

From using tools well to building a small yourself — one page, chapter by chapter. Every chapter has a teaching guide, so a tutor can run the class from this page alone.

My Learning
Chapters
Chapter 1 · Beginner · Getting started

Before you start: your AI toolkit

Goal

Know which tools this course uses, what each is for, which accounts you need, and how to keep keys and personal data safe.

This course goes from understanding AI, to using AI tools, to building a tiny yourself. You will meet three kinds of tools: chat assistants such as ChatGPT that answer in a conversation, such as Codex and Claude Code that read and change files on your computer, and agent tools such as Claude Cowork that carry out multi-step tasks for you. , and are the ground they all stand on, so the course teaches them too. Some chapters need a free account and some a paid plan; the teaching guide says so, and you can always follow along with the in- practice on SONUB instead.

A closer look

Two habits matter more than any tool. First, check the result: an AI answer, picture or code change is a draft until you have read it, tested it or compared it with a source. Second, protect secrets: never paste passwords, keys or other people's personal data into a chat, a or a file you share. Keys belong in environment variables or in a that is never committed to Git.

Explain it yourself

Explain in your own words the three kinds of AI tools in this course and give one example of each.

Compare with an explanation

Chat assistants answer in a conversation (ChatGPT). Coding agents read and change files and run commands in a project (Codex, Claude Code). Agent tools carry out multi-step tasks across files and apps (Claude Cowork). All three produce drafts that I have to check.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Introduce the course map (5 min) → show one example of each kind of tool (10 min) → students set up accounts and a course folder (15 min) → safety rules and questions (10 min). Stretch or shorten each part to fit your lesson length.

Show on screen

  1. Open this course and walk through the chapter list: how AI works, AI tools, developer basics, AI agents, building an LLM, the final project.
  2. Ask a chat assistant one short question, then show a coding agent changing one line in a file, so students see the difference between talking and acting.
  3. Show where an API key should live (an environment variable or a .env file) and how a .gitignore line keeps it out of Git.

Student tasks

  1. List which tools you can already use (ChatGPT, Codex, Claude, GitHub) and which you still need to sign up for.
  2. Create an empty folder named ai-course on your computer; later chapters use it.

Done when

The student names the three kinds of AI tools with one example each and states the two safety habits.

If students get stuck

  • No paid plan: follow the demonstrations and use the in-browser practice on SONUB; every concept chapter works without an account.
  • A school or office computer blocks installs: use the web versions of the tools and the SONUB shell and Python practice.

Questions for the class

  • What is the difference between asking a chat assistant and letting a coding agent change your files?
  • Where should an API key be stored, and where must it never appear?

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 2 · Beginner · How AI works

AI words: the 10 terms you will hear every day

Goal

Explain the everyday AI words — , prompt, , , , , , , API, agent — in one simple sentence each.

A model is a that has learned patterns from data; a (LLM) learned them from huge amounts of text and predicts the next piece of text. What you type is the prompt, and the model reads it in tokens — small pieces of words. The context window is how many tokens the model can see at once, including the conversation so far. Parameters are the numbers inside the model that training adjusts; training is the long, expensive learning step, and inference is using the finished model to answer you.

A closer look

A hallucination is a confident answer that is wrong or made up, which is why you always check. An API is a door that lets your own program send a prompt and get the answer back, usually with a secret . A only answers, but an agent can also act: read files, run commands and use tools, step by step, toward a goal. or open- models can be downloaded and run on your own computer; closed models are used only through the company's app or API.

Explain it yourself

Explain to a friend what a context window is and why it matters.

Compare with an explanation

The context window is how much text (in tokens) the model can look at at one time — your prompt, files and the conversation so far. If something falls outside it, the model cannot see it any more, so long chats can lose early details. Putting the important facts into the prompt again fixes this.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Ask students which AI words they have heard (5 min) → explain the words in pairs: prompt/token, training/inference, chatbot/agent (15 min) → word-matching game (10 min) → self-check (10 min).

Show on screen

  1. Type a sentence into a tokenizer page or the SONUB tokens chapter and count the tokens together.
  2. Ask a chatbot a question it cannot know (a made-up person) and show a hallucination; then show how to check it.
  3. Compare a chatbot answering "how do I rename this file?" with an agent that actually renames it.

Student tasks

  1. Make your own word card: each of the ten words with a one-sentence meaning and an example.
  2. Find one hallucination by asking a chatbot about something very local or very new, and write how you checked it.

Done when

Students can explain the ten words in their own words and give the difference between training and inference and between a chatbot and an agent.

If students get stuck

  • Students mix up training and inference: training = studying for the exam, inference = writing the exam.
  • Tokens are confusing: show that a long or rare word becomes several tokens while a common word is one.

Questions for the class

  • Why can a model "forget" what you said at the start of a very long conversation?
  • What is the difference between asking a chatbot and giving a task to an agent?
Sources and further reading
Chapters
Chapter 3 · Beginner · How AI works

AI, machine learning, and language models

Goal

Distinguish a broad field from one kind of model.

Artificial intelligence is a field of building systems for tasks such as prediction, recognition, planning, and generation. Some systems use rules written by people. instead fits patterns from data; uses with many layers.

A closer look

A large language model (LLM) is one kind of AI. Many text-generating LLMs predict the next token from the available . Image generators, , and rule-based systems can work differently. Fluent language is not evidence that a system is alive or that its output is true.

Explain it yourself

Does every AI system generate the next word? Give a counterexample.

Compare with an explanation

No. A flower classifier predicts a class label; a rule-based program can follow fixed conditions.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Ask what students think AI is (5 min) → sort examples into rules, machine learning and language models (10 min) → read and discuss the chapter (15 min) → self-check (10 min).

Show on screen

  1. Show three examples side by side: a spam filter written with rules, a photo app that learned to recognise faces, and a chat assistant that generates text.
  2. Draw three nested circles: artificial intelligence, machine learning inside it, deep learning inside that, and place language models in the innermost circle.

Student tasks

  1. List five apps you use and label each one as rules, machine learning or a language model, with a reason.

Done when

The student gives a correct counterexample of an AI system that does not generate words.

If students get stuck

  • Students think every AI is ChatGPT: show a calculator-like rule system and a recommendation system as other kinds of AI.

Questions for the class

  • Is a thermostat that follows the rule "heat when below 20 °C" artificial intelligence? Why or why not?
Sources and further reading
Chapters
Chapter 4 · Beginner · How AI works

Write and check a prompt

Goal

State the task, useful context, constraints, and a way to check the result.

A prompt is input that guides a model. Compare “Explain fractions” with “For a beginner, explain one half using a pizza example, then ask me one question without giving its answer.” The second request specifies an audience, an example, and a learning activity.

A closer look

A role can guide tone, but does not grant expertise or guarantee compliance. Ask for sources when needed and verify that they support the claim. Compare two prompts on the same examples. Share only necessary information; a clearer prompt can help, but cannot remove every model limitation.

Explain it yourself

Does “You are an expert” make an answer reliable?

Compare with an explanation

No. It can guide the style; evidence and testing are still needed.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Compare a vague and a precise request (10 min) → improve one prompt together (10 min) → students write and test prompts (20 min) → discuss how to check answers (10 min).

Show on screen

  1. Ask "Explain fractions", then the precise version from the chapter, and compare audience, example and activity in the two answers.
  2. Add "You are an expert" to a prompt and show that the answer can still contain a mistake.

Student tasks

  1. Write a prompt for a topic you are learning that states the audience, one example and a way to check the answer.

Done when

The student's prompt names the task, the context, a constraint and a check.

If students get stuck

  • The answer is still vague: add an example of the output you want and a length limit.

Questions for the class

  • Which part of your prompt made the biggest difference to the answer?
Sources and further reading
Chapters
Chapter 5 · Beginner · How AI works

Prompt engineering: six parts of a prompt that works

Goal

Write prompts with a role, goal, context, examples, constraints and output format, and improve a prompt step by step instead of starting again.

means writing instructions so that a model gives the result you need. A good prompt usually has six parts: the role (who the model should act as), the goal (what you want), the context (the facts, files or audience it needs), examples (one or two samples of a good answer), constraints (length, level, what to avoid) and the output format (a list, a table, , a file). The more of these you give, the less the model has to guess.

A closer look

Treat a prompt like a draft. Read the answer, find what is missing or wrong, and add exactly that to the prompt: "use simpler words", "give three options", "cite the source". For hard tasks, ask the model to plan first and answer second, or split the task into smaller prompts. For coding agents, the long-lived parts of the prompt — the rules, commands and style — go into a project file such as CLAUDE.md or AGENTS.md so you do not repeat them every time.

Explain it yourself

Rewrite "make a homepage" as a prompt with the six parts.

Compare with an explanation

For example: "You are a web designer (role). Make a one-page homepage for my bakery (goal). It sells bread and cakes in Seoul; customers are families (context). Keep the style like this sample: … (example). Use only and , mobile first, no more than four sections (constraints). Give one index.html file (format)." Any prompt with all six parts is correct.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Show a weak prompt and its answer (5 min) → rebuild it with the six parts (15 min) → students improve a prompt in three rounds (15 min) → compare results (5 min).

Show on screen

  1. Ask "write about climate" and then the same request with role, audience, length and format; compare the two answers.
  2. Add one example answer to a prompt and show how the style of the result follows it.
  3. Ask for the result as a table, then as JSON, from the same prompt.

Student tasks

  1. Write a prompt with all six parts for a real task of yours (a study plan, a summary, an email).
  2. Improve it twice: each time add one fix based on what was wrong in the answer, and keep all three versions.

Done when

The final prompt has the six parts, and the student can point to the change that fixed each problem.

If students get stuck

  • The answer is too long or too general: add the audience, a length limit and the format.
  • The model ignores a rule: move the rule to the end, say it once clearly, and ask it to check the rule before answering.

Questions for the class

  • Which of the six parts helps most when the answer is in the wrong style?
  • Why put long-lived rules in CLAUDE.md or AGENTS.md instead of every prompt?
Sources and further reading
Chapters
Chapter 6 · Beginner · How AI works

Text, tokens, and IDs

Goal

Separate text pieces from their numeric identifiers.

A converts text into pieces called tokens and maps them to IDs in a vocabulary. Tokens may be words, word pieces, characters, or ; spaces and punctuation also matter. The same text can have different token counts with different tokenizers.

A closer look

Our toy lab uses a simple word tokenizer, not a production LLM tokenizer. An ID is just a label: ID 8 is not twice the meaning of ID 4. A context window limits how many tokens a model can use; the application may select, summarize, or discard material to fit.

Explain it yourself

If two tokens have adjacent IDs, must their meanings be similar?

Compare with an explanation

No. IDs identify vocabulary entries; their numerical distance does not measure meaning.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

What a token is (10 min) → count tokens of the same sentence in different ways (10 min) → students tokenise their own sentences (20 min) → self-check (10 min).

Show on screen

  1. Split "unbelievable!" into characters, into words and into word pieces such as un + believ + able + !, and count each.
  2. Show that IDs are only labels: two tokens with neighbouring IDs can mean completely different things.

Student tasks

  1. Write one sentence and split it into characters and into words; write a made-up ID next to each piece.

Done when

The student explains why the same text can have different token counts.

If students get stuck

  • Students confuse tokens with words: show a long word split into several tokens and a space or punctuation mark as its own token.

Questions for the class

  • Why do AI services often count usage in tokens rather than words?
Sources and further reading
Chapters
Chapter 7 · Beginner · How AI works

Vectors and embeddings

Goal

Distinguish IDs, , and learned .

An ID is a label. A is a list of numbers. A one-hot vector marks just one vocabulary position with 1 and the others with 0; it does not express semantic similarity. An embedding is a learned vector. Training can place related uses near one another, depending on the data and learning objective.

A closer look

Modern use to combine information from positions in the available context, so a token's representation can change with its sentence. Similarity is not truth or identical meaning. The famous king − man + woman analogy is an illustrative result from some word embeddings, not a universal equation. Search compares query and document vectors in a compatible embedding space.

Explain it yourself

Do nearby embeddings prove that two statements say the same true thing?

Compare with an explanation

No. They may share a topic while disagreeing. Read and verify the actual claims.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

From IDs to vectors (10 min) → one-hot vectors versus learned embeddings (10 min) → students place words on a 2-D map (20 min) → self-check (10 min).

Show on screen

  1. Write a one-hot vector for "cat" in a five-word vocabulary and show that it says nothing about similarity.
  2. Draw a 2-D map where cat and dog are close and car is far, and explain that training places them there.

Student tasks

  1. Place eight words of your choice on a 2-D map by meaning and explain two of the positions.

Done when

The student distinguishes an ID, a one-hot vector and an embedding.

If students get stuck

  • Students think nearby embeddings mean "true": show two opposite statements about the same topic that sit close together.

Questions for the class

  • If two sentences have nearby embeddings, what can and cannot we conclude?
Sources and further reading
Chapters
Chapter 8 · Beginner · How AI works

Training, inference, and retrieval

Goal

Explain what changes in training and what a model uses at inference time.

Our model counts which word follows the previous word. If red follows sky three times and blue once, their are 3/4 and 1/4. Modern neural language models instead optimize many weights to reduce prediction . At inference time they use those weights and the available context to calculate scores for the next token. This demo illustrates conditional prediction, not the full Transformer .

A closer look

changes model weights; LoRA trains smaller adapter while base weights can stay frozen. retrieves material and supplies it as context without requiring weight updates. BM25 ranks lexical matches using term frequency with saturation and document-length normalization; embedding retrieval compares learned vectors. Either can miss evidence or retrieve misleading text. A chat message is not automatically a training update.

Explain it yourself

An app retrieves a new manual and adds it to the prompt. Is that necessarily fine-tuning?

Compare with an explanation

No. Retrieval adds context. Fine-tuning requires a training process that updates weights.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Training versus inference (10 min) → the bigram counting example (10 min) → retrieval versus fine-tuning (10 min) → students sort scenarios (10 min) → self-check (10 min).

Show on screen

  1. Work through the chapter's sky → red/blue counting example on the board and compute the probabilities.
  2. Show an app that pastes a manual into the prompt (retrieval) and explain that the model's weights did not change.

Student tasks

  1. Sort five scenarios into training, inference or retrieval, for example "a chatbot reads today's menu before answering".

Done when

The student explains what changes during training and what the model uses at inference time.

If students get stuck

  • Students think a chatbot learns from every chat: explain that its weights stay the same unless it is retrained.

Questions for the class

  • Why can a model answer about a document it was never trained on?
Sources and further reading
Chapters
Chapter 9 · Beginner · How AI works

Instructions, sampling, and verification

Goal

Compare generation settings without confusing consistency with factual accuracy.

System instructions guide an assistant but do not guarantee obedience or secure tool access. The application must enforce permissions. rescales token scores before : lower positive values concentrate probability, higher values flatten it. keeps a fixed number of candidates; top-p keeps a set reaching a chosen cumulative probability. Neither setting checks facts. chooses a highest-scoring token rather than .

A closer look

Try greedy and sampling modes several times in the builder. Sampling can repeat the same result. Temperature zero does not guarantee identical output across real systems: model versions, context, tools, and numerical execution also matter. Then compare a vague question with one giving a goal, context, and a way to check the answer. Test a factual claim against an original source; use hints and explain the result in your own words.

Explain it yourself

Can a low-temperature model confidently repeat a false answer?

Compare with an explanation

Yes. Concentrated probabilities are not evidence of truth. Check the claim independently.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Instructions versus permissions (10 min) → temperature, top-k and top-p with numbers (15 min) → students predict outputs (15 min) → self-check (10 min).

Show on screen

  1. Take scores for three tokens, apply a low and a high temperature, and show how the probabilities sharpen or flatten.
  2. Ask the same question twice at a high temperature and show that the answers differ, then explain that neither is checked for truth.

Student tasks

  1. For the probabilities 0.6, 0.3, 0.1, say which tokens top-k = 2 and top-p = 0.8 keep.

Done when

The student explains that a low temperature makes answers consistent but not necessarily correct.

If students get stuck

  • Students think the system prompt is a security wall: explain that the application, not the prompt, must enforce permissions.

Questions for the class

  • When would you want a higher temperature, and when a lower one?
Sources and further reading
Chapters
Chapter 10 · Beginner · Using AI tools

ChatGPT: ask well and check the answer

Goal

Write requests with a goal, context, constraints and an output format, improve them step by step, and check the answer before using it.

ChatGPT is a chat assistant built on large language models. It writes, summarises, translates, explains and plans, and it can read files and pictures you attach and search the web when that feature is on. A good request has four parts: the goal (what you want), the context (who it is for and what you already have), the constraints (length, tone, what to avoid) and the format (a list, a table, an email). When the first answer misses, do not start over — say exactly what to change. Keep one conversation on one topic so earlier messages help instead of confuse.

A closer look

A language model predicts likely text, so a fluent answer can still be wrong. Ask for sources and open them, compare numbers with the original, and ask the model to list its assumptions. For important facts, check a second, independent source. Saved instructions and projects let ChatGPT remember your preferences, but they are still instructions, not guarantees, so keep checking.

Explain it yourself

Rewrite the request "Help me with my presentation" so that it has a goal, context, constraints and a format.

Compare with an explanation

For example: "Goal: a five-slide outline. Context: a three-minute class talk about recycling for 13-year-olds. Constraints: simple words, one statistic per slide with its source. Format: a slide title and two bullet points each." Any answer that clearly states all four parts is correct.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

A weak request versus a strong one (10 min) → live improvement in three turns (10 min) → students write and refine their own request (20 min) → compare and check answers (10 min).

Show on screen

  1. Ask "Tell me about Korea." Then ask: "Goal: a five-line introduction to Korea for a 10-year-old. Context: they live in Brazil. Constraint: no history dates. Format: bullet points." Compare the two answers.
  2. Follow up with a precise change such as "Make line 3 shorter and add one food example" instead of asking again from scratch.
  3. Ask a question whose answer contains a number, ask for the source, open it and check whether the number matches.

Student tasks

  1. Pick a real task (an email, a study plan, a summary) and write a request with a goal, context, constraints and a format.
  2. Improve the answer in at least two follow-up messages and write down one claim you checked and how.

Done when

The final request has all four parts and the student shows one fact they checked against a source.

If students get stuck

  • The answer is too long or too general: add a length limit and an audience, and give one example of what you want.
  • The answer invents a source or a number: say so, ask for a link, and treat anything you cannot verify as unconfirmed.

Questions for the class

  • Which of the four parts changed the answer the most in your example?
  • Why can a confident, fluent answer still be wrong?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 11 · Beginner · Using AI tools

Image generation: describe, refine, check

Goal

Describe a picture precisely, change one thing at a time, and check the result for mistakes, rights and honesty before using it.

Image models turn a text description into a picture, and many can also edit a picture you give them. ChatGPT and Codex can create and edit images, and Google offers its Nano Banana image models (the older Imagen models in the Gemini API have been shut down). A good image prompt names the subject, the setting, the style, the composition (close-up or wide, where things are), the colours and the size or aspect ratio. To edit, say what must change and what must stay the same, for example "keep the girl and the background, change only the umbrella to yellow".

A closer look

Generated pictures often hide small errors: wrong letters, extra fingers, impossible shadows. Always zoom in and check. Do not use a generated picture to pretend that something really happened, do not imitate a living artist or a real person without permission, and say that a picture was made with AI when it matters. Read the terms of the tool before using pictures commercially.

Explain it yourself

Write an edit request that changes only the background of a portrait to a beach and keeps the person exactly the same.

Compare with an explanation

For example: "Keep the person, their face, clothes, pose and lighting exactly as they are. Change only the background to a sunny beach with the sea behind them." It must name what changes and what stays.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

A weak prompt versus a strong one (10 min) → one edit that keeps everything else (10 min) → students make and edit their own picture (20 min) → review mistakes and rights (10 min).

Show on screen

  1. Generate "a cat", then "a watercolour of an orange cat sleeping on a blue chair by a sunny window, wide shot, 4:3", and compare.
  2. Edit the second picture: "Keep everything the same, change only the chair to green." Point out anything that changed by accident.
  3. Zoom into the result and find one mistake in text, hands, shadows or perspective.

Student tasks

  1. Write an image prompt with the subject, setting, style, composition, colours and size, and generate it.
  2. Make one edit that changes exactly one thing and note whether anything else changed.

Done when

The student shows the prompt, the edit request and one mistake they found in the result.

If students get stuck

  • The picture ignores part of the prompt: put the most important detail first and remove words that conflict.
  • The text in the picture is misspelled: ask for fewer words, or add the text afterwards in a normal editor.

Questions for the class

  • Why should an edit request say what must stay the same?
  • When is it not okay to use a generated picture?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 12 · Beginner · Using AI tools

Shell and basic commands: where AI tools run

Goal

Use the basic commands — pwd, ls, cd, mkdir, cat, cp, mv, rm, clear, exit — start and leave AI tools in a project folder, and know which commands are dangerous.

Codex, Claude Code, the Antigravity and most run in a terminal, a window where you type commands for a program called the shell. These are the basic words: pwd (where am I), ls (what is here), cd (go there; cd .. goes back up), mkdir (make a folder), cat (show a file), cp (copy), mv (move or rename), rm (delete), clear (clean the screen) and exit (close the session). You start an AI tool the same way, inside the project folder: claude, codex or agy. SONUB has a full shell course with a practice terminal in the browser — this chapter sends you to its first units.

A closer look

Inside an AI tool, commands that start with a slash control the tool itself: /init writes a project instruction file, /help lists the commands, /clear starts a fresh conversation and /exit leaves. Unit 11 of the shell course shows how to install AI coding tools and check them with --version; install commands change, so compare them with the official page. Press Ctrl+C to stop a command that is still running. When an AI agent proposes a command, read it before allowing it — rm -rf deletes files for good, with no recycle bin.

Practise in the Shell Commands course

Your progress for this chapter is recorded in that course.

Commands to type in your terminal
pwd                 # where am I?
ls                  # what is here?
mkdir ai-course     # make a folder
cd ai-course        # go into it (cd .. goes back up)
cat notes.txt       # show a file
cp notes.txt copy.txt
mv copy.txt old.txt # move or rename
rm old.txt          # delete for good (no recycle bin)
clear               # clean the screen

claude              # start an AI agent in this folder (or: codex, agy)
/init               # inside the agent: write the project instruction file
/help               # list the agent's commands
/exit               # leave the agent

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Which three commands would you use to go into a folder called ai-course, see what is in it, and confirm where you are?

Compare with an explanation

cd ai-course to go in, ls to list what is there, and pwd to print where I am.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Why the terminal matters for AI tools (5 min) → a live tour of pwd, ls, cd and mkdir (10 min) → students do units 1 and 2 in the SONUB shell (25 min) → the install check from unit 11 (10 min).

Show on screen

  1. Open the SONUB shell course and run pwd, ls, mkdir ai-course and cd ai-course in the practice terminal.
  2. Type a wrong command on purpose and read the error message aloud together.
  3. Show unit 11: the install commands for Claude Code and Codex and how --version confirms the install.

Student tasks

  1. Finish shell unit 1 (meeting the terminal) and unit 2 (files and folders).
  2. Open a terminal on your own computer and create the ai-course folder from the command line.

Done when

The student completes units 1 and 2 and can move into the ai-course folder without help.

If students get stuck

  • Windows looks different: use PowerShell or WSL as the shell course explains, or keep practising in the SONUB terminal.
  • "command not found" right after an install: close and reopen the terminal, then check the PATH part of unit 11.

Questions for the class

  • What do pwd, ls and cd each tell you or change?
  • Why read a command before letting an AI agent run it?
Sources and further reading
Chapters
Chapter 13 · Intermediate · Developer basics

Git and GitHub: save versions and work together

Goal

Save every change with Git so that AI edits can be reviewed and undone, and use to share a project, open a and review it.

Git records snapshots of a project called , so you can see what changed and go back. That makes it the safety net for AI coding agents: commit before you let an agent work, then review its changes with git and keep or undo them. GitHub is a website that keeps Git projects online. There you create a , push your commits, and open a pull request — a proposal to merge a set of changes that others can read, comment on and approve. SONUB's Git course teaches the commands step by step; this chapter adds the GitHub side.

A closer look

On GitHub, use issues to describe a task, to work on it without disturbing the main code, and pull requests to review it. Keep repositories that contain private work private, and never commit a .env file or a key; once it is pushed, assume it has leaked and replace the key. Codex and Claude Code can open pull requests too, but a person should read the diff before merging.

Explain it yourself

An AI agent changed five files and something broke. Which Git commands help you see the changes and go back?

Compare with an explanation

git status and git diff show what changed; git restore <file> undoes changes that are not committed yet; if they were committed, git revert undoes that commit.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Why version control matters with AI (5 min) → commit, diff and undo on screen (10 min) → GitHub: create a repository, push, open and review a pull request (15 min) → students practise (20 min).

Show on screen

  1. In a project folder run git init, git add and git commit -m "start", change a line, then run git diff to show exactly what changed.
  2. Create a repository on GitHub, push the project and open a pull request from a branch.
  3. Leave a review comment on one changed line, then approve it or request changes.

Student tasks

  1. Take steps 1–5 of the Git course (or show that you know them), then make three commits in the ai-course folder.
  2. Push the folder to a new GitHub repository and open one pull request that changes a single file.

Done when

The student's GitHub repository shows at least three commits and one pull request with a description.

If students get stuck

  • The push is rejected for authentication: sign in with the GitHub CLI (gh auth login) or a personal access token, and never type the token into a chat.
  • A secret was committed by mistake: revoke and replace the key at once, then remove it from the code; deleting the file alone is not enough.

Questions for the class

  • Why commit before letting an AI agent change your project?
  • What does a pull request let other people do?
Sources and further reading
Chapters
Chapter 14 · Intermediate · Developer basics

Python and NumPy: the tools for building models

Goal

Write and run small Python programs and use NumPy arrays, the building blocks of every model in this course.

Python is the most common language for AI because it is short to write and has strong . SONUB's Python course teaches printing, variables, lists, conditions, loops and functions in the browser with automatic checking — finish it first, or make sure you know those ideas. Models, however, work on many numbers at once, and for that we use NumPy. A NumPy array holds a grid of numbers, and one line such as a @ b multiplies whole matrices, which is exactly what a neural network does.

A closer look

Three NumPy ideas carry the rest of the course: shape (how many rows and columns), broadcasting (an operation is stretched across the whole array automatically) and vectorised maths (working on the whole array instead of writing a Python loop). All the code in this course runs in your browser. On your own computer, install Python 3, make a virtual environment with python -m venv .venv, and install NumPy with pip install numpy.

Example code Runs in your browser with Python and NumPy. Change the code and run it again.

Explain it yourself

One array has the shape (4, 3) and another (3, 2). What is the shape of their product, and why?

Compare with an explanation

(4, 2): matrix multiplication needs the inner sizes (3 and 3) to match, and the result keeps the outer sizes, 4 and 2.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Check the Python basics (10 min) → NumPy arrays, shape and @ on screen (10 min) → students run and change the example (20 min) → explain softmax together (10 min).

Show on screen

  1. Run the example and point at the shape, the broadcast result and the matrix product.
  2. Change the scores in the softmax line and show that the probabilities still add up to 1.
  3. Write the same addition as a Python loop and as one NumPy line, and compare.

Student tasks

  1. Finish the SONUB Python course up to functions, or show the tutor that you can write a small function.
  2. Change the example: make a 3×3 array, multiply it by a 3×1 array and predict the shape before you run it.

Done when

The student predicts the shape of a matrix product correctly and explains what softmax returns.

If students get stuck

  • A ValueError about shapes: print the .shape of both arrays; for a @ b the inner sizes must match.
  • "No module named numpy" on your own computer: activate the virtual environment and run pip install numpy.

Questions for the class

  • Why use NumPy instead of a Python loop?
  • What do the numbers returned by softmax always add up to?
Sources and further reading
Chapters
Chapter 15 · Intermediate · Developer basics

Python: run, inspect, change

Goal

Use variables, conditions, and functions in the browser.

Python is widely used for AI because libraries such as NumPy and scikit-learn provide numerical and machine-learning tools. SONUB runs Python in the browser using Pyodide. Loading the and packages takes time. Printing a greeting checks that code runs; it does not train an AI model.

A closer look

The example below applies a rule written by a person. Change the score or threshold and predict the output before running it. A function uses return to give a value back; print only displays it. Test boundary cases such as a score exactly equal to the threshold. This rule-based program has no learning step.

Example code Runs in your browser with Python and NumPy. Change the code and run it again.

Explain it yourself

A programmer changes an if-condition. Did the program learn from data?

Compare with an explanation

No. Editing a rule is programming. Learning requires a process that derives model behavior from data.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Run the example (10 min) → change one condition and predict the output (10 min) → students write a small function (20 min) → self-check (10 min).

Show on screen

  1. Run the chapter's example code and change the question so the else branch runs.
  2. Point out that changing an if-condition is programming, not learning from data.

Student tasks

  1. Write a function that answers three different questions with if/elif/else and test it with each.

Done when

The student predicts which branch runs before running the code.

If students get stuck

  • IndentationError: line up the lines inside if and else with four spaces.

Questions for the class

  • What is the difference between a program a person changes and a model that learns?
Sources and further reading
Chapters
Chapter 16 · Intermediate · Build and publish

Vibe coding: build a homepage by talking to an AI

Goal

Build a one-page homepage with an AI coding agent by describing it, reviewing each change and keeping the project in Git.

means building software mainly by describing what you want in plain words and letting an AI write the code, while you steer, test and decide. Start small: a folder, a Git repository and a short brief — who the site is for, the sections, the style and the rules (plain HTML and CSS, works on a phone, no outside libraries). Ask the agent for the first version, open index.html in a browser, and then improve it one change at a time: "make the header smaller", "add a contact section", "fix the layout on a phone".

A closer look

You are still the developer. Read every change before you accept it, commit to Git after each working step so you can go back, and test on a real phone width. Never let the agent put passwords or API keys in the page — a homepage is public, and everything in it can be read. When the page works, it is ready to publish: the next chapter puts it on the internet with Cloudflare.

Commands to type in your terminal
mkdir homepage && cd homepage
git init                       # save points from the first minute
claude                         # or: codex, agy

# then, inside the agent:
# "Make a one-page homepage in index.html for <who it is for>.
#  Sections: <...>. Style: <...>. Plain HTML and CSS, works on a phone,
#  no outside libraries. Show me the plan before you write."

git add index.html
git commit -m "first working homepage"
git restore index.html         # throw away a change you do not like

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

List the four steps you repeat for each change in vibe coding.

Compare with an explanation

Describe one change → let the agent make it → check it in the browser (also at phone width) → commit to Git if it works, or go back if it does not. Any answer with ask, check and save is correct.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Write the brief together (10 min) → the agent builds version one (10 min) → three rounds of "look, ask, check, commit" (25 min) → show the pages (5 min).

Show on screen

  1. In an empty homepage folder run git init, start the agent and paste a six-part prompt for a one-page site.
  2. Open index.html, resize the browser to phone width, and ask the agent to fix what breaks.
  3. Commit, ask for a bad change, then return to the last commit with git restore.

Student tasks

  1. Build your own one-page homepage (a club, a hobby, a portfolio) with at least three sections.
  2. Make at least three commits with clear messages, one per working change.

Done when

The page opens in a browser, reads well at phone width, has no secrets in it and has a Git history of small steps.

If students get stuck

  • The agent rewrites everything each time: ask for one small change and name the file and section.
  • The page looks broken on a phone: ask for a mobile-first layout and check at 390 px width.

Questions for the class

  • Why commit after every working step when an AI writes the code?
  • Why must a public homepage never contain an API key?
Sources and further reading
Chapters
Chapter 17 · Intermediate · Build and publish

Publish to the web: deploy your homepage on Cloudflare

Goal

Publish a static homepage on Cloudflare Pages with Wrangler or from GitHub, update it, and know what is public after you publish.

Cloudflare Pages hosts static sites — HTML, CSS, and images — on Cloudflare's worldwide network, with a free plan and an address like your-project.pages.dev. There are two ways in. Direct Upload: install , run npx wrangler login, then npx wrangler pages ./ --project-name=my-homepage from the folder with index.html. Git integration: push the project to GitHub, connect the repository in the Cloudflare dashboard, and every push publishes a new version automatically. Choose one at the start — a Direct Upload project cannot be switched to Git integration later.

A closer look

Everything you publish is public, so check that no keys, private notes or .env files are in the folder. Each deployment gets its own preview address, and the production address shows the latest one, so you can test before sharing. A custom such as myname.com can be added later in the dashboard. You can ask your coding agent to run the deploy commands, but read them first and never paste your Cloudflare API token into a chat.

Commands to type in your terminal
# Direct Upload — run in the folder that has index.html
npx wrangler login
npx wrangler pages project create my-homepage
npx wrangler pages deploy ./ --project-name=my-homepage

# -> https://my-homepage.pages.dev
# Choose at the start: a Direct Upload project cannot switch to Git integration later.

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Explain in three steps how your homepage goes from your computer to the internet.

Compare with an explanation

1. Log in to Cloudflare with Wrangler (or connect GitHub). 2. Upload the folder with index.html as a Pages project. 3. Cloudflare serves it from its network at a pages.dev address, and each new upload replaces the live version. Any answer with login, upload and the public address is correct.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

What hosting is and why static is simple (5 min) → deploy with Wrangler together (15 min) → change the page and deploy again (10 min) → connect GitHub as the second way (10 min).

Show on screen

  1. Run npx wrangler login and npx wrangler pages deploy ./ --project-name=demo-homepage, then open the pages.dev address.
  2. Change one line, deploy again, and show the new deployment and its preview address in the dashboard.
  3. Show a .gitignore that keeps .env out, and explain why nothing secret belongs in a static site.

Student tasks

  1. Publish your vibe-coding homepage and share the pages.dev address.
  2. Make one improvement, publish it again and confirm the change is live.

Done when

The homepage is reachable at a pages.dev address, an update has been published, and the student can explain what is public.

If students get stuck

  • "npx: command not found": install Node.js (LTS) first, then open a new terminal.
  • The page shows 404: deploy the folder that contains index.html, not its parent folder.

Questions for the class

  • What is the difference between Direct Upload and Git integration?
  • Why is a static site safe to host for free but unsafe for secrets?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 18 · Intermediate · Build and publish

Google Play: put your app on Android phones

Goal

Know the steps to publish an Android app on Google Play — developer account, app bundle, store listing, testing and review — including the testing rule for new personal accounts.

To publish on Google Play you need a Play Console developer account (a one-time registration fee and identity check), an app built as an Android App Bundle (.aab) signed with your upload key, and a store listing: name, description, screenshots, an icon, a privacy policy address and answers about content and data safety. If you build the app with an AI agent, for example with Flutter, ask it to make a release build and keep the signing key file and its passwords out of Git and out of every chat.

A closer look

Releases go through tracks: internal testing, closed testing, open testing and production. New personal developer accounts must first run a closed test with at least 12 testers who stay opted in for 14 days in a row before they can apply for production access, so plan your testers early. Every release is reviewed by Google, and each update needs a higher version code. Rules and screens change, so follow the official Play Console help next to this chapter.

Commands to type in your terminal
# Flutter: build a signed Android App Bundle for Google Play
flutter build appbundle
# -> build/app/outputs/bundle/release/app-release.aab

# Keep the upload key and its passwords out of Git:
#   android/key.properties
#   *.jks

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Put these in order: production, closed test, release bundle, store listing.

Compare with an explanation

Release bundle → store listing → closed test (12 testers for 14 days for a new personal account) → production. The bundle and listing can be prepared in either order, but testing always comes before production.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

From app to store: the big picture (10 min) → build a release bundle together (15 min) → walk through the Play Console listing (15 min) → plan the 12-tester closed test (10 min).

Show on screen

  1. Show a release build command (for Flutter: flutter build appbundle) and where the .aab file appears.
  2. Walk through Play Console: create the app, the store listing, the data-safety form and the testing tracks.
  3. Show where the upload key is stored and why it must never be committed or shared.

Student tasks

  1. Write the store listing for your app: name, short and full description, and a list of screenshots to take.
  2. Make a tester plan: 12 people, how you will invite them, and how you will keep them in the test for 14 days.

Done when

The student can list the steps from release bundle to production, explain the tracks and the closed-test rule, and has a listing draft and tester plan.

If students get stuck

  • No developer account or not old enough: practise with the listing and tester plan; a parent or the school can own the account.
  • The upload is rejected for the version: raise the version code (Flutter: the number after + in pubspec.yaml).

Questions for the class

  • Why do new personal accounts have to run a closed test before production?
  • What happens if you lose your upload key, and how do you protect it?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 19 · Intermediate · Build and publish

App Store: put your app on iPhones

Goal

Know the steps to publish an iPhone app — Apple Developer Program, signing, App Store Connect, TestFlight and App Review — and the most common reasons for rejection.

Publishing on the App Store needs a Mac with Xcode, a membership in the Apple Developer Program (a yearly fee), and a record for your app in App Store Connect with its bundle ID, name, screenshots, a privacy policy address and the privacy details of the data it collects. You archive the app in Xcode (or with a such as flutter build ipa) and upload it; Xcode handles the signing and profiles for you when automatic signing is on.

A closer look

Every uploaded build can go to TestFlight first, so testers install it before the public does. When you submit for release, Apple's App Review checks the app against its guidelines. Common rejections: the app crashes or has placeholder content, the privacy details are missing, there is a login but no test account for the reviewer, there is third-party login without an equivalent privacy-friendly option such as Sign in with Apple, or the app is only a website wrapped in an app with little to do (the minimum-functionality rule, guideline 4.2). Read the rejection message, fix exactly that and resubmit.

Commands to type in your terminal
# Flutter on a Mac with Xcode: build the iOS archive for App Store Connect
flutter build ipa
# -> build/ios/archive/Runner.xcarchive  (open it in Xcode)
# -> Xcode: Distribute App -> App Store Connect -> TestFlight first
# A website only wrapped in an app can be rejected (App Review Guidelines 4.2 — minimum functionality)

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Your app was rejected because "the app crashed on launch". What do you do?

Compare with an explanation

Reproduce it on a real iPhone or in TestFlight with the same iOS version, fix the crash, raise the build number, upload a new build and reply in App Store Connect saying what was fixed. Fixing, re-uploading and replying are the key steps.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Apple's path: account → build → TestFlight → review (10 min) → archive and upload together (15 min) → App Store Connect listing (15 min) → rejection reasons and how to answer (10 min).

Show on screen

  1. In Xcode choose Product → Archive, then Distribute App → App Store Connect.
  2. In App Store Connect show the TestFlight tab, add an internal tester and install the build on a phone.
  3. Read a real-looking rejection message together and write the fix and the reply.

Student tasks

  1. Fill in a listing draft: name, subtitle, description, keywords, privacy policy address and a demo account for the reviewer.
  2. Check your app against the five common rejection reasons and note what to fix.

Done when

The student can explain archive, upload, TestFlight and review in order, and their checklist covers the common rejection reasons.

If students get stuck

  • No Mac or no membership: practise the listing and the checklist, and test the app on Android or the web.
  • Upload fails with a signing error: turn on automatic signing in Xcode and choose your team.

Questions for the class

  • Why test with TestFlight before submitting for review?
  • Why does Apple ask for a demo account when your app has a login?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 20 · Advanced · AI agents

Agents and sub-agents: how an AI works step by step

Goal

Explain the agent loop (think, act, observe, repeat), what tools and permissions an agent has, and when a main agent hands work to .

An agent is a language model that works in a loop: it reads the goal, decides the next step, uses a tool (reads a file, runs a command, searches the web), looks at the result and decides again, until the task is done or it needs you. Its power comes from its tools, and its limits come from its permissions — what it may read, change and run without asking. Claude Code, Codex and the Antigravity CLI are all agents of this kind; they differ in models, settings and commands, not in the basic loop.

A closer look

A sub-agent is a helper the main agent starts for one part of the job. It has its own fresh context window, so it can read many files or search widely and report back only the conclusion, keeping the main conversation short. Sub-agents can also run in parallel on independent parts. In Claude Code they are Markdown files with a name, a description, allowed tools and instructions in .claude/agents/ (for the project) or ~/.claude/agents/ (for you). Give a sub-agent a narrow job and only the tools it needs, and remember that its report is still a draft you check.

Explain it yourself

Your project has 300 files and you want to know where the login code is. Why is a sub-agent a good idea?

Compare with an explanation

Reading many files fills the context window. A sub-agent can do the search in its own fresh context and return only "the login code is in these three files", so the main conversation stays short and focused. A read-only sub-agent is also safe because it cannot change anything.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Act out the agent loop with a student as the "agent" (10 min) → watch a real agent's tool calls (10 min) → write a sub-agent file (20 min) → discuss when not to use one (10 min).

Show on screen

  1. Give a coding agent a small task and point at each step: the plan, the tool call, the result and the next decision.
  2. Ask the agent to search the whole project for one thing and show it handing the search to a read-only sub-agent.
  3. Open a sub-agent file in .claude/agents/ and read its name, description, tools and instructions.

Student tasks

  1. Draw the agent loop for a task of your own (for example "fix the broken link on my homepage") with every tool it would use.
  2. Write a read-only reviewer sub-agent: a description of when to use it, tools limited to reading, and a three-line checklist.

Done when

The student can explain the loop, the role of tools and permissions, and why a sub-agent has its own context, and has a working sub-agent file.

If students get stuck

  • The sub-agent is never used: make the description say exactly when to use it, in the words of the request.
  • The agent does too much at once: ask for a plan first and approve one step at a time.

Questions for the class

  • What is the difference between a chatbot answer and an agent loop?
  • Why give a sub-agent fewer tools than the main agent?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 21 · Advanced · AI agents

Codex: OpenAI's coding agent

Goal

Give Codex a clear coding task with the files, the expected behaviour and a way to check it, then review its changes before you keep them.

Codex is OpenAI's coding agent. It works in your terminal (the Codex CLI), in code editors and in the ChatGPT app; it reads your project, edits files and runs commands to test its work. It follows the instructions in an AGENTS.md file at the root of the project, so you can state your rules once — for example which command runs the tests. Codex asks for approval before risky actions, and you choose how much it may do on its own, from read-only to editing the workspace.

A closer look

Good coding requests are specific: what to change, in which files, how it should behave afterwards, and how to check it (a test, a command, an example ). For a bigger task, ask for a plan first. When Codex is finished, read the diff, run the tests yourself, and commit only what you understand. codex exec runs a task without the interactive screen, which is handy in scripts.

Explain it yourself

Rewrite "make my code better" into a request Codex can carry out and check.

Compare with an explanation

For example: "In word_count.py, make count_words ignore punctuation and capital letters. Keep the function name. Add a test where 'Hello, hello!' counts as one unique word. Run python -m pytest and show the result." It names the file, the behaviour and the check.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

What a coding agent does (5 min) → a live task with a clear request (15 min) → students give Codex their own small task (20 min) → review the diffs together (10 min).

Show on screen

  1. In the ai-course folder, write an AGENTS.md with one rule, for example "Run python -m pytest after every change."
  2. Ask Codex for a small script with a test, approve its steps, and show the test running.
  3. Open git diff and walk through every changed line before committing.

Student tasks

  1. Give Codex a task that names the file, the behaviour and the check — for example a function that counts the words in a text, with a test.
  2. Review the diff, run the test yourself, then commit with a message that describes the change.

Done when

The student's commit contains working code and a test, and the student can explain every changed line.

If students get stuck

  • Codex changes more than you asked: stop it, undo with git restore, and repeat the request naming the exact files.
  • Sign-in or plan problems: sign in with your ChatGPT account; if Codex is not included in your plan, follow the demonstration and practise reviewing the tutor's diff.

Questions for the class

  • What should a good coding request always contain?
  • Why read the diff even when the tests pass?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 22 · Advanced · AI agents

Claude Code 1: set up a project and give lasting instructions

Goal

Start Claude Code in a project, give it lasting instructions in CLAUDE.md, and control what it may do with permissions.

Claude Code is Anthropic's coding agent. It runs in the terminal and also in code editors, the Claude desktop app and the web. In a project folder, type claude to start; it reads the code, answers questions about it, edits files and runs commands. A file named CLAUDE.md at the root of the project is read at the start of every session — put the project's purpose, the commands that build and test it, and your rules there. The /init command drafts a CLAUDE.md for you by reading the project.

A closer look

Claude Code asks before it edits files or runs commands, and you decide whether to allow an action once, for the session, or always. Permission rules live in .claude/settings.json, and plan mode lets Claude Code read and propose a plan without changing anything. Start strict, loosen only what you trust, and never allow a command you do not understand.

Explain it yourself

Write three lines you would put in CLAUDE.md for a small Python homework project.

Compare with an explanation

For example: "Purpose: homework exercises for a Python class. Test: run python -m pytest after every change. Rule: keep functions short and explain each one in a comment." Any answer with a purpose, a test command and a rule is correct.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Install check and first start (10 min) → CLAUDE.md with /init (10 min) → permissions and plan mode (10 min) → students set up their own project (20 min).

Show on screen

  1. Start claude in the ai-course folder and ask "What is in this project?"
  2. Run /init, then edit the generated CLAUDE.md to add one rule about tests.
  3. Switch to plan mode, ask for a change, and show that nothing is edited until you approve the plan.

Student tasks

  1. Start Claude Code in your ai-course folder and write a CLAUDE.md with the purpose, the test command and two rules.
  2. Ask Claude Code for a change in plan mode and read its plan without approving it.

Done when

The student's project has a CLAUDE.md with a test command and rules, and the student can explain what plan mode does.

If students get stuck

  • "claude: command not found": repeat the install check in shell unit 11 and reopen the terminal.
  • It asks for permission too often: allow "always" only for safe commands such as running the tests, never for deleting files.

Questions for the class

  • What belongs in CLAUDE.md, and why is it read in every session?
  • When would you use plan mode?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 23 · Advanced · AI agents

Claude Code 2: plan, change, test, review

Goal

Run a whole task loop with Claude Code: describe the goal, review the plan, let it change and test the code, then review and keep or undo the result.

Working well with a coding agent follows a loop. Explain the goal and how to check it. Read the plan and correct it before any file changes. Let the agent edit and run the tests. Read the diff yourself. Keep the change with a commit, or undo it. Many small loops beat one giant request, because each loop is easy to check.

A closer look

Give the agent ways to check itself: tests, a command that must succeed, or an example of the correct output. If a session heads in the wrong direction, press Esc to stop, say what was wrong, or undo with Git and make a fresh request; long sessions collect confusing context, and /clear starts clean. For work you repeat, save the steps as a (see the Agent Skills chapter).

Explain it yourself

Put these in order: read the diff, describe the goal and the check, commit, approve the plan, run the tests.

Compare with an explanation

Describe the goal and the check → approve the plan → (the agent changes the code and) run the tests → read the diff → commit.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

The five-step loop on the board (5 min) → a live loop on a small feature (15 min) → students run two loops on their project (20 min) → share one thing the agent got wrong (10 min).

Show on screen

  1. Ask: "Add a function that returns the most common word in a text, with tests. Show me the plan first." Correct one detail of the plan.
  2. Let it edit and run the tests; when a test fails, show how it reads the error and fixes the code.
  3. Review git diff and commit; then make a bad change on purpose and undo it with git restore.

Student tasks

  1. Run one complete loop on your project: a goal with a check, the plan, the change, the tests, the diff, the commit.
  2. Run a second loop that improves something from the first, and write one sentence about what you corrected in the plan.

Done when

The student's Git history shows two commits made through the loop, each with passing tests.

If students get stuck

  • The agent says the tests pass but they fail: run the test command yourself and trust the output, not the summary.
  • The conversation gets confused: commit or undo what you have, use /clear, and start again with a short, precise request.

Questions for the class

  • Why are several small loops better than one big request?
  • What do you do when the agent goes in the wrong direction?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 24 · Advanced · AI agents

Antigravity CLI (agy): Google's agent in your terminal

Goal

Start Google's Antigravity CLI with agy, give it a task, compare it with Claude Code and Codex, and use more than one agent to check each other.

The Antigravity CLI is Google's coding agent for the terminal, started with the command agy after running the install script from its official page; Google also offers a migration guide for users of the older Gemini CLI. It uses Google's Gemini models and works like the other agents: you run it in a project folder, describe the task, approve its plans and commands, and it reads and edits files. The first time you run it, it opens the browser so you can sign in with your Google account. It can also send parts of a task to several helper agents at once.

A closer look

Knowing three agents is useful because each model has different strengths and blind spots. A good habit is cross-checking: ask one agent to make a change and another to review it, or ask several to analyse the same problem separately and compare — where they disagree, open the files yourself and decide. Keep the same project rules for all of them in AGENTS.md, which many agents read, so they follow the same instructions.

Explain it yourself

Two agents disagree about the cause of a bug. How do you decide who is right?

Compare with an explanation

Look at the evidence each gives — the file and line, the error message — and check it yourself: run the code, read the line, write a small test. The answer that matches the real behaviour wins, even if only one agent said it.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Three agents side by side: Claude Code, Codex, agy (10 min) → install and sign in to agy (10 min) → the same small task in two agents (20 min) → compare and decide (10 min).

Show on screen

  1. Run agy in the practice project and ask it to explain the project structure.
  2. Give the same bug to agy and to Claude Code or Codex, and compare the two plans.
  3. Ask one agent to review the other agent's change and show how you decide between them.

Student tasks

  1. Write an AGENTS.md with your project rules and check that two agents follow it.
  2. Give one task to two agents and write a short table: what each did, what was better, what was wrong.

Done when

The student has run agy on a project, compared two agents on the same task and can explain why cross-checking catches mistakes.

If students get stuck

  • agy does not start or cannot sign in: check the official install page and sign in with a Google account in the browser.
  • The agents give different answers: that is the point — open the files they point to and let the evidence decide, not the majority.

Questions for the class

  • Why can two different AI agents find more mistakes than one?
  • Why put the rules in AGENTS.md when you use several agents?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 25 · Advanced · AI agents

Agent Skills: teach an AI agent a repeatable task

Goal

Read and write a SKILL.md file so that an AI agent does a repeatable task the same way every time, and test when it is used.

An agent skill is a folder with a SKILL.md file that teaches an AI agent how to do one kind of task: the steps, the rules and the checks, and optionally scripts and reference files. Claude Code, Codex and other agents support the open Agent Skills format. The top of SKILL.md holds a name and a description; the agent reads only these at first and loads the full instructions when a request matches the description. That keeps many skills available without filling up the conversation.

A closer look

The description decides when a skill is used, so write it with the words people really say and state what it is not for. Keep the instructions short and concrete, move long details into separate reference files, and test the skill with requests that should and should not use it. Skills can run scripts, so install skills only from sources you trust, and read them first. SONUB itself is built with several skills — one of them writes the beginner pop-ups for terms you see on this site.

Explain it yourself

Write a description for a skill that turns meeting notes into an action list.

Compare with an explanation

For example: "Turns meeting notes into a numbered action list with an owner and a due date. Use when the user asks for action items or a to-do list from a meeting. Not for writing full minutes." It says what it does, when to use it and what it is not for.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

What a skill is and where it lives (10 min) → read a real skill together (10 min) → students write a small skill (20 min) → test when it triggers (10 min).

Show on screen

  1. Open the example SKILL.md and point at the name, the description and the steps.
  2. Put the skill in .claude/skills/weekly-report/ and ask "Write my weekly report"; then ask something unrelated and show that the skill is not used.
  3. Make the description vague and show how the skill becomes unreliable.

Student tasks

  1. Write a SKILL.md for a task you repeat (a summary, a checklist, a report) with a clear description and three to five steps.
  2. Test it with two requests that should use it and one that should not, and note the results.

Done when

The skill has a name, a description that says when to use it, numbered steps and a check, and it is used correctly in the tests.

If students get stuck

  • The skill is never used: put the words people actually say into the description.
  • It is used for the wrong requests: add what it is not for to the description.

Questions for the class

  • Why does the agent read only the name and the description at first?
  • Why read a skill before installing it from the internet?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 26 · Advanced · AI agents

Claude Cowork: hand over multi-step work

Goal

Use an agent tool for tasks across files and apps, set clear limits, follow its progress and check the finished work.

Claude Cowork uses the same agent technology as Claude Code but needs no terminal. In the Claude desktop app you describe a task — for example "sort these 40 receipts into a spreadsheet by month" — give it access to the folder it needs, and it plans the steps, works through them and shows its progress. It is made for office and study work: organising files, drafting documents from notes, collecting information into a table. Cowork is available on paid Claude plans.

A closer look

The more an agent can do, the more your instructions matter. Give it only the folders it needs, say what it must not do (delete, send, buy), ask it to stop and ask when it is unsure, and check the result against the originals. A useful habit from software teams is cross-checking: give the same question to two or more AI tools, compare the answers, and decide from the evidence, not from the majority. SONUB's own developers work this way — one question goes to several AI models, and every claim is then checked in the source files.

Explain it yourself

List four things a good task brief for an agent tool must contain.

Compare with an explanation

The goal, the input (which files or folder), the expected output, and the limits (what it must not do, and when to stop and ask).

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

What an agent tool is (5 min) → a live task with limits (15 min) → students design a task brief (20 min) → cross-check two AI answers (10 min).

Show on screen

  1. Give Cowork a sample folder of notes and ask for a one-page summary document; point out where it asks for permission.
  2. Show a task brief with limits: which folder, what output, what it must not do, and when to ask.
  3. Ask the same factual question to two AI tools, compare the answers and check the source.

Student tasks

  1. Write a task brief for a real chore: the goal, the input folder, the expected output and three things it must not do.
  2. If you have access, run it in Cowork and compare three items of the output with the originals; if not, ask two AI tools the same question and compare.

Done when

The brief names the goal, the input, the output and the limits, and the student reports at least one item they checked.

If students get stuck

  • No paid plan: write the task brief and do the cross-checking task with free tools — the planning skill is the same.
  • The agent touched the wrong files: give it a copy of the folder instead of the original, and narrow its access.

Questions for the class

  • Why should an agent work on a copy of your files at first?
  • When AI tools disagree, why decide from the evidence instead of the majority?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 27 · Advanced · Agents that keep working

Goal and Ralph Loop: let an agent keep going until it is really done

Goal

Set a goal with a clear finish line, run an agent in a loop until the goal is met, and stop it safely with checks, limits and budgets.

Normally an agent stops after one reply. A goal turns one request into a long task: you state the objective and the finish line, and the agent keeps working, checking its progress after each step. In Codex this is the /goal command — /goal with the outcome sets it, /goal shows it, and /goal pause, resume or clear control it; a goal is active, paused, complete or budget-limited, and it may be marked complete only when evidence such as passing tests supports it. The is the same idea built from a simple trick: a Stop hook catches the agent when it tries to finish and feeds the same prompt back in. The agent sees its own earlier work in the files and Git history and improves it, round after round.

A closer look

A loop is only as good as its finish line. "Make it better" never ends; "all tests in tests/ pass and the page loads without errors" can be checked. Always set a limit — a maximum number of rounds, a completion phrase the agent may say only when it is true, or a token budget — or the loop can run all night and spend money for nothing. Start loops on a fresh Git branch, keep the project's rules in CLAUDE.md or AGENTS.md, and check the result yourself: "done" from an agent is a claim, not a proof.

Commands to type in your terminal
# Codex — one long task with a finish line you can check
/goal All tests in tests/ pass and the homepage loads without errors
/goal               # show the goal and its status
/goal pause         # also: /goal resume, /goal clear

# Claude Code — Ralph Loop plugin: the same prompt again and again, with limits
/ralph-loop "Fix the failing tests in tests/. Say DONE only when all pass." --completion-promise "DONE" --max-iterations 5

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Rewrite "make the homepage good" as a goal for a loop.

Compare with an explanation

For example: "The homepage passes the HTML validator, has no console errors, reads well at 390 px width and every link works. Stop after at most 8 rounds." It has checkable conditions and a limit.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Why one reply is not enough for big tasks (5 min) → write a goal with a finish line (10 min) → run a short loop with a limit (20 min) → review what it did in Git (15 min).

Show on screen

  1. In Codex type /goal with a measurable objective, then /goal to see the status, and pause it.
  2. Start a Ralph Loop in Claude Code with a completion phrase and a maximum of 5 rounds, and show the state file that counts the rounds.
  3. Show git log after the loop and check the work against the finish line.

Student tasks

  1. Rewrite three vague requests ("improve my site", "fix bugs", "write tests") as goals with a checkable finish line.
  2. Run one loop of at most 5 rounds on a practice branch and write what each round changed.

Done when

The goal has a checkable finish line and a limit, the loop stopped by itself, and the student verified the result.

If students get stuck

  • The loop never stops: cancel it, add a maximum number of rounds and a finish line that can be tested.
  • Each round undoes the last one: the goal is unclear — write the finish line as a test or a checklist.

Questions for the class

  • Why does a loop need both a finish line and a limit?
  • Why should you still check the work when the agent says it is done?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 28 · Advanced · Agents that keep working

VPS and tmux: keep an agent working 24 hours a day

Goal

Rent a small (), connect with , run an agent inside so it keeps working after you disconnect, and keep the server and your keys safe.

A VPS is a small computer you rent in a data centre; it stays on when your laptop sleeps. You connect with ssh user@address using an SSH key instead of a password, install your tools (Git, Node.js, Python, the agent) and clone your project. If you start an agent directly in the SSH session, it stops when the connection drops. tmux solves that: tmux new -s agent opens a session, you start the agent inside it, press Ctrl+b then d to detach, and later tmux attach -t agent brings you back to the same screen. tmux ls lists the sessions.

A closer look

An agent running all night needs guard rails. Give it a clear goal with a finish line and a limit, run it on a branch, and let it commit so you can review the work in the morning. Keep API keys in environment variables, never in the repository, and set a spending limit with your AI provider. Protect the server: SSH keys only, a firewall, and regular updates. Check on the session with tmux attach or by reading the Git log, and stop it with Ctrl+C or tmux kill-session -t agent.

Commands to type in your terminal
ssh user@address               # log in with an SSH key, not a password
tmux new -s agent              # open a session called "agent"
claude                         # start the agent with a goal and a limit
# press Ctrl+b, then d         -> detach; the agent keeps working
exit                           # log out — the session stays on the server

ssh user@address
tmux ls                        # list sessions
tmux attach -t agent           # back to the same screen
tmux kill-session -t agent     # stop it for good

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Write the commands to start a tmux session called agent, leave it running and come back to it later.

Compare with an explanation

tmux new -s agent, start the program, press Ctrl+b then d to detach; later, after logging in again, tmux attach -t agent. tmux ls shows the sessions if you forget the name.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Why a server: always on, always online (5 min) → SSH in with a key (10 min) → tmux new, detach, attach (15 min) → start a limited agent loop and check it later (20 min).

Show on screen

  1. Connect with ssh, run tmux new -s agent, start a long command, press Ctrl+b d, log out, log in again and tmux attach -t agent.
  2. Inside tmux start an agent with a goal and a round limit on a practice branch.
  3. Show where the API key lives (an environment variable) and the provider's spending-limit page.

Student tasks

  1. Practise tmux on your own computer or a VPS: create a session, detach, list sessions, attach and kill it.
  2. Write a night-run plan: the goal and finish line, the limit, the branch, how you will check it and how you will stop it.

Done when

The student can keep a program running after disconnecting with tmux and has a safe night-run plan with a limit and a review step.

If students get stuck

  • "no sessions" on attach: the session was ended or the server restarted — check with tmux ls and start a new one.
  • SSH asks for a password or is refused: add your public key to the server and connect with the matching user.

Questions for the class

  • Why does a program stop when SSH disconnects, and how does tmux prevent that?
  • What three limits should an agent running all night always have?
Sources and further reading
Chapters
Chapter 29 · Master · Build your own LLM

Numbers, predictions, and activations

Goal

Build small functions and explain what their outputs mean.

Start with an average, a maximum value, and a threshold classifier. max returns the largest value; argmax returns its position. For single-label classification, that position can identify the highest-scoring class. A score is not automatically a calibrated probability. Changing a decision threshold can change which examples are classified as positive.

A closer look

A neuron can combine inputs as z = w·x + b and apply an . Sigmoid maps a finite real number to a value between 0 and 1; it is one activation, not the definition of every neuron. Other networks use ReLU or GELU. Implementing sigmoid shows a building block, not a trained network. The missions then introduce models fitted from data; passing examples is a checkpoint, not proof of generalization.

Explain it yourself

For [0.2, 0.7, 0.1], what do max and argmax return using zero-based indexing?

Compare with an explanation

max = 0.7; argmax = 1. A value and its index are different outputs.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Average, max and argmax (10 min) → thresholds and activations (10 min) → students do the AI lab missions (20 min) → self-check (10 min).

Show on screen

  1. For [0.2, 0.7, 0.1] show max, argmax and the class that argmax chooses.
  2. Move a decision threshold from 0.5 to 0.3 and show which examples change class.

Student tasks

  1. Complete the average, maximum and threshold missions in the AI lab code mode.

Done when

The student explains the difference between max and argmax and why a score is not automatically a probability.

If students get stuck

  • Off-by-one answers for argmax: remind students that Python counts positions from 0.

Questions for the class

  • Why might a doctor choose a lower threshold for a warning test?
Sources and further reading
Chapters
Chapter 30 · Master · Build your own LLM

Train and evaluate a small model

Goal

Separate training from evaluation and explain the limits of a score.

Use scikit-learn to fit and classification models. Iris has four measurements: sepal length and width, and petal length and width. Split data before fitting. Learn from the training portion and evaluate on held-out examples. A high training score can coexist with poor results on new data; this is . Keep preprocessing fitted to too, so evaluation information does not leak into learning.

A closer look

The neighbor count k and tree depth are chosen outside fitting; coefficients can be learned parameters. Use a split or cross-validation to choose settings, then reserve the test set for the final estimate. Repeatedly tuning to test results makes that estimate optimistic. Report the split, baseline, score, and errors. One small Iris experiment is a first project, not proof that a model works for every population or task.

Explain it yourself

A model scores 100% on the data it learned from. What should you check next?

Compare with an explanation

Evaluate on appropriate unseen data and inspect errors and leakage. Training accuracy alone is not enough.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Train/test split on the board (10 min) → fit and evaluate a model (15 min) → students compare training and test scores (15 min) → self-check (10 min).

Show on screen

  1. Split a small table into training and test rows, fit on the first part and score on the second.
  2. Show a model that scores 100% on training data and worse on test data, and name it overfitting.

Student tasks

  1. Complete the regression and classification missions and write down the training and test scores.

Done when

The student explains why a score on the training data is not enough.

If students get stuck

  • Data leakage: make sure scaling and other preprocessing are fitted on the training part only.

Questions for the class

  • Your model scores 100% on its training data. What do you check next?
Sources and further reading
Chapters
Chapter 31 · Master · Build your own LLM

Build an LLM 1: characters, counts and a first generator

Goal

Turn text into numbers with a character tokenizer, count which character follows which, and generate new text from those counts.

Every language model starts by turning text into numbers. The simplest tokenizer gives each character an ID. The simplest model, a bigram model, counts how often each character follows each other character and turns the counts into probabilities. To generate text it picks the next character with those probabilities, adds it, and repeats. Run the code below: it prints the IDs, the most likely characters after "h", some generated text and the loss.

A closer look

The loss measures how surprised the model is by the real next character — the average of minus the log of its probability. A perfect model would have a loss of 0. Real LLMs use tokens made of several characters and look at a much longer context, but the loop is the same: text → IDs → probabilities for the next token → pick one → repeat.

Example code Runs in your browser with Python and NumPy. Change the code and run it again.

Explain it yourself

The table says that after "t" comes "h" with probability 0.7 and "e" with 0.3. What happens when the model generates after "t"?

Compare with an explanation

It picks "h" about 7 times in 10 and "e" about 3 times in 10, at random according to those probabilities, and then continues from the character it picked.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Text into numbers on the board (10 min) → run the code and read the output (10 min) → students change the text and the start character (20 min) → talk about the loss (10 min).

Show on screen

  1. Run the code and explain each printed line: the vocabulary, encode and decode, the probabilities after "h", the generated text and the loss.
  2. Change the training text to a few sentences in another style and run it again; show how the generated text changes.
  3. Point at the probs line and show that every row adds up to 1.

Student tasks

  1. Replace the text with three sentences of your own and generate 40 characters from a letter of your choice.
  2. Find which character most often follows "e" in your text and check it by counting by hand.

Done when

The student runs the code with their own text and explains what one row of the probability table means.

If students get stuck

  • A KeyError when generating: the start character is not in the text; choose a character that appears in it.
  • The output looks like nonsense: that is expected, because a bigram model sees only one previous character.

Questions for the class

  • Why does a model have to turn text into numbers?
  • What would a loss of 0 mean?
Sources and further reading
Chapters
Chapter 32 · Master · Build your own LLM

Build an LLM 2: a neural network that learns

Goal

Replace counting with a small neural network that learns embeddings and weights by and sees three characters of context.

A counting table cannot look further back without exploding in size, but a neural network can. Each character gets a learned vector, an embedding. The model joins the vectors of the last three characters, passes them through a hidden layer and outputs a score for every possible next character; softmax turns the scores into probabilities. Training compares the prediction with the real next character, computes the loss, and moves every weight a small step in the direction that lowers it. That step is gradient descent, and the backward pass computes the direction.

A closer look

Watch the loss fall as the steps go by: the network is learning. The generated text now forms real words because it sees more context. Temperature controls how adventurous generation is — below 1 picks safer characters, above 1 takes more risks. Large LLMs have billions of weights and train on enormous amounts of text with , but each training step is this same idea.

Example code Runs in your browser with Python and NumPy. Change the code and run it again.

Explain it yourself

What happens to the generated text when the temperature goes from 0.8 down to 0.2, and why?

Compare with an explanation

It becomes more repetitive and safe, because dividing the scores by a small temperature makes the most likely character's probability much larger than the others.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Embeddings and a hidden layer on the board (10 min) → run the code and watch the loss (10 min) → students change the temperature and the text (20 min) → explain one training step (10 min).

Show on screen

  1. Run the code and point at the loss falling every 50 steps.
  2. Change the temperature in generate() to 0.3 and then to 1.5 and compare the texts.
  3. Set lr to 5.0 and run again; show that a step that is too large makes training unstable.

Student tasks

  1. Change the training text to your own sentences and train again; note the final loss.
  2. Try two temperatures and describe the difference in one sentence.

Done when

The student shows the loss going down and explains what an embedding and a training step are.

If students get stuck

  • The loss becomes nan: the learning rate is too high; lower lr to 0.5 or less.
  • Generation fails with your text: the start string must be three characters that appear in the text.

Questions for the class

  • What does the backward pass compute?
  • Why does more context make the text look more like real words?
Sources and further reading
Chapters
Chapter 33 · Master · Build your own LLM

Build an LLM 3: attention, the heart of a transformer

Goal

Add self-attention so that every position can look back at earlier characters and decide which ones matter, then train it and inspect it.

Transformers, the architecture behind today's LLMs, are built on attention. For each position the model makes a query (what am I looking for?), and every earlier position offers a key (what do I contain?) and a value (what do I pass on?). Comparing the query with the keys gives attention weights that add up to 1, and the output mixes the values with those weights. A causal mask stops a position from looking at characters that come after it, so the model cannot cheat. Position embeddings tell the model where each character stands.

A closer look

This code trains one attention head with a context of eight characters, entirely in NumPy, and prints the attention weights of the last character, so you can see which earlier characters it relies on. A real transformer stacks many layers with many heads each, adds feed-forward layers and normalisation, and trains with an optimiser such as Adam on far more text. Everything else — tokens, embeddings, softmax, loss, gradient descent and sampling — you have now built yourself.

Example code Runs in your browser with Python and NumPy. Change the code and run it again.

Explain it yourself

In one sentence each, say what the query, the key and the value do.

Compare with an explanation

The query describes what the current position is looking for; the key describes what each earlier position contains so that it can be matched with the query; the value is the information passed on in proportion to that match.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Query, key and value with an everyday example (10 min) → run the code and read the loss and the attention weights (10 min) → students experiment (20 min) → connect it to real LLMs (10 min).

Show on screen

  1. Explain attention with a sentence: in "the dog ran because it was scared", the word "it" attends to "dog".
  2. Run the code and read the attention weights of the last character: which earlier positions get the most weight?
  3. Remove the mask (multiply it by 0) and show that the loss drops suspiciously low because the model can see the answer.

Student tasks

  1. Train with your own text and generate from a start string of your choice.
  2. Print the attention weights for another example, such as X[10:11], and describe what the last character attends to.

Done when

The student trains the model, shows the loss going down, and explains query, key, value and the causal mask in their own words.

If students get stuck

  • Shape errors after changing T: the mask and the windows both depend on T, so change T in one place only.
  • Training is slow on an old device: lower the number of steps to 200; the loss still falls.

Questions for the class

  • Why does the model need a causal mask?
  • What do the attention weights of one position add up to?
Sources and further reading
Chapters
Chapter 34 · Master · Build your own LLM

Build a GPT on your computer: GPT-2 in miniature

Goal

Train a small GPT with the same design as GPT-2 on your own computer with Python and PyTorch, watch the loss fall and generate text from your model.

GPT-2 is a stack of transformer blocks: token and position embeddings, then layers of self-attention and a small neural network, then a final layer that scores every possible next token. The smallest GPT-2 has about 124 million parameters and was trained on billions of tokens with large GPUs for days — too big for a laptop. The same design, made small, does train on a laptop: with 4 layers, 4 attention heads and 128-number embeddings (about 0.8 million parameters) it learns from a small text such as Shakespeare in about 3 minutes on the CPU. Andrej Karpathy's open-source nanoGPT is the classic short code for this: prepare the data, run the training script, then sample text. Its author now marks it as old and points to nanochat, a newer full-stack project, but nanoGPT is still the clearest way to see a GPT-2-style model in a few hundred lines.

A closer look

Training repeats one step: take a batch of text, predict each next token, measure the error (the loss), and nudge every parameter to make it smaller. Watch two numbers — the training loss and the validation loss on text the model has not seen; if only the training loss falls, the model is memorising. When training ends you have a checkpoint file with all the parameters. On a Mac use the mps device, on an NVIDIA card use cuda, and otherwise the cpu with a smaller model. The browser chapters before this one built the same pieces by hand in NumPy; here you use them at real size.

Commands to type in your terminal
git clone https://github.com/karpathy/nanoGPT
cd nanoGPT
pip install torch numpy transformers datasets tiktoken wandb tqdm

python data/shakespeare_char/prepare.py      # text -> characters -> numbers

# a small GPT on the CPU (about 3 minutes); on a Mac use --device=mps
python train.py config/train_shakespeare_char.py --device=cpu --compile=False \
    --eval_iters=20 --log_interval=1 --block_size=64 --batch_size=12 \
    --n_layer=4 --n_head=4 --n_embd=128 --max_iters=2000 \
    --lr_decay_iters=2000 --dropout=0.0

python sample.py --out_dir=out-shakespeare-char --device=cpu

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Name the three main parts of a GPT and what each one does.

Compare with an explanation

Embeddings turn tokens and positions into vectors; transformer blocks (self-attention plus a small neural network) mix information between the tokens; the output layer turns the last vector into a score for every possible next token. Then sampling picks the next token.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

From the three browser chapters to GPT-2: the same blocks, bigger (10 min) → set up Python and PyTorch (10 min) → prepare data and start training (15 min) → sample text and read the loss curve (15 min).

Show on screen

  1. Show the GPT-2 block diagram and match each part to the build-llm chapters: embeddings, attention, the next-token scores.
  2. Run the Shakespeare character-level training from nanoGPT with a small CPU setting (about 3 minutes) and show the training and validation loss as it prints.
  3. Generate text from an early checkpoint and from the final one, and compare.

Student tasks

  1. Train the small model on your computer (or on a free cloud notebook) and save the loss values at the start and the end.
  2. Change one setting — the number of layers, the embedding size or the training steps — and write how the loss and the text changed.

Done when

The student trained a model, has a checkpoint, can show the loss falling and can explain training loss versus validation loss.

If students get stuck

  • Out of memory: lower the batch size, the block size or the number of layers.
  • Training is very slow on the CPU: make the model smaller or use a free cloud notebook with a GPU.

Questions for the class

  • Why does the same GPT-2 design work at a much smaller size?
  • What does it mean when the training loss keeps falling but the validation loss rises?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 35 · Master · Run your model anywhere

The runner: the program that brings a model to life

Goal

Explain what a does — load the weights, tokenize, run the model step by step, sample and stream — and run a model with llama.cpp or Ollama.

A trained model is only a file of numbers. A runner is the program that uses it: it loads the weights into , turns your text into tokens with the model's tokenizer, runs the model to get scores for the next token, samples one token with settings like temperature, adds it to the text and repeats — each new token to the screen. It also keeps a of earlier work (the ) so each new token is fast, and it applies the chat template the model was trained with. ChatGPT, Ollama and llama.cpp are all runners around models.

A closer look

Runners differ in where they run and which file formats they read. PyTorch runs your training checkpoint directly; llama.cpp and Ollama run files on ordinary computers and phones; browsers and phones can also use ONNX or Apple's and Google's own runtimes. Many runners offer a local API, so your own app can talk to a model on your computer exactly like it talks to a cloud API — with no key and no data leaving the machine. Your nanoGPT checkpoint becomes runnable in these engines after a conversion step, which the next chapter does.

Commands to type in your terminal
# a runner on your computer: download a small open model and chat
ollama run llama3.2:1b

# the same runner as a local API — no key, nothing leaves the machine
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2:1b",
  "prompt": "Explain a token in one sentence."
}'

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

List the steps a runner repeats to produce each new token.

Compare with an explanation

Take the text so far (as tokens), run the model to get a score for every possible next token, turn the scores into probabilities, sample one token (using temperature and similar settings), append it and show it, then repeat until a stop token or the length limit.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Weights are just numbers: what is missing? (5 min) → the runner's loop step by step (15 min) → run a small open model with Ollama or llama.cpp (20 min) → call its local API (10 min).

Show on screen

  1. Write the runner loop on the board: tokenize → model → scores → sample → append → repeat, and connect it to the sampling chapter.
  2. Run a small open model locally (for example ollama run with a 1-billion-parameter model) and show tokens streaming.
  3. Call the local API with curl and show the same answer coming back as JSON.

Student tasks

  1. Write the runner loop as numbered steps in your own words and mark where temperature is used.
  2. Run a small open model on your computer and measure how many tokens per second it produces.

Done when

The student can explain each step of the runner loop, has run a local model and knows that a runner can serve a local API.

If students get stuck

  • The model is too slow or does not fit: choose a smaller model or a more strongly quantized file.
  • The answers look strange: the chat template or tokenizer does not match the model — use the files that came with it.

Questions for the class

  • Why is a weights file alone not enough to chat with a model?
  • What is the advantage of running a model locally instead of through a cloud API?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 36 · Master · Run your model anywhere

Your LLM on your phone: convert, shrink and embed

Goal

Convert a model to a phone-friendly format, shrink it with , embed it with a runner in an app and use it offline on your own phone.

Phones have little memory, so the model must be small and compressed. Quantization stores each parameter with fewer bits — for example 4 bits instead of 16 — which makes the file about four times smaller with only a small loss in quality. The usual path is: convert the model to GGUF with the llama.cpp conversion tools, quantize it (Q4_K_M is a common choice), and test it on your computer first. Your own nanoGPT can be exported this way, though a tiny model trained on Shakespeare will only write Shakespeare; for a useful assistant, start from a small open model of about 1 to 3 billion parameters.

A closer look

To use it on a phone there are two ways. The quick way: copy the GGUF file into an app that already contains a runner, such as PocketPal AI, and chat offline. The builder's way: embed the runner in your own app — for example llama.rn in a Native app or a llama.cpp binding in a Flutter app — ship or download the model file, and call it from your code. Everything stays on the phone, so it works without the internet and keeps data private, but it is slower than the cloud and uses battery, so keep prompts short and models small. Another way is to keep the runner on your computer and call its local API from the phone over the same Wi-Fi — easier, but it works only near that computer. Do not confuse embedding a model in an app with embeddings, the vectors from the embeddings chapter; a small embedding model on the phone can also search your own notes.

Commands to type in your terminal
# your own nanoGPT: train it with the GPT-2 tokenizer (data/shakespeare, not shakespeare_char)
# and save the weights as a Hugging Face GPT-2 folder (./my-model) — then it converts like any model

# llama.cpp: model folder -> GGUF (16-bit) -> 4-bit Q4_K_M
python convert_hf_to_gguf.py ./my-model --outfile my-model-f16.gguf
./llama-quantize my-model-f16.gguf my-model-Q4_K_M.gguf Q4_K_M
ls -lh my-model-*.gguf         # about four times smaller

# quick way: copy my-model-Q4_K_M.gguf into an offline chat app (e.g. PocketPal AI)
# builder's way: embed a runner in your app (llama.rn, a llama.cpp binding) and load the file

These run in a terminal on your own computer or server, not on this page. Read each line before you run it.

Explain it yourself

Describe the path from a trained model on your computer to a chat on your phone in four steps.

Compare with an explanation

1. Convert the model to a phone-friendly format such as GGUF. 2. Quantize it (for example to 4 bits) so it fits in memory. 3. Put it in an app that contains a runner — an existing offline chat app or your own app with an embedded runner. 4. Load it on the phone and chat offline. Testing on the computer between the steps is also good.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Why phones need small models (5 min) → convert and quantize on a computer (15 min) → run it in a phone app (15 min) → how an app embeds a runner (15 min).

Show on screen

  1. Show the file size of the same model at 16-bit and at 4-bit and test both on a computer.
  2. Load a small quantized GGUF model into an offline chat app on a phone, turn on airplane mode and chat.
  3. Show a few lines of app code that load the model file and stream tokens from the embedded runner.

Student tasks

  1. Choose a small open model, find its quantized GGUF file, and estimate whether it fits in your phone's memory.
  2. Run it on your phone offline and write the speed (tokens per second) and one thing it does well and one it does badly.

Done when

The student can explain conversion, quantization and embedding a runner in an app, and has run a model offline on a phone (or on a computer if no phone is available).

If students get stuck

  • The app crashes when loading: the model is too big for the phone's memory — use a smaller model or stronger quantization.
  • No phone available: run the same GGUF file with llama.cpp on a computer; the steps are the same.

Questions for the class

  • What do you gain and what do you lose with 4-bit quantization?
  • Why is an on-device model good for privacy?
Sources and further reading

Product details checked on 2026-10-15. AI tools change quickly — compare with the official page.

Chapters
Chapter 37 · Master · Final project

Final project: build something with AI and show your work

Goal

Plan, build and present a small project with the tools of this course, with a Git history and checks that show it works.

Choose a small, useful project — for example a quiz generator for your class, a script that organises your files, a web page about a hobby, or your own mini language model trained on a text you like. Write a one-page plan: the goal, the users, and how you will check that it works. Build it with a coding agent in small loops, commit after each working step, and keep the agent on your rules with AGENTS.md, CLAUDE.md or a skill. Finally, open a pull request on GitHub that describes what you built and how to try it.

A closer look

The presentation matters as much as the code: show the plan, one moment when the AI got something wrong and how you noticed, the tests or checks you ran, and what you would do next. Credit honestly — say which parts you wrote, which the AI wrote, and how you checked them.

Explain it yourself

What four things should the description of your final pull request contain?

Compare with an explanation

What the project does, how to run or try it, how it was checked (tests or examples), and which parts were made with AI help.

You mark this yourself. Nothing is graded here.

Mark this chapter as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.

Teaching guide

How to run this chapter in class. Students may read it too.

Lesson flow

Project ideas and scope (15 min) → students plan and build over one or more lessons → presentations with the Git history and a demo (about 10 min each).

Show on screen

  1. Show an example plan with a goal, users, checks and three milestones.
  2. Show a finished example repository: the commits, a CLAUDE.md or AGENTS.md, and a pull request with a clear description.
  3. Give a short example presentation that includes one AI mistake and how it was caught.

Student tasks

  1. Write the one-page plan and get the tutor's approval before you start building.
  2. Build it in at least three commits and open a pull request with a description and instructions to try it.

Done when

The pull request exists, the project works as described, and the student can explain one AI mistake and one check.

If students get stuck

  • The project is too big: cut it down to one feature that works from start to finish, then add more.
  • The code works but the student cannot explain it: ask the agent to explain it line by line, then rewrite one part yourself.

Questions for the class

  • Which check gave you the most confidence that your project works?
  • Which parts did you do yourself, and which did the AI do?