mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-24 04:32:27 +00:00
PIL images, PNG bytes and local image paths in VoyageAI source embeddings are saved directly as JPEG. RGBA, grayscale-with-alpha (LA) and palette (P) images therefore raise `OSError: cannot write mode ... as JPEG` before the provider is called. Convert to RGB at all three JPEG encoding sites. The caller’s original PIL image remains unchanged. Document that alpha is discarded and callers should composite onto a chosen background when it matters. Validation: - New image regressions + existing VoyageAI tests: **18 failed / 26 passed before → 44 passed after**. Tests cover both multimodal models, PIL/bytes/Path, RGBA/LA/P/RGB, decoded JPEG pixels and invalid images. - Independent local LanceDB table ingestion smoke: three PNG modes stored with 1024-dimensional vectors, original bytes preserved. Uses the freshly built current native extension. - Adjacent local embedding tests: 15 passed, 1 skipped (no OpenAI key), 9 deselected. The separate Flickr download test failed with `RemoteDisconnected`; it is excluded from the local result. - Pyright: 0 errors; CI-pinned Ruff 0.9.9 lint and Python formatting passed. External VoyageAI calls are stubbed; real Pillow conversion and LanceDB ingestion execute locally. No live provider or full-repository test result is claimed. AI assistance was used for implementation and validation.
72 lines
3.2 KiB
Plaintext
72 lines
3.2 KiB
Plaintext
---
|
|
title: Voyage AI
|
|
sidebarTitle: Voyage AI
|
|
---
|
|
|
|
import { PyEmbeddingVoyageaiUsage, PyEmbeddingVoyageaiMultimodal } from '/snippets/integrations.mdx';
|
|
|
|
Voyage AI provides cutting-edge embedding and rerankers.
|
|
|
|
|
|
Using voyageai API requires voyageai package, which can be installed using `pip install voyageai`. Voyage AI embeddings are used to generate embeddings for text data. The embeddings can be used for various tasks like semantic search, clustering, and classification.
|
|
You also need to set the `VOYAGE_API_KEY` environment variable to use the Voyage AI API.
|
|
|
|
```shell
|
|
export VOYAGE_API_KEY="your-api-key"
|
|
```
|
|
|
|
Supported models are:
|
|
|
|
- voyage-4-large (best retrieval quality, 1024 default dimensions, supports 256/512/1024/2048)
|
|
- voyage-4 (balanced general-purpose, 1024 default dimensions, supports 256/512/1024/2048)
|
|
- voyage-4-lite (optimized for latency/cost, 1024 default dimensions, supports 256/512/1024/2048)
|
|
- voyage-context-3
|
|
- voyage-3.5
|
|
- voyage-3.5-lite
|
|
- voyage-3
|
|
- voyage-3-lite
|
|
- voyage-finance-2
|
|
- voyage-multilingual-2
|
|
- voyage-law-2
|
|
- voyage-code-2
|
|
- voyage-multimodal-3.5 (multimodal - supports text, images, and video)
|
|
|
|
<Info>
|
|
**Multimodal Model:** `voyage-multimodal-3.5` supports text, images, and video inputs. It outputs 1024-dimensional embeddings by default, configurable via the `output_dimension` parameter (256, 512, 1024, 2048). See the [Voyage AI multimodal embeddings documentation](https://docs.voyageai.com/docs/multimodal-embeddings) for more details.
|
|
</Info>
|
|
|
|
Supported parameters (to be passed in `create` method) are:
|
|
|
|
| Parameter | Type | Default Value | Description |
|
|
|---|---|--------|---------|
|
|
| `name` | `str` | `None` | The model ID of the model to use. Supported models: voyage-4-large, voyage-4, voyage-4-lite, voyage-3, voyage-3-lite, voyage-3.5, voyage-3.5-lite, voyage-context-3, voyage-finance-2, voyage-multilingual-2, voyage-law-2, voyage-code-2, voyage-multimodal-3.5 |
|
|
| `input_type` | `str` | `None` | Type of the input text. Default to None. Other options: query, document. |
|
|
| `truncation` | `bool` | `True` | Whether to truncate the input texts to fit within the context length. |
|
|
| `output_dimension` | `int` | `None` | Output embedding dimension. Only supported by `voyage-multimodal-3.5`. Valid options: 256, 512, 1024 (default), 2048. |
|
|
|
|
|
|
For text models, `compute_source_embeddings()` accepts a single string, a list of strings, a one-dimensional NumPy array, or a PyArrow `Array` or `ChunkedArray`. Batch inputs retain their order.
|
|
|
|
Usage Example:
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="Python" icon="python">
|
|
{PyEmbeddingVoyageaiUsage}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
### Multimodal Example {#multimodal-example}
|
|
|
|
The `voyage-multimodal-3.5` model can embed text alongside images. You can use image URLs, local `pathlib.Path` objects, raw image bytes, or PIL Image objects.
|
|
|
|
For source embeddings, PIL images and images loaded from bytes or local paths are
|
|
converted to RGB and encoded as JPEG. This supports RGBA, grayscale with alpha,
|
|
and palette images; transparency is discarded. Composite transparent images onto
|
|
your chosen background before embedding if the background color matters.
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="Python" icon="python">
|
|
{PyEmbeddingVoyageaiMultimodal}
|
|
</CodeBlock>
|
|
</CodeGroup>
|