🧪 AI Lab — Interactive Playground

Companion to the 8-chapter course and the micrograd / tokenizer / attention / matmul / embeddings / rag / finetuning / serving modules · everything below is the SAME code you built, running live in your browser · no libraries
← Main site 📘 Take the course 💻 GitHub

📱 These 7 concepts power the apps you use every day

Every time you open Gmail, ChatGPT, Spotify, or Google Translate — these exact algorithms are running. Hover each app to see which concept it uses.

📧GmailSpam filter → Scenario 2
💬ChatGPTTokenizer + Attention → Scenarios 3,4
🌐Google TranslateAttention → Scenario 4
🎵SpotifyTemperature sampling → Scenario 5
🏠ZillowRegression → Scenario 2
🛒AmazonRecommendation → Scenario 2
📸Face IDNeural net → Scenario 1
🗣️Siri/AlexaAttention + tokenizer → Scenarios 3,4

☂ Scenario 1 — The Umbrella Neuron live

A trained neuron with FROZEN weights (w=[+2.0,−0.5,+1.0], b=−0.3) decides for you.

📧 Gmail spam filter 💳 Credit card fraud check 🔔 "Cancel subscription?" prompts 🏥 Triage: urgent or not?

👆 Drag the sliders — find the exact point where the verdict flips!

🎯 Challenge: Find the exact cloudy value where the verdict flips from "bring umbrella" to "leave it" (try 0.45–0.55). That flip line is the decision boundary — every classifier has one.

🏋 Scenario 2 — Train a Network LIVE live

Real task: learn 5 weather→umbrella examples. 41 knobs, hinge loss. Watch loss fall — then drag the learning rate and see the shower-knob effect.

📧 Gmail spam filter 🏠 Zillow price estimate 📱 Face ID unlock 🎬 Netflix recommendations

👆 Click +100 steps, then drag lr to 0.5 (bounces!) then 0.005 (crawls)

🎯 Challenge: Set learning rate to 0.5 and train — watch the loss BOUNCE (the shower knob!). Then set it to 0.005 — it crawls. Find the highest LR that still converges. That's the art of tuning.

🔢 Scenario 3 — Tokenizer Lab + API Cost Calculator live

Real task: this is literally how ChatGPT bills you — you pay per TOKEN, not per word.

💬 ChatGPT / Claude billing ⌨️ Phone autocomplete 🌐 Google Translate 🔍 Google Search indexing

👆 Type emoji, Hindi, code — nothing is "unknown" (byte fallback!)

not trained yet
🎯 Challenge: Type an emoji like "🚀" — it falls back to raw bytes (4 tokens for one emoji!). Now type "the" — it's 1 token. That's why GPT charges more for emoji-heavy messages.

👀 Scenario 4 — Attention Visualizer live

The sentence every AI paper cites: what does "it" refer to? Click an ending — the bars are REAL softmax attention weights.

🌐 Google Translate 📝 Grammarly suggestions 🗣️ Siri / Alexa understanding 📧 Gmail Smart Reply

👆 Click TIRED vs WIDE — watch attention shift from animal to street

click an ending ↑
🎯 Challenge: Click TIRED → "it" looks at "animal" 60%+. Click WIDE → "it" flips to "street" 55%+. Same sentence, different meaning — attention is how AI reads context. This is the engine behind Google Translate.

🌡 Scenario 5 — Temperature Explorer live

This is ChatGPT's creativity dial, exposed. The model's honest guess is fixed — the temperature decides how adventurous the sampling is.

💬 ChatGPT creativity 🎨 DALL-E image variety 🎵 Spotify Discover Weekly 📝 Gmail Smart Compose

🧮 Scenario 6 — Context Cost: attention is O(n²) live

Why long context costs more than linear: EVERY token must score EVERY token. Drag the context length and watch the pairwise score count explode.

💬 ChatGPT long conversations 📄 Claude 100K document upload ⚡ Flash Attention (why it exists) 🧠 KV Cache (vLLM)

🧲 Scenario 7 — MatMul Visualizer live

The single loop every GPU is running right now: C[i][j] += A[i][k] · B[k][j]. Step through the multiply-accumulate and watch one cell of C fill in — billions of these sit behind every ChatGPT reply.

step through the loop ↑

🌍 Where You Just Used These Ideas In The Real World

Every card = a product you use daily, and the exact concept from phases 1–3 that powers it.

📧 Spam filterNeuron + hinge loss: features ("free money", links) → spam score. Gmail's first line of defense is exactly this shape.
→ Scenario 2 (train live)
🏠 House price estimateMSE regression: size/location → price. Zillow-style estimators start here.
→ scenarios_tester.py #8
☂ Rule-of-thumb appsFrozen-weight neuron = any instant yes/no decision (umbrella, outfit, cancel subscription?).
→ Scenario 1 (live)
💬 ChatGPT billingYou pay per TOKEN. Our lab counts tokens of your message exactly like the API meter does.
→ Scenario 3 (live)
⌨️ AutocompleteCommon chunks become single tokens → the model predicts in bigger, smarter steps.
→ tokenizer/step2
🌐 Any language, no crashesByte-level BPE: emoji, Hindi, code — nothing is "unknown". Worst case = raw bytes.
→ tokenizer/step3 (6/6 PASS)
👁️ How ChatGPT knows who "it" isSelf-attention weights link pronouns to the words they refer to — the mechanic behind translation & summarization.
→ Scenario 4 (live)
🎨 The temperature knobEvery chat UI's "creativity" slider is softmax temperature: low = focused answers, high = surprising ones.
→ Scenario 5 (live)
💸 Why long context costs moreAttention is O(n²): 2× the document = 4× the compute. The reason Flash Attention & KV caches exist.
→ Scenario 6 (live)
⚡ Matrix multiply = the GPU loopEvery neural net, every attention head, every tokenizer embedding trains on this one triple loop. When a datacenter buys GPUs, it is buying n³ loops per second.
→ Scenario 7 (live) · matmul/

🎯 Spot the AI — Interactive Quiz live

10 everyday apps — can you spot which use AI? Click each to reveal. Test yourself!

Score: 0/10 — click each card to reveal

🧪 Free-Play Sandbox live

Mix and match! Type a sentence AND pick an app to see how AI processes it.

Type a sentence to see the AI pipeline...