Searching for points near given point in a multidimensional space
If you don't want the exact nearest neighbour but would be satisfied with finding points that are not too far off, then you should take a look at Approximate nearest neighbour search.

Wikipedia suggests the following approaches:


Locality-sensitive hashing
Best bin first
Balanced box-decomposition tree


Depending on the distribution of your data, not all dimensions may be equally relevant (maybe all points are bunched together along some line or hyperplane) and you could also use dimensionality reduction techniques, the main one being PCA (or maybe autoencoders nowadays).

Of course you can combine both, and that is also what I would recommend you to do in most cases.

If you want the exact nearest neighbour, unfortunately research suggests that this is very hard in high dimensions (see curse of dimensionality), and with a 512 dimensional space "clever" methods can very well end up being worse in practice than simply searching through all points.