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

semantic score not generated when sending a query using vectorstore.similarity_search method #962

Closed
AhmedMostafa08 opened this issue May 21, 2024 · 2 comments

Comments

@AhmedMostafa08
Copy link

Description
when trying to send a query using vectorstore.similarity_search i get a KeyError: '_semanticScore' as the result doesn't have a semantic score generated
semantic_score = result["_semanticScore"]

Expected behavior
to get a response

Current behavior
the mentioned error happens

here's the code for how I created the vector index :
client=meilisearch.Client('url','api key ')
embeddings = OpenAIEmbeddings()
vectorstore = Meilisearch(
embedding=embeddings,
client=client,
embedders=embedders,
index_name='vector_index')
and here's the embedding and embedder code
embeddings = OpenAIEmbeddings()
embedders = {
"default": {
"source": "userProvided",
"dimensions": 1536,
}
}
embedder_name = "default"

also note that the vector store is created and documents are added just fine
and here's an example for the indexed document
Document(page_content="name: MA in Sport Management\ncities: ['Southampton']\ncountries: ['United Kingdom']\ncontinents: ['Europe']\nei: Solent University\nmajors: ['Sports Management']\nminors: ['Sport and Fitness Management']\ndegree_level: Masters\nid: 470849\nis_featured: False\nint_fee_currency: USD\ntuition_fee_type: absolute\nslug: ma-in-sport-management\nboosted: 299995\nphoto: https://active-storage-assets.s3.eu-west-1.amazonaws.com/3t4naBgJWYSZqr8DZrg4GkAY\npartnership_boost: 49926\npartnership_type: Recruitment Solution\neasy_apply: True\nprogram_ranking: None\nei_global_ranking: 74\nei_country_ranking: 93\nleads_subscription: 0\nvisits_subscription: 0\ntotal_tuition_fee: 18352.0\nprogram_level_id: 71\nparent_degree_level_id: 2770\ncity_ids: [30580]\ncountry_ids: [75]\nmajor_ids: [2846]\nint_tuition_fees: 18352.0\ntuition_fees: 10,000 - 20,000\nduration_in_days: 365\napplication_deadlines: [1688774400]\nei_id: 36943\npersuasion_text: None\nintakes: ['Winter 2023', 'Fall 2023', 'Winter 2024']\nduration: Less than 2 years\nparent_degree_level: Masters\nformat: Full time\nstudy_type: ['On campus']\ndiscipline: {'lvl0': ['Business & Management'], 'lvl1': ['Business & Management > Sports Management']}\npage_content: name: MA in Sport Management\ncities: ['Southampton']\ncountries: ['United Kingdom']\ncontinents: ['Europe']\nei: Solent University\nmajors: ['Sports Management']\nminors: ['Sport and Fitness Management']\ndegree_level: Masters\nid: 470849\nis_featured: False\nint_fee_currency: USD\ntuition_fee_type: absolute\nslug: ma-in-sport-management\nboosted: 299995\nphoto: https://active-storage-assets.s3.eu-west-1.amazonaws.com/3t4naBgJWYSZqr8DZrg4GkAY\npartnership_boost: 49926\npartnership_type: Recruitment Solution\neasy_apply: True\nprogram_ranking: None\nei_global_ranking: 74\nei_country_ranking: 93\nleads_subscription: 0\nvisits_subscription: 0\ntotal_tuition_fee: 18352.0\nprogram_level_id: 71\nparent_degree_level_id: 2770\ncity_ids: [30580]\ncountry_ids: [75]\nmajor_ids: [2846]\nint_tuition_fees: 18352.0\ntuition_fees: 10,000 - 20,000\nduration_in_days: 365\napplication_deadlines: [1688774400]\nei_id: 36943\npersuasion_text: None\nintakes: ['Winter 2023', 'Fall 2023', 'Winter 2024']\nduration: Less than 2 years\nparent_degree_level: Masters\nformat: Full time\nstudy_type: ['On campus']\ndiscipline: {'lvl0': ['Business & Management'], 'lvl1': ['Business & Management > Sports Management']}", metadata={'source': 'https://www.educatly.com/program/470849')

  • Meilisearch version: 1.8.0
@sanders41
Copy link
Collaborator

sanders41 commented May 21, 2024

_semanticScore was removed from the results in 1.8.0. See the Hybrid Search section of the release notes https://github.com/meilisearch/meilisearch/releases/tag/v1.8.0.

@sanders41
Copy link
Collaborator

I'm going to go ahead and close this, but if there is somthing I'm missing about the issue feel free to reopen and further explain.

meili-bors bot added a commit that referenced this issue May 22, 2024
963: Fix document and vector fixture r=curquiza a=sanders41

# Pull Request

In looking at #962 I noticed that the `index_with_documents_and_vectors` fixture was not working as expected and therefore the `test_vector_search` test was not testing what was expected. Because only one document had vectors the document addition task was failing and no documents were added to the index. So `test_vector_search` was returning no hits because there were no documents in the index. This updates the fixutre to add vectors to all documents, and updates the test to pass with the new results.

## Related issue
Fixes #<issue_number>

## What does this PR do?
- Fixes the `test_vector_search` test.

## PR checklist
Please check if your PR fulfills the following requirements:
- [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [ ] Have you read the contributing guidelines?
- [ ] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Paul Sanders <paul@paulsanders.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants