From 9564431b579529a8fc1aa005378d02f3d751edfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Castillo=20Gonz=C3=A1lez?= <82875882+pcbeingused333@users.noreply.github.com> Date: Mon, 30 Nov 2026 06:06:26 -0500 Subject: [PATCH] fix(python): support Cohere embed-v4.0 in CohereEmbeddingFunction (#4805) `CohereEmbeddingFunction(name="embed-v4.0")` raised `ValueError: Model embed-v4.0 not supported`. **Cause.** `ndims()` uses a closed list of v2/v3 model names and raises for everything else, so Cohere's current embedding model was rejected. **Fix.** Add `embed-v4.0` to `ndims()`, returning its default output dimension (1536). **Test.** `test_cohere_embed_v4_is_supported` creates the function with `name="embed-v4.0"` and checks `ndims() == 1536`. It fails before the change with the `ValueError` and passes after; the existing Cohere default-model test still passes. This change was prepared with the help of an AI assistant (Claude Code), and the author is responsible for the change. --------- --- docs/web/integrations/embedding/cohere.mdx | 3 ++- python/python/lancedb/embeddings/cohere.py | 4 ++++ python/python/tests/test_embeddings.py | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/web/integrations/embedding/cohere.mdx b/docs/web/integrations/embedding/cohere.mdx index 3b64286a1..0706308fc 100644 --- a/docs/web/integrations/embedding/cohere.mdx +++ b/docs/web/integrations/embedding/cohere.mdx @@ -20,6 +20,7 @@ Supported models are: - embed-multilingual-v3.0 - embed-english-light-v3.0 - embed-multilingual-light-v3.0 +- embed-v4.0 (1536-dimensional by default) The v2.0 models (`embed-english-v2.0`, `embed-english-light-v2.0` and `embed-multilingual-v2.0`) were retired by Cohere on April 4, 2026. @@ -33,7 +34,7 @@ Supported parameters (to be passed in `create` method) are: | Parameter | Type | Default Value | Description | |---|---|--------|---------| -| `name` | `str` | `"embed-multilingual-v3.0"` | The model ID of the cohere model to use. Supported base models for Text Embeddings: embed-english-v3.0, embed-multilingual-v3.0, embed-english-light-v3.0, embed-multilingual-light-v3.0 | +| `name` | `str` | `"embed-multilingual-v3.0"` | The model ID of the cohere model to use. Supported base models for Text Embeddings: embed-english-v3.0, embed-multilingual-v3.0, embed-english-light-v3.0, embed-multilingual-light-v3.0, embed-v4.0 (1536-dimensional by default) | | `source_input_type` | `str` | `"search_document"` | The type of input data to be used for the source column. | | `query_input_type` | `str` | `"search_query"` | The type of input data to be used for the query. | diff --git a/python/python/lancedb/embeddings/cohere.py b/python/python/lancedb/embeddings/cohere.py index a885a3f6a..119d0c514 100644 --- a/python/python/lancedb/embeddings/cohere.py +++ b/python/python/lancedb/embeddings/cohere.py @@ -50,6 +50,7 @@ class CohereEmbeddingFunction(TextEmbeddingFunction): * embed-multilingual-v3.0 * embed-english-light-v3.0 * embed-multilingual-light-v3.0 + * embed-v4.0 (1536-dimensional by default) The v2.0 models (embed-english-v2.0, embed-english-light-v2.0 and embed-multilingual-v2.0) were retired by Cohere on April 4, 2026. @@ -198,6 +199,9 @@ class CohereEmbeddingFunction(TextEmbeddingFunction): return 1024 elif self.name in ["embed-english-light-v3.0", "embed-multilingual-light-v3.0"]: return 384 + elif self.name == "embed-v4.0": + # Default output dimension of embed-v4.0 + return 1536 elif self.name == "embed-english-v2.0": return 4096 elif self.name == "embed-multilingual-v2.0": diff --git a/python/python/tests/test_embeddings.py b/python/python/tests/test_embeddings.py index 488fd3cd9..afd07f8a1 100644 --- a/python/python/tests/test_embeddings.py +++ b/python/python/tests/test_embeddings.py @@ -1283,3 +1283,9 @@ def test_cohere_default_model_is_not_a_retired_v2_model(): assert cohere.name == "embed-multilingual-v3.0" assert "v2.0" not in cohere.name assert cohere.ndims() == 1024 + + +def test_cohere_embed_v4_is_supported(): + cohere = get_registry().get("cohere").create(name="embed-v4.0") + + assert cohere.ndims() == 1536