Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] KNN Query using FAISS score is incorrect #2592

Open
NitinAggarwal1 opened this issue Mar 11, 2025 · 2 comments
Open

[BUG] KNN Query using FAISS score is incorrect #2592

NitinAggarwal1 opened this issue Mar 11, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@NitinAggarwal1
Copy link

What is the bug?
We have used the KNN plugin in open search to try doing the vector search .

Details of the index are as follows :

  • Index Mapping : "description_dense_vector": {
    "type": "knn_vector",
    "dimension": 768,
    "method": {
    "engine": "faiss",
    "space_type": "innerproduct",
    "name": "hnsw",
    "parameters": {}
    }
    }

  • Query we use to get result set :
    GET ml-products/_search
    {
    "track_total_hits": true,
    "profile": "true",
    "_source": {
    "includes": [
    "product_id",
    "description",
    "p_product_catalog_search",
    "Brand_s",
    "multifield_text"
    ]
    },
    "size": 15,
    "query": {
    "neural": {
    "description_dense_vector": {
    "query_text": "mini kobalt tool kt",
    "model_id": "b_wGhJUB8vZIfNtyHHkc",
    "min_score": "0.1"
    }
    }
    }
    }

Issue 1 : For min_score = 0.8 we are getting 60 results , while for min_score = 0.9 we are getting 3356 results .
Issue 2 : Issue 2 : For max_distance = 0.8 we are getting 3 results , while for max_distance = 0.9 we are getting 0 results
It is just opposite the normal behaviour where min_score if reduced the recall should increase.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

What is the expected behavior?
A clear and concise description of what you expected to happen.

What is your host/environment?

  • OS: Container-Optimized OS with containerd (cos_containerd)
  • Version : 2.19
  • Plugins : KNN Native Plugin

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
We see the faiss

@NitinAggarwal1 NitinAggarwal1 added bug Something isn't working untriaged labels Mar 11, 2025
@jmazanec15
Copy link
Member

Thanks @NitinAggarwal1 . That seems backwards. Let me see if I can repro

@jmazanec15
Copy link
Member

@NitinAggarwal1 just to confirm, the scores returned in the results are always what you expect, correct? Its more a matter of the number of matches? I imagine this has to do with radial search implementation in faiss. Did you try at all with Lucene engine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants