๐ง Learn AI the school way
How models actually work (tokens โ embeddings โ attention โ RLHF & LoRA), then
how to use them well (prompting, RAG, agents, diffusion) โ every concept as a school story,
every lesson with a numbered diagram and a hands-on lab. The labs are zero-dependency
Python : no GPU, no API key, no pip install.
๐ฌ Companion video:
9 AI Concepts Explained in 7 minutes (ByteByteAI) โ the aerial view;
this course is the slow ground tour of every concept it names.
๐งฉ tokens ๐บ๏ธ embeddings
๐ attention โญ RLHF & LoRA
๐ RAG ๐ agents ๐บ diffusion
๐ฌ Part 1 โ INSIDE the model
rules are grown from examples, not written ๐
text becomes puzzle pieces ๐งฉ seated by meaning ๐บ๏ธ
one game: guess the next piece ๐ฒ โ with glancing ๐
finishing school: etiquette, gold stars, sticky notes โญ
๐งฐ Part 2 โ USING it for real
ask the librarian well; mind the small desk ๐ฃ๏ธ๐ช
the confident kid makes things up โ defenses ๐
open-book exams (RAG) ๐ and hall passes (agents) ๐
un-blur the static: diffusion & multimodal ๐บ
๐บ๏ธ The big picture โ one diagram, both worlds
The whole course on one canvas. Click for the
4K version .
๐ฌ Part 1 โ inside the model (lessons 1โ7)
One git branch = one idea; branch 05 contains lessons 01โ05. Labs run with plain Python 3.
๐งฐ Part 2 โ using it for real (lessons 8โ12 + bonus 13)
No installs here either โ the labs use any chatbot you already have, plus paper and honesty.
# take the course locally:
git clone https://github.com/BaluRaut/learn-ai-school.git
cd learn-ai-school
python3 demo/bigram_model.py # a language model in 60 seconds
git checkout lesson-01-what-is-ai # then lesson by lesson
๐
Went deep on lesson 13? There is now a whole
MCP school โ with a real server & client in the repo and 5 use cases with sequence diagrams. And for lesson 11: the
Agents school โ a runnable agent, guardrails, failure modes, and 5 patterns. And for lessons 04 & 10: the
VectorDB school โ a runnable mini vector database and the RAG machine room.
๐ The lesson diagrams โ follow the numbers
Every lesson as one numbered box-and-arrow diagram (purple = inside the model,
teal = using it) โ also on a standalone page .
1 ๐ What is AI
Rulebooks vs learning from examples โ the rules are grown, not written.
๐ the rulebook way if ears AND whiskers AND tailโฆ rule #41 breaks on cartoon cats ๐ฅ ๐ฑ the examples way 10,000 photos: cat / not-cat โ๏ธ training rules GROW inside ๐ง model answers even for NEW cats 1 2 AI โ machine learning โ deep learning โ LLMs โ this course walks inward 3
2 โ๏ธ Training
Practice tests + the red pen โ loss and tiny downhill nudges.
๐ examples question + true answer ๐ง model millions of dials โ๏ธ prediction ๐ด loss HOW wrong? 1 โฐ๏ธ gradient descent: nudge EVERY dial slightly downhill 2 repeat millions of times ๐งช validation set = unseen questions โ catches memorizers (overfitting) 3
3 ๐งฉ Tokens
Cutting text into puzzle pieces โ why 'strawberry' is hard.
๐ text 'the robot reads' ๐งฉ tokenizer - BPE glue the most frequent pair, repeat thousands of times ๐ข token IDs [464, 9379, 9743] 1 2 the model sees ONLY these pieces โ never words, never letters: why 'how many R's in strawberry' is hard ๐ ยท why pricing is per-token ยท why some languages cost 3ร 3
4 ๐บ๏ธ Embeddings
The seating chart of meanings โ similar words sit together.
๐งฉ token 'cat' ๐บ๏ธ its seat coordinates [0.31, -1.2, 0.88, โฆ] ร768 learned, not drawn the seating hall - meaning space cat ๐ฑ kitten dog ๐ถ ๐ stapler - far 1 2 distance = similarity โ semantic search, RAG (L10), kingโman+womanโqueen ๐ 3
5 ๐ฒ Next-token prediction
The sentence-completion game, with a temperature dial.
๐ pieces so far 'The dog chased the' ๐ scoreboard over ALL pieces cat 24% ยท ball 17% ยท car 9% โฆ stapler 0.0001% one full scoreboard per step ๐๏ธ temperature 0: safe ยท 1: natural 2: chaos 1 2 ๐งฉ picked: 'cat' โ glue on 3 repeat โ that's why answers STREAM
6 ๐ Attention
Kids glancing around the class โ who does 'it' refer to?
'The robot dropped the ball because IT was heavy' ๐ 'it' glances around learned weights: robot 65% ยท heavy 14% ยท ball 5% ๐จ blend 'it' comes out ROBOT-flavored ๐ค ๐๏ธ transformer this, รmany heads, ร32 layers, ALL tokens in parallel 1 2 3 queryยทkey similarity on the seats (L04) โ softmax โ weighted blend โ demo prints these exact numbers
7 โญ RLHF & LoRA
Library, etiquette class, gold stars โ and sticky notes.
๐ pretraining read EVERYTHING months ยท $$$M ยท once ๐ fine-tuning QโA examples: learn to ANSWER โญ RLHF humans pick better โ taste-judge โ nudge ๐ค the assistant 1 2 3 ๐๏ธ LoRA: freeze the brain, learn tiny sticky notes ~0.1% of the size ยท one GPU ยท swappable per customer 4
8 ๐ฃ๏ธ Prompting & context
How you ask the librarian โ and the small desk it fits on.
๐ช the desk - context window: N tokens, that's ALL there is ๐ role + rules (system) ๐ฌ conversation - oldest slides off ๐ pasted docs + examples โ๏ธ the answer itself - also here! ๐ฃ๏ธ the craft say who to be ยท exact ask ยท show examples (few-shot) ยท 'think step by step first' 1 ๐ณ๏ธ not on the desk = doesn't exist: no memory between chats ยท middle gets skimmed 2 same model, 10ร better output โ prompting is iteration, not incantation 3
9 ๐ Hallucinations
The confident kid who never says 'I don't know'.
โ thin-shelf question 'books about Mongolian pirates?' ๐ง the machine produce the LIKELIEST continuation truth was never in the loss (L02) ๐ fluent ยท confident ยท WRONG realistic fake title, fake author, page count 1 2 ๐ defense 1: facts ON the desk (paste them โ or RAG, L10) ๐งพ defense 2: 'quote the exact sentence you base this on' ๐คท defense 3: 'if unsure, say so' + verify anything you'd act on 3
10 ๐ RAG
The open-book exam, automated with the seating chart.
1 before exam season - once ๐ handbook โ โ๏ธ chunks ๐บ๏ธ vector DB seat per chunk โ question embedded too ๐ nearest seats = most relevant chunks ๐ช the desk question + those chunks + 'answer ONLY from these, cite' ๐งพ 2 3 4 facts โ RAG ยท style โ fine-tune (L07) โ the rule of rules
11 ๐ Agents & tools
A student with a to-do list and a hall pass.
๐ goal 'organize the class picnic' ๐ง THINK next-token planning in words (L05!) ๐งฐ ACT writes a tool call: roster.count() ๐ LOOK result โ desk: 23 kids 1 2 3 loop until the goal is met ๐ง guardrails: read-only tools by default ยท spending caps ยท human sign-off for field-trip forms ยท logs of every step 4
12 ๐บ Diffusion & multimodal
Un-blurring TV static, step by step, toward your words.
๐จ homework, millions of times ๐ฑ photo +noise ร1000 ๐บ static learn: predict the noise ๐บ pure static ๐ un-noise ร20-50 steps prompt's meaning-seat (L04) steers each step ๐ฑ๐ 'cat with a crown' 1 2 ๐ multimodal: images/audio become tokens too โ same desk, same attention (L03/L06) 3
13 ๐ Bonus: MCP
The universal plug โ deep-dive course: learn-mcp-school ๐
๐ before MCP every app ร every tool = a hand-built adapter (NรM) ๐ซ hosts - the rooms Claude Desktop ยท IDE ยท your agent โ standard sockets ๐ ๐ฌ MCP servers files ยท GitHub ยท your DB โ standard plugs 1 2 each server announces: my TOOLS ๐งฐ ยท my RESOURCES ๐ ยท my PROMPTS ๐ discover (tools/list) โ call (tools/call) โ result lands on the desk โ L11's loop, standardized 3 ๐ง a server runs with YOUR permissions โ installing one = installing software; L11 guardrails apply double 4
Start Lesson 01 โ
๐๏ธ Study plan (4 weeks)
๐ All 13 lesson diagrams
๐งช Quiz
โฎ๏ธ Before & trade-offs