# Accuracy of the scores and rankings in ANN output

**URL:** <https://discuss.elastic.co/t/accuracy-of-the-scores-and-rankings-in-ann-output/336009>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [June 14, 2023, 6:34pm UTC](https://discuss.elastic.co/t/accuracy-of-the-scores-and-rankings-in-ann-output/336009 "2023-06-14T18:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajivhs](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rajivhs](https://discuss.elastic.co/u/rajivhs)\
**Post date:** [June 14, 2023, 6:34pm UTC](https://discuss.elastic.co/t/accuracy-of-the-scores-and-rankings-in-ann-output/336009/1 "2023-06-14T18:34:26Z")

</div>

[As per the ES8 documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html#approximate-knn), when running an ANN query with k=100, Elastic will:

1. Find the 100 closest neighbors, using the HNSW approximation
2. Calculate each result's similarity and rank them using the specified similarity algorithm (eg, `dot_product`)

I understand that by design, ANN uses approximations in step 1. So the 100 results aren't guaranteed to be the 100 nearest neighbors. The `recall` metric [in the benchmarks](https://elasticsearch-benchmarks.elastic.co/#tracks/dense_vector/nightly/default/90d) reflect the percentage of the nearest neighbors that are returned by ANN, and this is unlikely to be 100%.

However, are approximations used in step 2 as well? Within a set of 100 results, are they guaranteed to have accurate rankings and similarity scores (eg, using precise `dot_product` calculations)?

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [June 14, 2023, 7:37pm UTC](https://discuss.elastic.co/t/accuracy-of-the-scores-and-rankings-in-ann-output/336009/2 "2023-06-14T19:37:26Z")

</div>

Hey @rajivhs ,

The `dot_product` calculation is not approximate. As vectors are stored, the graph is built with the actual `dot_product` calculation and when the graph is explored, we calculate the actual `dot_product` between vectors.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 12, 2023, 7:38pm UTC](https://discuss.elastic.co/t/accuracy-of-the-scores-and-rankings-in-ann-output/336009/3 "2023-07-12T19:38:10Z")

</div>

Closed on July 12, 2023, 7:38pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
