feat(python): refresh VoyageAI models and contextualized embedding path - #1
feat(python): refresh VoyageAI models and contextualized embedding path#1fzowl wants to merge 2 commits into
Conversation
Refresh the VoyageAI integration against the current model catalog and fix the contextualized embedding design. Models: - add voyage-code-4, voyage-4-nano, voyage-3-large, voyage-code-3 text models - add voyage-context-4 alongside voyage-context-3 (contextualized) - update ndims, token-limit table, docstrings and docs accordingly Contextualized embeddings (voyage-context-*): - embed each input string as its own independent document by sending the batch as a flat list[str] with enable_auto_chunking=True and chunk_size=32000 on the document side, so every input resolves to exactly one chunk and one embedding. Inputs are not contextualized against each other, since generic embed_many callers pass unrelated texts. - the query path omits auto-chunking (the API rejects it for query inputs). Token-aware batching: - retained/covered by unit tests: split at the token boundary, a single oversized text still goes through alone, item-count cap respected. Tests cover both the document and query contextualized paths and the batching logic.
|
VERDICT:CHANGES_NEEDED Reviewing the VoyageAI refresh (commit Core change — goodThe actual source change (5 files) is correct, well-tested, and cleanly documented:
Commit hygiene: clean — single focused commit, no Blocking / must-fix
Minor
Core code is approvable; fix the base-branch scope (#1) and drop the unrelated formatting hunks (lancedb#2) before merge. |
- Revert unrelated assert-reflow formatting churn in test_embeddings_slow.py (test_colpali / test_colpali_models / voyage embedding assert) so the diff carries only VoyageAI changes and passes ruff format --check. - Apply project ruff formatting to test_voyageai_embeddings.py assert messages. - Document that a contextualized input longer than the 32000-token per-chunk ceiling is split server-side and only the first chunk embedding is kept.
|
Addressed the review feedback in Blocking
Minor
Catalog audit — current docs catalog is fully covered: text (voyage-4-large/4/4-lite/4-nano/code-4 + domain + legacy), contextualized (voyage-context-4/3), multimodal (voyage-multimodal-3.5/3), rerankers (rerank-2.5/2.5-lite). Nothing missing. Validation — |
|
VERDICT:APPROVED Reviewed the full diff, commit messages, and the surrounding Correctness
Fit / conventionsMatches existing module style, docstrings, and the Breaking-change riskLow. New models are additive; doc edits are cosmetic. The one real behavior change is contextualized document embedding semantics — but the previous behavior was incorrect for the generic caller, and the new behavior + the data-loss caveat (input >32000 tokens keeps only the first chunk) is clearly documented in the docstring. Acceptable. TestsGood coverage: no-network unit tests for dims, contextual classification, document vs. query contextual paths (asserting exact kwargs), and all three batching edge cases; slow integration extended to Commit hygieneClean — no Minor (non-blocking)
Neither warrants blocking. Approving. |
|
Upstream PR opened: lancedb#3955 This PR stays open as the working channel until the upstream PR is resolved. |
What
Refresh the VoyageAI embedding integration against the current Voyage model catalog and correct the contextualized embedding path.
Models
voyage-code-4,voyage-4-nano,voyage-3-large,voyage-code-3.voyage-context-4alongsidevoyage-context-3.ndims, the per-request token-limit table, docstrings, and docs to match.Contextualized embeddings (
voyage-context-*)Each input string is embedded as its own independent document. On the document side the batch is sent as a flat
list[str]withenable_auto_chunking=Trueandchunk_size=32000, so every input resolves to exactly one chunk and one embedding — deterministic per-input vectors and trivial result collection.Inputs are intentionally not contextualized against one another: generic
embed_manycallers pass unrelated texts, so cross-input contextualization would be wrong. Previously the batch was sent as a single document's chunks (inputs=[batch]), which mixed unrelated inputs; that is fixed here.The query/retrieval path omits
enable_auto_chunking/chunk_size, because the API rejects auto-chunking wheninput_typeisquery.Token-aware batching
The plain-text path builds batches by estimated token count against the per-model token limit (not only a fixed item count).
Why
Keep the exposed models current, make contextualized embeddings correct and deterministic for generic callers, and respect per-request token budgets.
Tests
list[str]+ auto-chunking +chunk_size=32000, one embedding per input) and the query path (asserts auto-chunking is not sent).voyage-context-4,voyage-code-4,voyage-3-large, and to exercise the contextual query/search path.All non-slow unit tests pass locally (
pytest python/tests/test_voyageai_embeddings.py). Ruff check/format clean.