What is a Vector?
- Is a fruit: Yes (1.0)
- Color: Orange (0.8)
- Shape: Spherical (0.9)
- Taste: Citrus (0.7)
- Is a fruit: No (0.0)
- Color: Orange (0.81)
- Shape: N/A (0.0)
- Taste: N/A (0.0)
Measuring Similarity
Why is Vector Representation Useful?
- Training: A model is trained on a massive dataset (like the entire internet).
- Context: It learns that "Orange" and "Juice" often appear together, while "Orange" and "Telecom" appear in different contexts.
- Encoding: The model learns to automatically assign numbers (embeddings) to data so that related concepts are naturally pushed closer together in a mathematical "space."

What is HNSW?
In a world, compute is cheap and abundant, brute force can work (quantum computing can't solve this, so we are talking about a alien technology). Coming back to our world, we need a better way to search through large number of embeddings.In the real world, vectors don't just have 4 dimensions; they often have 768 or 1,536. Calculating the distance between a query and every single stored vector (Brute Force) is incredibly slow. We need a shortcut. The idea is to connect similar vectors ahead of time, creating a graph. This is called a Navigable Small World (NSW). Think of it like a social network: you might not know a stranger, but you know someone who knows someone who knows them. When searching, we start near a good match, explore nearby similar items, and keep track of the best ones we’ve seen so far in case there’s something even better slightly farther away. We stop once exploring doesn’t improve the results and return the best few matches.

- The Top Floor (Express): Has only a few windows. You can look out and see entire cities. You jump from City A to City B in one step.
- The Middle Floors: Have more windows. You can jump from neighborhood to neighborhood.
- The Bottom Floor (Street Level): Every single house is visible. You walk door-to-door to find the exact address.

- Start at the top: Find the general "neighborhood" of your search.
- Drop down a layer: Refine the search within that neighborhood.
- Repeat: Keep dropping layers until you reach the bottom.
- Final Search: Perform a tiny, local search to find the absolute best matches.