Skip to content

feat(python): refresh Voyage AI by MongoDB models and contextualized embeddings - #4

Open
fzowl wants to merge 2 commits into
mainfrom
chore/update-voyage-integration
Open

fzowl wants to merge 2 commits into
mainfrom
chore/update-voyage-integration

Conversation

@fzowl

@fzowl fzowl commented Nov 15, 2026

Copy link
Copy Markdown
Owner

What

The Voyage AI by MongoDB embedding function was missing current models, sent contextualized documents the way the API no longer expects, and only knew a few reranker names in its docs.

This brings it up to date:

  • New models: voyage-code-4, voyage-context-4, voyage-3-large, voyage-code-3, with native dimensions and Matryoshka output_dimension (256/512/1024/2048) for the models that support it. output_dimension is sent only when set, and a ValueError is raised for models that do not support it instead of ignoring it.
  • Token-aware batching now uses the documented per-request token limit of each model (plus the 1000-input cap). voyage-code-4 has no documented token limit, so it is split by input count only. A model without an entry raises instead of falling back to a default.
  • voyage-context-* documents are sent as a flat list[str] with enable_auto_chunking=True and chunk_size=32000, so each input is its own document. Queries are still sent without auto-chunking, which the API rejects for queries. If the API splits an input into several chunks, a non-retried ValueError is raised instead of silently keeping only the first chunk.
  • User-visible text now says "Voyage AI by MongoDB" (docs, docstrings). Class names, the voyageai registry key, VOYAGE_API_KEY, model ids and URLs are unchanged.
  • Docs list rerank-3 and rerank-3-lite and the minimum voyageai version (0.4.0, which added auto-chunking). The multimodal docs example used a Wikimedia thumbnail URL that Voyage cannot fetch; it now uses an image from this repository.

voyage-4-nano is not added: it runs locally and needs a different dependency and dimension contract.

Testing

  • Unit tests for the new models and dimensions, output_dimension handling, the contextualized document and query requests, the multi-chunk failure (including that it is not retried), and the batching boundaries (token limit per model, 1000-input cap, no-limit model, order, unknown model).
  • Live runs against the Voyage API: every new model with its native dimension and with a smaller dimension through table.add and search, contextualized documents and queries, rerank-3, rerank-3-lite and rerank-2.5 with top_n, and a batch of three 45K-token texts split into two requests with the order preserved.

…embeddings

Add voyage-code-4, voyage-context-4, voyage-3-large and voyage-code-3, with
Matryoshka output dimensions and per-model request token limits. Send
contextualized documents as a flat list with auto-chunking, and fail when an
input is split into several chunks. Rebrand the user-visible name, document
rerank-3 and rerank-3-lite, and fix the multimodal docs example image URL.
@fzowl

fzowl commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Summary: new models and Matryoshka dimensions, per-model token batching, flat auto-chunked contextualized documents (multi-chunk results fail explicitly), rebrand to "Voyage AI by MongoDB", docs fixes.

Proof: non-slow Python tests for embeddings and rerankers pass (218 passed); live Voyage runs for all new models, dimensions, contextualized document and query paths, rerank-3 / rerank-3-lite / rerank-2.5 with top_n, and a token-split batch with order preserved. The multimodal docs example now runs live.

Review: two rounds, last verdict APPROVE.

This branch has not been deployed

No deployments
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.

1 participant