Learn by Doing
Interactive simulations that let you experiment with real AI concepts — no setup required.
LLM & AI
47The Agent Loop
Watch an AI agent reason, call a tool, observe the result, and loop until it has an answer. See exactly when the LLM is called versus when it isn't — and learn why a max-iterations guard is essential.
Agent Memory
See how LLMs are stateless by default and how short-term history, context overflow (truncation vs. summarization), and long-term memory retrieval let agents remember across turns and sessions.
The API Layer
Dissect a chat-completion request from the inside: roles, messages, streaming tokens, and params like temperature, max_tokens, and stop sequences. Watch what actually happens when a request hits the model — then assemble your own.
Attention Head Specialization
Different attention heads learn different jobs — copying, induction, tracking position, or linking subjects to verbs. Inspect a head's pattern on a sentence.
Self-Attention
Watch transformers decide which tokens to attend to. Explore the Q·Kᵀ/√d_k → softmax formula through animated heatmaps showing pronoun coreference, adjective–noun links, long-range dependencies, and multi-head patterns — all computed live, no LLM calls.
Beam Search vs Greedy Decoding
Keep the k most probable partial sequences at each step. Watch a beam tree branch and prune, and see why it beats greedy decoding.
BLEU & ROUGE
N-gram overlap metrics score generated text against references — BLEU on precision, ROUGE on recall. See why a perfect score can still be wrong.
BM25 vs Dense Retrieval
Keyword (BM25) and embedding (dense) retrieval rank the same documents very differently. See where each one wins and fails.
BPE Merge Order
Byte-pair encoding applies learned merge rules in strict order. Watch a word collapse from characters into subword tokens, merge by merge.
Catastrophic Forgetting
Fine-tuning on a narrow task can erase earlier general ability. Watch one skill decay as another is learned — and how regularization slows the loss.
Chunking Strategies
Tune chunk size and overlap, watch a document split in real time, and see how those settings decide whether a retrieval query finds the right answer or falls into the gap between chunks.
Context Window
Watch the model's working memory fill up — and see what gets dropped, summarised, or forgotten when it runs out. No model calls; pure budget simulation.
Contrastive Decoding
Subtract a small 'amateur' model's log-probabilities from a large 'expert' model's to suppress generic, off-topic tokens.
Cross-Attention in Encoder-Decoder Models
In encoder-decoder models, the decoder's queries attend over the encoder's outputs. See how each generated token pulls from the source sequence.
Embedding Space Arithmetic
king − man + woman ≈ queen. See how relationships between concepts become vector arithmetic in embedding space.
Embeddings & Vector Search
See how text becomes a point in vector space, why similar meanings cluster together, and how cosine similarity retrieves the nearest neighbors — including the silent embedding-mismatch failure mode where wrong-model queries return garbage results with no error.
Episodic vs Semantic Memory
Agents keep raw event logs (episodic) and distilled facts (semantic). See how distillation, retrieval, and staleness differ between the two stores.
Hybrid Search & Reciprocal Rank Fusion
Combine keyword and dense rankings with Reciprocal Rank Fusion to get better recall than either alone. See RRF merge two lists step by step.
KV Cache Mechanics
During autoregressive decoding, cached key/value tensors from earlier tokens skip recomputation. Watch the cache grow and the compute saved add up.
Layer Normalization: Pre vs Post
LayerNorm re-centers and re-scales activations to stabilize training. See pre-norm vs post-norm, and how RMSNorm simplifies it.
Logit Bias & Token Banning
Add a fixed bias to specific tokens’ logits to force or forbid them. See how −100 bans a token while a small bias just nudges it.
The Logit Lens
Project a transformer's intermediate residual stream to vocabulary space at each layer to watch a prediction take shape from layer 0 to the output.
LoRA: Low-Rank Adaptation
Freeze the giant weight matrix and learn a tiny low-rank A×B update instead. Watch trainable parameters collapse as rank drops.
MCP: Client–Server Flow
Watch JSON-RPC messages cross the MCP client↔server boundary: tool discovery, tool calls, the hard-coded-list anti-pattern, server errors, and how MCP turns N×M integrations into N+M.
The MLP as Key-Value Memory
Transformer MLP layers behave like a key-value store: the first matrix matches a pattern (key), the second writes an associated output (value).
Multi-Agent Orchestration
Watch orchestration graphs execute — sequential pipelines, parallel fan-out, routing branches, iterative loops, and misclassification corner cases. The same LLM becomes Writer, Critic, Editor, or Orchestrator by changing the system prompt.
Next-Token Sampling
Watch how a language model converts raw logits into a probability distribution and samples the next token. See how temperature sharpens or flattens the distribution, and how top-k and top-p (nucleus) sampling control which tokens can be chosen.
Parallel vs Sequential Agents
Independent subtasks can run on parallel agents to cut wall-clock time — but data dependencies force sequencing. See the scheduling tradeoff on a task graph.
Perplexity
Perplexity is the exponential of average per-token surprise. See how a model's confidence on each token rolls up into a single score.
Positional Encoding
Transformers have no built-in sense of order. See how sinusoidal encodings (and RoPE rotations) inject token position into embeddings.
Prefill vs Decode Phase
LLM inference has two phases: a compute-bound prefill of the whole prompt, then memory-bound decode of one token at a time. See why they behave so differently.
Prompt Engineering
Learn how to craft effective prompts for large language models. Experiment with techniques like few-shot prompting, chain-of-thought, and instruction tuning.
RAG Evaluation: Faithfulness vs Relevance
A RAG answer can be relevant to the question yet unfaithful to the retrieved context — or vice versa. See how these two axes are measured and diverge.
RAG Pipeline
Watch how Retrieval-Augmented Generation grounds LLM answers in your documents. See why semantic matching bridges vocabulary gaps, why top-k selection matters, and how private knowledge bypasses the training cutoff — all via a live animatable pipeline.
Repetition & Presence Penalties
Frequency and presence penalties down-weight tokens the model already used, breaking loops — but set too high they block words the text genuinely needs.
Reranking with a Cross-Encoder
A fast bi-encoder retrieves candidates; a slower cross-encoder re-reads each query–document pair jointly to reorder them. See the precision–latency tradeoff.
Self-Consistency Voting
Sample several independent reasoning paths and take the majority answer. See how voting across diverse chains beats a single chain-of-thought.
Semantic vs Lexical Similarity
Two sentences can mean the same thing with zero shared words — or share words and mean opposite things. Compare embedding cosine to keyword overlap.
Sparse Attention Patterns
Full attention costs O(n²). See how local-window, strided, and global-token patterns cut that cost — and what context they risk dropping.
Speculative Decoding
A small draft model proposes several tokens that a large verifier model accepts or rejects in one pass — trading cheap guesses for fewer expensive steps.
Structured Output
Get a model to return JSON that downstream code can actually use. Write prompts step by step — start with "just ask," then add JSON instruction, JSON mode, and finally a schema. Watch your parse rate and field-conformance climb.
Superposition & Polysemanticity
Networks pack more features than they have neurons by overlapping them. See how sparsity makes superposition work — and when features interfere.
System Prompt & Guardrails
Understand how system prompts shape AI behaviour and how guardrails prevent misuse. Attack a live bot and build your own defences.
Tokenization
Type anything and watch your input become BPE tokens — the discrete units the model actually sees. Discover why code costs more than prose, why "strawberry" trips counters, and why non-English text burns through your token budget.
Tool & Function Calling
See exactly how LLM tool calling works: the model emits a structured call, your code executes it, and the result flows back. Animate every step — tool schemas, parallel calls, invalid args, graceful errors, and direct answers.
How LLMs Learn: The Training Objective
Watch a tiny model learn to predict the next token. See how cross-entropy loss = −log(p(true token)) falls as gradient steps sharpen the probability distribution — and why ambiguous contexts always floor higher than deterministic ones.
Weight Quantization (INT8/INT4)
Shrink a model by storing weights in fewer bits. See the precision-vs-memory tradeoff, and why outlier weights cause quantization error.
Data Structures & Algorithms
34AVL Tree Rotations
Insert and delete nodes in a self-balancing AVL tree and watch the single and double rotations that restore O(log n) height.
Backtracking
Watch a depth-first backtracking search build a decision tree one choice at a time — choose, explore, then UNDO. See pruning cut dead branches early, and compare why subsets (2ⁿ), permutations (n!), and a well-pruned search visit wildly different numbers of nodes.
Bellman-Ford Algorithm
Relax every edge V−1 times to find shortest paths even with negative weights, then use one more pass to detect negative cycles.
Binary Search
Watch lo, mid, and hi converge on a target in a sorted array — half the search space eliminated at every step. See exactly why binary search is O(log n) while linear search is O(n), handle the found, not-found, and boundary cases, then search any array yourself.
Binary Search on the Answer
Search not over an array but over the answer space itself. Watch a monotonic feasibility predicate flip from false to true as binary search homes in on the minimum feasible value — using Koko eating bananas as the concrete problem.
Binary Search Tree
Watch a binary search tree grow, shrink, and reshape as you insert, search, and delete. See why insertion order makes trees balanced or degenerate, and how deletion handles leaves, single children, and two-child successors.
Bit Manipulation
Watch bits flip live for AND, OR, XOR, NOT, shifts, and common tricks — set, clear, toggle, check, isolate-lowest-set-bit, and count set bits — all on 8-bit integers, computed column by column so you see exactly which rule fires at each position.
Coin Change (Min Coins)
Fill a 1-D DP array bottom-up to find the fewest coins making each amount, watching each denomination compete for the minimum.
Dijkstra's Shortest Path
Relax edges from the cheapest unvisited node outward, maintaining a live distance table, to find single-source shortest paths in a non-negative weighted graph.
Dynamic Programming Table Builder
Watch a 2D DP table fill cell-by-cell, with every dependency highlighted as it is computed — the single biggest "aha" of DP. Compare LCS and Edit Distance recurrences side-by-side, trace the backtrace path, then build your own table from any two strings.
Edit Distance
Fill the Levenshtein DP table to find the minimum insert/delete/replace operations to transform one string into another, then trace the operation sequence.
Fenwick Tree (BIT)
See how a Binary Indexed Tree uses the i & -i bit trick to answer prefix-sum queries and apply point updates in O(log n).
Floyd's Cycle Detection
Use a slow and a fast pointer (tortoise and hare) to detect a cycle in a linked list in O(1) space, then locate where the cycle begins.
Graph Traversal & Shortest Path
Watch BFS, DFS, and Dijkstra explore a weighted graph node-by-node. See the frontier expand, track tentative distances relaxing in real time, and discover why algorithm choice determines whether you find the shortest or deepest path first.
Hash Table
Watch a key travel through a hash table: compute a visible hash, mod it by the capacity to pick a bucket, chain on collision, and walk the chain to find or delete. Then cross the load-factor threshold and watch a resize rehash every key into a bigger table.
Heap & Priority Queue
See a min-heap live in two views at once — the array representation and the binary tree — kept in perfect sync. Watch sift-up restore the heap after an insert, sift-down restore it after an extract-min, and build-heap turn an arbitrary array into a valid heap in one O(n) pass.
Huffman Encoding
Build a prefix-free code tree greedily by merging the two lowest-frequency nodes, then read off the optimal variable-length binary codes.
Kadane's Maximum Subarray
Track a running local maximum and a global maximum across one pass to find the contiguous subarray with the largest sum.
KMP String Matching
See how the KMP failure function lets a search skip redundant comparisons, jumping the pattern forward instead of restarting after a mismatch.
0/1 Knapsack
Fill the 0/1 knapsack DP table row by row, deciding to include or exclude each item, then trace back which items maximize value within the weight limit.
Longest Common Subsequence
Watch a 2D dynamic-programming table fill cell-by-cell to find the longest subsequence common to two strings, then trace the path back.
Linked List Pointer Surgery
Watch the next pointers of a singly linked list rewire step by step as you insert, delete, and reverse it — including the prev/curr/next dance of an in-place reversal — and see Floyd’s fast/slow runners converge to detect a cycle. Every arrow flip is animated at your own speed.
Merge Intervals
Sort intervals by start time, then sweep through them collapsing overlaps into a minimal set of disjoint intervals.
Monotonic Stack
Watch an array processed left-to-right while a decreasing stack answers "next greater element" for every position in one O(n) pass. See how one incoming element can pop a whole backlog at once — the key insight behind the pattern.
Prefix Sum Array
Build a prefix-sum array once, then answer any range-sum query in O(1) by subtracting two cumulative totals.
Prim's Minimum Spanning Tree
Grow a minimum spanning tree one edge at a time, always adding the cheapest edge that crosses the cut between visited and unvisited nodes.
Recursion: Call Stack & Recursion Tree
Watch recursive calls pile onto the call stack and unwind — factorial multiplying its answer back up from the base case — then see the SAME recursion as a tree, where naive Fibonacci recomputes the same subproblems over and over. See exactly why that repeated work makes it exponential.
Segment Tree
Build a segment tree over an array and watch how it answers range-sum queries and point updates in O(log n). See the three-case overlap logic that prunes the tree on every query, and how a leaf change propagates its new sum up to the root.
Sliding Window
Watch a window slide across an array as its running sum updates by adding what ENTERS on the right and subtracting what LEAVES on the left. See the fixed-size pattern (a size-k window sliding) and the variable-size pattern (grow right, shrink left until a condition holds), why incremental updates make it O(n) instead of O(n·k), the edge cases (k = n, k = 1, no valid window), then run any array yourself.
Sorting Visualizer
Watch five sorting algorithms — bubble, selection, insertion, merge, and quicksort — move the same bars. See every comparison and swap animated at your own speed, and read live counters that show why O(n²) sorts lose to O(n log n) on the same input.
Topological Sort
Watch Kahn's algorithm peel zero-in-degree nodes from a directed acyclic graph one by one. See in-degree badges count down, the queue fill and drain, and the emitted order build up — then detect what happens when a cycle blocks progress.
Trie (Prefix Tree)
Watch words inserted character by character into a prefix tree, shared prefixes lighting up as reused nodes, end-of-word markers placed, and autocomplete walking branches to collect all words under a prefix.
Two-Pointer Technique
Advance two pointers from opposite ends of a sorted array to find a pair summing to a target in linear time.
Union-Find (Disjoint Set)
Watch a Disjoint Set Union structure evolve as unions merge components and finds compress paths. See union-by-rank keep trees shallow, path compression flatten chains in one pass, and why idempotent unions are free — then try it yourself.
Programming
20Async/Await & the Event Loop
Watch a single-threaded event loop interleave coroutines at each `await`, giving the illusion of parallelism for I/O-bound work.
Call Stack & Frame Objects
Each function call pushes a frame holding its local variables; returning pops it. Watch the stack grow and shrink through recursion.
Closures & the Late-Binding Trap
A closure captures variables by reference and looks them up at call time, not definition time — the source of the classic loop-closure bug.
Context Manager Protocol
A `with` block calls `__enter__` on entry and `__exit__` on exit — even when an exception is raised. See how `__exit__` can suppress errors.
Decorator Mechanics
A decorator is just `func = decorator(func)`. Watch the wrapping desugar, see stacking order, and learn why functools.wraps matters.
Data Model: Dunder Dispatch
Python operators and built-ins are sugar for dunder methods. Watch `a + b` resolve to `__add__`, fall back to `__radd__`, and handle NotImplemented.
Garbage Collection & Reference Counting
CPython frees an object the moment its reference count hits zero. See refcounts rise and fall, and why reference cycles need a separate collector.
Generator Execution Model
Step through a Python generator to see how `yield` suspends the function frame mid-execution and `next()` resumes it from exactly where it paused.
Git Commit Graph
See how Git builds a DAG of commits, how branches and HEAD move, and what really happens during merge, rebase, and reset — visualised step by step as the graph changes.
Hashing & the Equality Contract
Dict keys and set members rely on the rule a == b ⟹ hash(a) == hash(b). Break it and watch lookups silently fail.
The Iterator Protocol
A `for` loop is sugar for repeated `__next__()` calls until `StopIteration`. See how iterables, iterators, and exhaustion really work.
LEGB Scope Resolution
Watch Python resolve a name through Local → Enclosing → Global → Built-in scopes, stopping at the first match.
Mutable Default Arguments
Python evaluates default argument values once at definition time. A mutable default is shared across calls — and silently accumulates state.
Bytecode & the Evaluation Stack
See how Python compiles expressions to bytecode for a stack-based VM, and step through the instructions pushing and popping the evaluation stack.
Python Import Resolution
Watch Python walk sys.path to find a module. Discover why insertion order matters, how __init__.py makes a directory a package, why a local random.py shadows the stdlib, and when src-layout needs pip install -e.
Python Objects & Inheritance
Step through the Method Resolution Order (MRO) as Python walks the C3 chain to find a method. Explore the diamond problem, super() constructor chaining, method overrides, and the Observer design pattern — all animated, no LLM.
Reference vs Value Semantics
Python names are references to objects, not boxes holding values. Watch assignment rebind names while mutation affects every name pointing at the same object.
Regular Expressions: NFA Matching
Compile a small regex into an NFA and watch active states advance as each input character is consumed — including catastrophic backtracking.
Static Code Analysis
Watch a linter and type checker read code WITHOUT running it — catching unused imports, type mismatches, and subtle bugs like the "100"×5 string-repetition trap. See what auto-fixes are safe and why some issues need human judgment.
TDD: Red → Green
Watch tests flip from red to green as you fix a real function under test. See exactly which assertion failed and why — including a boundary bug that only one edge-case test catches.