← All Resources

Embedding Explorer

Explore how AI represents meaning as geometry. Search for words to see what's nearby, try analogies to discover that you can do arithmetic on meaning, and watch the scatter plot shift perspective as you explore.

Log in to use this tool.

Pedagogical Goals

  • Make the abstract concept of word embeddings concrete and explorable
  • Show that AI represents meaning as points in space, where distance reflects semantic similarity
  • Let students discover that relationships between words have geometric structure (king - man + woman = queen)
  • Demonstrate that 2D projections of high-dimensional space are lossy by reprojecting around different words
  • Connect embeddings to students' experience with LLMs: the same vectors that make words 'nearby' are what let chatbots understand context

How It Works

The explorer uses pre-computed 1,536-dimensional word embeddings from Azure OpenAI. A vocabulary of ~300 words across categories (royalty, emotions, animals, professions, etc.) is pre-embedded and stored as a JSON cache. When a student searches for a word, the API computes cosine similarity against all cached vectors and returns the nearest neighbors. Analogies use vector arithmetic: A - B + C finds the word closest to the result. The scatter plot uses PCA to project the high-dimensional space to 2D, and shifts its center to the selected word so students can see the neighborhood around any word they choose.

How It Was Built

The embedding cache is pre-seeded with a curated vocabulary using a build script. The scatter plot renders on an HTML canvas with animated transitions between projections. The API endpoints for similarity search, analogy computation, and projection are implemented in the Hono API server. The frontend is a single React client component with Canvas rendering, debounced search, and SWR-based data fetching. Built iteratively with Claude Code, with the scatter plot projection going through several algorithm iterations to find the right balance between mathematical accuracy and visual clarity.