mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
BREAKING CHANGE: `JinaEmbeddings.ndims()` previously returned 768 for unlisted model names. It now raises `ValueError`. When creating a schema with an unlisted model, pass its documented output width to `Vector(width)`. Fixes the `# TODO: fix hardcoding` in `JinaEmbeddings.ndims()` (same kind of fix as #4737, which made the OpenAI-compatible models use their real dimension). **Root cause:** `ndims()` returned 768 for every model. Any model whose default output is not 768 (jina-clip-v2 and jina-embeddings-v3: 1024, jina-embeddings-v4: 2048, jina-embeddings-v2-small-en: 512) produced a vector column of the wrong size. **Fix:** per-model lookup table of default output dimensions, only for models whose dimension is documented (model configs on Hugging Face `hidden_size`/`projection_dim`, and https://jina.ai/models/ pages). Unknown models raise a `ValueError` listing the supported names instead of silently guessing 768. The default `jina-clip-v1` still returns 768. When appending to a table, generated vectors are validated against the width of the stored fixed-size column, so existing tables that use an unlisted model keep working. **Test:** `python/tests/test_jina_embeddings.py` (no network, no API key), including reopening a table with an unlisted model, appending a matching vector and rejecting a mismatched width. This change was prepared with an AI coding assistant (Claude). --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
2.4 KiB
Plaintext
71 lines
2.4 KiB
Plaintext
---
|
|
title: Jina
|
|
sidebarTitle: Jina
|
|
---
|
|
|
|
import {
|
|
PyEmbeddingJinaText,
|
|
PyEmbeddingJinaMultimodal,
|
|
} from '/snippets/provider_examples.mdx';
|
|
|
|
## Vector Dimensions {#vector-dimensions}
|
|
|
|
`ndims()`, used when declaring a schema such as `Vector(func.ndims())`, returns the default width of these models:
|
|
|
|
| Model | Dimensions |
|
|
|---|---|
|
|
| `jina-clip-v1` | 768 |
|
|
| `jina-clip-v2` | 1024 |
|
|
| `jina-embeddings-v2-small-en` | 512 |
|
|
| `jina-embeddings-v2-base-en` | 768 |
|
|
| `jina-embeddings-v2-base-code` | 768 |
|
|
| `jina-embeddings-v2-base-de` | 768 |
|
|
| `jina-embeddings-v2-base-zh` | 768 |
|
|
| `jina-embeddings-v2-base-es` | 768 |
|
|
| `jina-embeddings-v3` | 1024 |
|
|
| `jina-embeddings-v4` | 2048 |
|
|
|
|
For any other model name, `ndims()` raises `ValueError`. Appending to an existing table whose vector column is a fixed-size list does not call `ndims()`: the generated vectors are checked against the width stored in the table.
|
|
|
|
## Text Embedding Models {#text-embedding-models}
|
|
|
|
Jina embeddings are used to generate embeddings for text and image data.
|
|
You also need to set the `JINA_API_KEY` environment variable to use the Jina API.
|
|
|
|
You can find a list of supported models under [https://jina.ai/embeddings/](https://jina.ai/embeddings/)
|
|
|
|
Supported parameters (to be passed in `create` method) are:
|
|
|
|
| Parameter | Type | Default Value | Description |
|
|
|---|---|---|---|
|
|
| `name` | `str` | `"jina-clip-v1"` | The model ID of the jina model to use |
|
|
|
|
Usage Example:
|
|
|
|
Replace `your-api-key` with your Jina API key. This provider reads it from `JINA_API_KEY`; the example sets it explicitly. In application code, supply it through your environment or a secrets manager.
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="Python" icon="python">
|
|
{PyEmbeddingJinaText}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
## Multimodal Embedding Models {#multimodal-embedding-models}
|
|
|
|
Jina embeddings can also be used to embed both text and image data, only some of the models support image data and you can check the list
|
|
under [https://jina.ai/embeddings/](https://jina.ai/embeddings/)
|
|
|
|
Supported parameters (to be passed in `create` method) are:
|
|
|
|
| Parameter | Type | Default Value | Description |
|
|
|---|---|---|---|
|
|
| `name` | `str` | `"jina-clip-v1"` | The model ID of the jina model to use |
|
|
|
|
Usage Example:
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="Python" icon="python">
|
|
{PyEmbeddingJinaMultimodal}
|
|
</CodeBlock>
|
|
</CodeGroup>
|