Repository navigation
fix(pinecone): honor default_empty_query_vector for queries without an embedding - #23599
Open
anikeaty08 wants to merge 1 commit into
Open
anikeaty08 wants to merge 1 commit into
anikeaty08 wants to merge 1 commit into
Conversation
…n embedding PineconeVectorStore accepted and documented default_empty_query_vector but never stored it. query() also computed a zero-vector fallback and then overwrote it with query.query_embedding, so a metadata-only query sent vector=None to Pinecone (or raised TypeError when alpha was set). Keep the default vector, use it when the query has no embedding, and otherwise fall back to a zero vector of the index dimension, as the existing comment intended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PineconeVectorStoreaccepted and documenteddefault_empty_query_vector("used as the query vector if the query is empty") but never stored or used it. Inquery(), the code also built a zero-vector fallback ("pinecone requires a query embedding, so default to 0s") and then overwrote it withquery.query_embeddinginDEFAULT/HYBRIDmode. For a metadata-only query that sentvector=Noneto Pinecone, and raisedTypeErrorwhenalphawas set.Changes:
default_empty_query_vectorin a private attribute (not a new pydantic field, so serialization is unchanged);alphascaling to whichever vector is used.Behavior with an embedding on the query is unchanged, and an explicit query embedding always wins over the default.
Fixes #23598
New Package?
Version Bump?
Type of Change
How Has This Been Tested?
tests/test_default_empty_query_vector.py(mocked index, no Pinecone account needed) covers: the default vector inDEFAULTandHYBRIDmode, an explicit embedding taking precedence,alphascaling the default, the zero-vector fallback sized fromdescribe_index_stats(),from_paramsforwarding the option, and the default being optional. 7 of the 8 tests fail on the previous code. The package's existing suite is unchanged (14 passed, 2 skipped, the latter needing a live index).Suggested Checklist:
AI disclosure: an AI assistant helped find this by scanning for constructor arguments that are never used, and helped draft the change. I reproduced the behavior, reviewed the diff, and ran the tests myself.