fix: preserve Voyage asymmetric embedding semantics - #3515
Open
Tosko4 wants to merge 1 commit into
Open
Conversation
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.
Summary
input_type="document"when initializing Voyage embeddings and embedding stored contentinput_type="query"when embedding recall queriesencode()and every non-Voyage LiteLLM providerWhy
Hindsight already exposes Voyage models through
litellm-sdk, but the adapter currently omits Voyage's asymmetric retrievalinput_type.Voyage's retrieval contract embeds corpus content as
documentand search text asquery. Passing those roles through Hindsight keeps stored vectors and recall queries in the intended retrieval spaces instead of relying on the provider's general-purpose default.Validation
uv run python -m pytest -n 0 tests/test_litellm_sdk_embeddings.py -q(29 passed, 3 skipped)uv run ruff check hindsight_api/engine/embeddings.py tests/test_litellm_sdk_embeddings.pyuv run ruff format --check hindsight_api/engine/embeddings.py tests/test_litellm_sdk_embeddings.py./scripts/hooks/lint.shRisk and impact
The behavioral change is restricted to LiteLLM model names beginning with
voyage/. Other providers continue to omitinput_type, and directencode()callers retain provider-default behavior.Deployments that already indexed content with a Voyage model while
input_typewas omitted should rebuild those stored embeddings when adopting this change, so document and query vectors consistently use the asymmetric retrieval contract.Scope
Two files only:
hindsight-api-slim/hindsight_api/engine/embeddings.pyhindsight-api-slim/tests/test_litellm_sdk_embeddings.pyNo schema, configuration, dependency, generated-client, or public API changes.
Rollout
No database migration is included. New Voyage embeddings use the correct role automatically after upgrade. Existing Voyage-backed indexes should be re-embedded as noted above.
Reviewer focus
Please verify that:
documentqueryencode()and non-Voyage providers stay unchangedPR #3090 also touches these two files for retry and timeout behavior. It is not a duplicate, but whichever change lands second may need a focused rebase.