A More Realistic Example
There aren't just three dimensions
It's easy for us as humans to understand things that happen in two or three dimensions, but vectors in the real world can contain many, many dimensions. I was intentionally misleading us in the beginning. What's interesting is no matter how many dimensions or "traits" we choose, the math expands out to fit them. For example, the dot product for a three dimensional vector may be $\mathbf a \cdot \mathbf b = a_1 b_1 + a_2 b_2 + a_3 b_3$, but it actually expands out to n dimensions: $$a_1 b_1 + a_2 b_2 + a_3 b_3 + \cdots + a_{n-1} b_{n-1} + a_n b_n$$ neat, right?
A larger example
Using the exact same math from our simple video game vector example, we are going to scale this to 50 dimensions. Select a word from the list below and you'll get back the nearest neighbors using our similarity function!
Try it
Pick a word and see which other words are its nearest neighbors.
Here is an example of what "king" looks like with our example embeddings:
"king" => [0.50451, 0.68607, -0.59517, -0.022801, 0.60046, -0.13498, -0.08813, 0.47377, -0.61798, -0.31012, -0.076666, 1.493, -0.034189, -0.98173, 0.68229, 0.81722, -0.51874, -0.31503, -0.55809, 0.66421, 0.1961, -0.13495, -0.11476, -0.30344, 0.41177, -2.223, -1.0756, -1.0783, -0.34354, 0.33505, 1.9927, -0.04234, -0.64319, 0.71125, 0.49159, 0.16754, 0.34344, -0.25663, -0.8523, 0.1661, 0.40102, 1.1685, -1.0137, -0.21585, -0.15155, 0.78321, -0.91241, -1.6106, -0.64426, -0.51042]
And that's still nowhere close to what an actual vector would look like!
All the training and inference that AI models use nowadays is exactly what we just walked through in these few pages, just an enormous amount of dot products across more data than we can imagine. No wonder GPU prices are so high.
That's all I wanted to share, thanks for reading if you made it this far, or if you didn't. Please use the suggest a topic button up above for anything. There is no topic too small.
You also got your first taste of linear algebra. See, it isn't that bad.