Search code examples
distancemilvus

A question about Milvus distance calculation


I have a question about distance calculation in Milvus. In Milvus, I use the L2 distance calculation to query a vector for top1 and Milvus returns a distance of 9.340524. whereas the distance I get between the query vector and the return using the L2 formula is 2.156227. Why is the formula for distance calculated differently from the result returned by Milvus?


Solution

  • The L2 distance is returned by FAISS, it is a square value. For example, vector1=[1,2], vector2=[0, 4], the returned L2 distance is 5.

    You got L2 distance 9.340524, but it is not equal to 2.156227*2.156227, I think there must be some mistakes. You can do the steps to verify:

    1. create a new collection
    2. insert the vector that you got from the previous query(the top1 vector)
    3. query again