PART 1 · VISUAL CONCEPT 01

Tokens & Embeddings

How does raw text turn into numbers an LLM can actually do geometry on?

Interactive Lab 01 · Byte-Pair Encoding (BPE)

Watch Characters Merge Into Subword Tokens

Type anything or pick a preset, then drag the step slider to see BPE merge frequent pairs into token IDs.

Step 0 / 0
Live BPE Merge Sandbox
Chars Merged
Characters 24
Current Tokens 24
Compression (chars/tok) 1.00x
Active Merge Rule Step 0: Raw characters
Interactive Lab 02 · Embedding Matrix & Vector Geometry

Inspect Matrix E[V × d] & Drag the Live Probe Vector

Click any two words to measure their angle θ, test vector arithmetic, or drag the Amber probe dot anywhere on the plane.

cos(θ) = 0.94
Embedding Table E[V × d]
6-Dim Slice
E["king"] (#4920) -1.0 → +1.0
E["queen"] (#7104) 6 dims
cos(θ) = 0.94 Angle θ = 19.9°
High Similarity
2D Semantic Vector Space (Drag Amber Probe)
ROYALTY TECH / AI FOOD PROBE
Probe Nearest 3:
Mental Model · 20 Lines of Pure Python

The Entire Pipeline Without Magic

tokens_and_embeddings.py

      

Why LLMs Miss Letters in "strawberry"

Tokenizers hand the model subword IDs like #496 (straw) + #19772 (berry)—never raw characters. Counting letters requires mentally spelling out opaque IDs.

Leading Spaces Change the Token ID

"apple" and "·apple" map to completely different rows in matrix E. That is why trailing spaces in prompts can subtly shift generation probabilities.

Meaning = Angle, Not Length

Cosine similarity normalizes out vector magnitude and compares direction θ—the exact geometry powering every semantic search and RAG vector database.