Vector Strike: Semantic Search Database Defender A developer built Vector Strike, a retro arcade game that visualizes how vector databases like Pinecone, Milvus, Qdrant, and pgvector perform semantic search. The game lets players configure similarity thresholds, embedding dimensions, and indexing methods (flat scan vs. HNSW) to see how these parameters affect search accuracy and performance. It maps concepts like cosine similarity, dimension collapse, and proximity graph traversal to interactive gameplay. Have you ever wondered how vector databases like Pinecone, Milvus, Qdrant, or pgvector search through billions of high-dimensional documents in milliseconds? Under the hood, they map semantic concepts into dense numerical vectors, calculate multidimensional cosine similarity angles, and traverse proximity graphs to locate nearest neighbors without scanning the entire database. To help you visualize how vector databases and embeddings actually operate, I built a retro-vector arcade game: ๐Ÿ›ฐ๏ธ Vector Strike: Database Defender Play in Fullscreen Mode if the embed sizing is tight https://vector-strike-90043718455.us-central1.run.app ๐Ÿ› ๏ธ Choose Your Database Optimizations Your mission as a Vector Database VDB administrator is to configure your query settings and index structures to defend your index nodes: - ๐Ÿ“ Similarity Threshold ฯ„ : Tweak the match threshold slider. High thresholds require near-identical semantic matches but protect your index, whereas lower thresholds act like a splash-damage laser but risk matching incorrect clusters. - ๐Ÿช Embedding Dimensions 2D $\rightarrow$ 8D $\rightarrow$ 32D : Higher dimensions isolate categories and guarantee precise hits. Lowering dimensions collapses the projection space, causing spatial overlap that results in false deflections and friendly-fire query failures. - โšก Proximity Indexing Flat Scan $\rightarrow$ HNSW Graph : - Flat Scan: Runs a brute-force linear search over all targets. It causes computation latency spikes as more query objects arrive. - HNSW Hierarchical Navigable Small World : Dynamically builds proximity links between adjacent node targets. The turret traverses vectors along the nearest-neighbor graph, snap-locking onto targets with zero lookup latency. ๐Ÿงฌ Playable ML Concepts Explained Here is how the arcade mechanics map to production vector databases: 1. ๐Ÿ”€ Multidimensional Projections Dimension collapse - In-Game: You can toggle between 2D, 8D, and 32D space. In 32D space, the categories are cleanly separated. In 2D space, the database collapses, and you'll find space rockets getting deflected by vehicle lasers because they overlap on the collapsed axes. ๐Ÿ’พ The Real-World Counterpart Embeddings map textual semantics into high-dimensional space e.g., 1536 dimensions for OpenAI's text-embedding-3-small . Reducing dimensionality via PCA or projection squeezes distinct concepts onto similar planes. โš ๏ธ How it affects VDBs When dimensions collapse, semantic resolution is lost. A vector database will begin returning false matches because unrelated words map to nearby coordinates on the truncated plane. 2. ๐Ÿ›ฐ๏ธ Cosine Similarity Thresholds The Match Laser - In-Game: When you fire a category query like FOOD or SPACE , the laser calculates the similarity value against targets it intersects. If the dot product similarity is below $\tau$, the laser deflects. ๐Ÿ—œ๏ธ The Real-World Counterpart Cosine similarity measures the cosine of the angle between two multi-dimensional vectors. It is a scale-invariant metric commonly used to check how close two documents are in embedding space. โš ๏ธ How it affects VDBs Production search pipelines filter results based on a minimum similarity score threshold. Setting the threshold too high returns zero results, while setting it too low returns irrelevant noise. 3. ๐Ÿ•ธ๏ธ HNSW Graph Traversals Nearest-Neighbor Search - In-Game: In HNSW mode, you see thin green link lines draw between targets. Firing the laser instantly traces a route along the lines, hopping from node to node to hit the target instantly rather than flying through the screen linearly. ๐Ÿ”‹ The Real-World Counterpart HNSW Hierarchical Navigable Small World structures vectors into multi-layer proximity graphs. Instead of comparing the query vector against every single vector in the database, the search navigates the graph towards the closest neighbors. ๐Ÿš€ How it affects VDBs By avoiding exhaustive linear scanning, HNSW slashes search latency from $O N $ to logarithmic time, allowing databases to query millions of records in microseconds. ๐Ÿ› ๏ธ The Under-the-Hood Engineering Journey Creating a vector-math arcade game presented some unique engineering tasks: 1. Simulating Dimensionality Collapse in JS To let players experience "Dimensional Collapse" in real-time, we precompute a 32-dimensional coordinate matrix for all words. - The Solution: When the player changes the dimension setting, the engine dynamically slices the vector coordinates vec.slice 0, activeDim and normalizes the sliced vectors before running the dot product: 2. High-Performance HNSW Traversal Visualization To visualize greedy graph routing on canvas, we calculate proximity paths dynamically using a distance heap. When HNSW mode is active, the laser tracks the step-by-step hops along target coordinates, firing audio triggers at each step. Click to see the Greedy HNSW Traversal path generation ๐Ÿ’ฌ Let's Discuss: - What is your high score defending the Vector Database? - Did you notice how 2D mode causes spaceships and rockets to deflect matching vectors due to axis collapse? - Which index type did you find more visually pleasing: Flat or HNSW traversal paths? Asteroids inspired game to teach players about Graph DBs for LLMs ๐Ÿ›ฐ๏ธ Vector Strike: Semantic Search Database Defender An educational retro-oscilloscope vector graphics game that maps database defense mechanics directly to vector embeddings, cosine similarity thresholds, and vector graph index traversal Flat Scan vs. HNSW Graph Routing . ๐Ÿ‘‰ Play the Live Demo here https://vector-strike-90043718455.us-central1.run.app/ ๐ŸŽฎ The Concept In Vector Strike , you play as a Vector Database administrator defending your vector database partitions against incoming query concepts represented by descending labeled target clusters . To eliminate targets, you press keys 1 - 5 to instantly fire the matching category laser and match target embeddings using Cosine Similarity : - Embedding Accuracy: Toggle dimensionality 2D, 8D, 32D . Lower dimensions 2D collapse projection spaces and travel super fast , but cause spatial collisions and false deflections. Higher dimensions 32D travel slower , but accurately filter complex overlap concepts. - Match Tolerance ฯ„ : Adjust your matching threshold slider. Tighten it for score multipliers on exact matches, or loosenโ€ฆ Disclaimer: AI was used throughout this project, it is just fitting that it would co-author with me, so special thanks to the Foundry for its tireless hours toiling away and Gemini for producing the cover image.