Skip to content

fix(pinecone): honor default_empty_query_vector for queries without an embedding - #23599

Open
anikeaty08 wants to merge 1 commit into
run-llama:mainfrom
anikeaty08:fix/pinecone-default-empty-query-vector
Open

anikeaty08 wants to merge 1 commit into
run-llama:mainfrom
anikeaty08:fix/pinecone-default-empty-query-vector

Conversation

@anikeaty08

Copy link
Copy Markdown

Description

PineconeVectorStore accepted and documented default_empty_query_vector ("used as the query vector if the query is empty") but never stored or used it. In query(), the code also built a zero-vector fallback ("pinecone requires a query embedding, so default to 0s") and then overwrote it with query.query_embedding in DEFAULT/HYBRID mode. For a metadata-only query that sent vector=None to Pinecone, and raised TypeError when alpha was set.

Changes:

  • keep default_empty_query_vector in a private attribute (not a new pydantic field, so serialization is unchanged);
  • when the query has no embedding, use the default vector if configured, otherwise a zero vector of the index dimension (the previously intended fallback);
  • apply alpha scaling 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?

  • Yes
  • No

Version Bump?

  • Yes (0.9.0 -> 0.9.1)
  • No

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • I added new unit tests to cover this change

tests/test_default_empty_query_vector.py (mocked index, no Pinecone account needed) covers: the default vector in DEFAULT and HYBRID mode, an explicit embedding taking precedence, alpha scaling the default, the zero-vector fallback sized from describe_index_stats(), from_params forwarding 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:

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran ruff check and ruff format on the changed files

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.

…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.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Successfully merging this pull request may close these issues.

[Bug]: PineconeVectorStore ignores default_empty_query_vector and sends vector=None for queries without an embedding

2 participants