You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I regularly need to come back and check exact behavior/definitions of metrics, notably IP, cos, L2 (which are kindof the same, but also not quite). There's a couple of other issues (#13, #258) where some details were unclear to others too.
A tiny table summarizing how inputs should be normalized, how they are normalized internally and the formula for the Match.distance you get back (just dot product? normalized then dot? 1 - dot?) would be super handy.
Thank you :)
Can you contribute to the implementation?
I can contribute
Is your feature request specific to a certain interface?
Thanks for suggestion, @tnibler! I'll try to make the docs of v3 clearer about the metrics, but feel free to suggest docs patches in the meantime - I'm ready to merge 😉
Hi, I'd like to take this. I have implemented HNSW myself, and so I know the relationships between cosine, L2 and inner product. I checked the README file and the docs/ folder, and I couldn't find a summary of the metrics. My idea is to read how each metric is calculated in the code, and make a small table, with the expected input normalization, what happens internally, and what is the formula of Match.distance. Is a patch to the docs still welcome, and do you prefer a new page in docs/ or a section in the README?
Thanks. I’ll add the metrics table to an existing docs page and use the supported $$ notation for the formulas. I’ll verify them against the implementation first, then open a PR linking this issue.
Activity
ashvardanian commentedon Oct 26, 2025
Thanks for suggestion, @tnibler! I'll try to make the docs of v3 clearer about the metrics, but feel free to suggest docs patches in the meantime - I'm ready to merge 😉
DiscoMenon commentedon Oct 19, 2026
Hi, I'd like to take this. I have implemented HNSW myself, and so I know the relationships between cosine, L2 and inner product. I checked the README file and the docs/ folder, and I couldn't find a summary of the metrics. My idea is to read how each metric is calculated in the code, and make a small table, with the expected input normalization, what happens internally, and what is the formula of Match.distance. Is a patch to the docs still welcome, and do you prefer a new page in docs/ or a section in the README?
ashvardanian commentedon Oct 19, 2026
A patch on existing pages is better, especially if it's not too intrusive and uses supported $$ math notation. Thanks 🤗
DiscoMenon commentedon Oct 19, 2026
Thanks. I’ll add the metrics table to an existing docs page and use the supported $$ notation for the formulas. I’ll verify them against the implementation first, then open a PR linking this issue.
Docs: Define the distances built-in metrics return
Docs: Define the distances built-in metrics return