Skip to content

Commit acf7c0d

Browse files
authored
Merge pull request #1422 from weaviate/multi2vec-jinaai
Add support for `multi2vec-jinaai`; docstring changes
2 parents 367b684 + b844a1b commit acf7c0d

File tree

3 files changed

+196
-48
lines changed

3 files changed

+196
-48
lines changed

test/collection/test_config.py

+40
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,32 @@ def test_basic_config():
355355
}
356356
},
357357
),
358+
(
359+
Configure.Vectorizer.text2vec_jinaai(
360+
model="jina-embeddings-v3",
361+
vectorize_collection_name=False,
362+
dimensions=512,
363+
),
364+
{
365+
"text2vec-jinaai": {
366+
"model": "jina-embeddings-v3",
367+
"vectorizeClassName": False,
368+
"dimensions": 512,
369+
}
370+
},
371+
),
372+
(
373+
Configure.Vectorizer.multi2vec_jinaai(
374+
model="jina-clip-v2",
375+
vectorize_collection_name=False,
376+
),
377+
{
378+
"multi2vec-jinaai": {
379+
"model": "jina-clip-v2",
380+
"vectorizeClassName": False,
381+
}
382+
},
383+
),
358384
(
359385
Configure.Vectorizer.text2vec_voyageai(
360386
vectorize_collection_name=False,
@@ -1249,6 +1275,20 @@ def test_vector_config_flat_pq() -> None:
12491275
}
12501276
},
12511277
),
1278+
(
1279+
[Configure.NamedVectors.multi2vec_jinaai(name="test", text_fields=["prop"])],
1280+
{
1281+
"test": {
1282+
"vectorizer": {
1283+
"multi2vec-jinaai": {
1284+
"vectorizeClassName": True,
1285+
"textFields": ["prop"],
1286+
}
1287+
},
1288+
"vectorIndexType": "hnsw",
1289+
}
1290+
},
1291+
),
12521292
(
12531293
[Configure.NamedVectors.text2vec_gpt4all(name="test", source_properties=["prop"])],
12541294
{

weaviate/collections/classes/config_named_vectors.py

+73-25
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
AWSModel,
4040
AWSService,
4141
CohereModel,
42+
CohereMultimodalModel,
4243
CohereTruncation,
4344
JinaModel,
45+
JinaMultimodalModel,
4446
Multi2VecField,
4547
OpenAIModel,
4648
OpenAIType,
@@ -51,6 +53,7 @@
5153
_Text2VecDatabricksConfig,
5254
_Text2VecVoyageConfig,
5355
_Multi2VecCohereConfig,
56+
_Multi2VecJinaConfig,
5457
)
5558
from ...warnings import _Warnings
5659

@@ -161,7 +164,7 @@ def text2vec_cohere(
161164
) -> _NamedVectorConfigCreate:
162165
"""Create a named vector using the `text2vec_cohere` model.
163166
164-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-cohere)
167+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/cohere/embeddings)
165168
for detailed usage.
166169
167170
Arguments:
@@ -183,7 +186,7 @@ def text2vec_cohere(
183186
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
184187
185188
Raises:
186-
`pydantic.ValidationError` if `truncate` is not a valid value from the `CohereModel` type.
189+
`pydantic.ValidationError` if `model` is not a valid value from the `CohereModel` type or if `truncate` is not a valid value from the `CohereTruncation` type.
187190
"""
188191
return _NamedVectorConfigCreate(
189192
name=name,
@@ -204,14 +207,14 @@ def multi2vec_cohere(
204207
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
205208
vectorize_collection_name: bool = True,
206209
base_url: Optional[AnyHttpUrl] = None,
207-
model: Optional[Union[CohereModel, str]] = None,
210+
model: Optional[Union[CohereMultimodalModel, str]] = None,
208211
truncate: Optional[CohereTruncation] = None,
209212
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
210213
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
211214
) -> _NamedVectorConfigCreate:
212215
"""Create a named vector using the `multi2vec_cohere` model.
213216
214-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-cohere)
217+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/cohere/embeddings-multimodal)
215218
for detailed usage.
216219
217220
Arguments:
@@ -225,8 +228,6 @@ def multi2vec_cohere(
225228
The model to use. Defaults to `None`, which uses the server-defined default.
226229
`truncate`
227230
The truncation strategy to use. Defaults to `None`, which uses the server-defined default.
228-
`vectorize_collection_name`
229-
Whether to vectorize the collection name. Defaults to `True`.
230231
`base_url`
231232
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
232233
`image_fields`
@@ -235,7 +236,7 @@ def multi2vec_cohere(
235236
The text fields to use in vectorization.
236237
237238
Raises:
238-
`pydantic.ValidationError` if `truncate` is not a valid value from the `CohereModel` type.
239+
`pydantic.ValidationError` if `model` is not a valid value from the `CohereMultimodalModel` type or if `truncate` is not a valid value from the `CohereTruncation` type.
239240
"""
240241
return _NamedVectorConfigCreate(
241242
name=name,
@@ -294,7 +295,7 @@ def text2vec_databricks(
294295
) -> _NamedVectorConfigCreate:
295296
"""Create a named vector using the `text2vec-databricks` model.
296297
297-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-databricks)
298+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/databricks/embeddings)
298299
for detailed usage.
299300
300301
Arguments:
@@ -333,7 +334,7 @@ def text2vec_mistral(
333334
) -> _NamedVectorConfigCreate:
334335
"""Create a named vector using the `text2vec-mistral` model.
335336
336-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-mistral)
337+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/mistral/embeddings)
337338
for detailed usage.
338339
339340
Arguments:
@@ -370,7 +371,7 @@ def text2vec_ollama(
370371
) -> _NamedVectorConfigCreate:
371372
"""Create a named vector using the `text2vec-ollama` model.
372373
373-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-ollama)
374+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/ollama/embeddings)
374375
for detailed usage.
375376
376377
Arguments:
@@ -417,7 +418,7 @@ def text2vec_openai(
417418
) -> _NamedVectorConfigCreate:
418419
"""Create a named vector using the `text2vec_openai` model.
419420
420-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-openai)
421+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/openai/embeddings)
421422
for detailed usage.
422423
423424
Arguments:
@@ -473,7 +474,7 @@ def text2vec_aws(
473474
) -> _NamedVectorConfigCreate:
474475
"""Create a named vector using the `text2vec_aws` model.
475476
476-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-aws)
477+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/aws/embeddings)
477478
for detailed usage.
478479
479480
Arguments:
@@ -546,7 +547,7 @@ def multi2vec_clip(
546547
) -> _NamedVectorConfigCreate:
547548
"""Create a named vector using the `multi2vec_clip` model.
548549
549-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-gpt4all)
550+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/transformers/embeddings-multimodal)
550551
for detailed usage.
551552
552553
Arguments:
@@ -726,7 +727,7 @@ def multi2vec_bind(
726727
) -> _NamedVectorConfigCreate:
727728
"""Create a named vector using the `multi2vec_bind` model.
728729
729-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-gpt4all)
730+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/imagebind/embeddings-multimodal)
730731
for detailed usage.
731732
732733
Arguments:
@@ -797,7 +798,7 @@ def text2vec_azure_openai(
797798
) -> _NamedVectorConfigCreate:
798799
"""Create a named vector using the `text2vec_azure_openai` model.
799800
800-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-gpt4all)
801+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/openai-azure/embeddings)
801802
for detailed usage.
802803
803804
Arguments:
@@ -832,7 +833,7 @@ def text2vec_gpt4all(
832833
) -> _NamedVectorConfigCreate:
833834
"""Create a named vector using the `text2vec_gpt4all` model.
834835
835-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-gpt4all)
836+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/gpt4all/embeddings)
836837
for detailed usage.
837838
838839
Arguments:
@@ -871,7 +872,7 @@ def text2vec_huggingface(
871872
) -> _NamedVectorConfigCreate:
872873
"""Create a named vector using the `text2vec_huggingface` model.
873874
874-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-huggingface)
875+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/huggingface/embeddings)
875876
for detailed usage.
876877
877878
Arguments:
@@ -901,7 +902,7 @@ def text2vec_huggingface(
901902
Raises:
902903
`pydantic.ValidationError` if the arguments passed to the function are invalid.
903904
It is important to note that some of these variables are mutually exclusive.
904-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-huggingface) for more details.
905+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/huggingface/embeddings#vectorizer-parameters) for more details.
905906
"""
906907
return _NamedVectorConfigCreate(
907908
name=name,
@@ -936,7 +937,7 @@ def text2vec_palm(
936937
) -> _NamedVectorConfigCreate:
937938
"""Create a named vector using the `text2vec_palm` model.
938939
939-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-palm)
940+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/google/embeddings)
940941
for detailed usage.
941942
942943
Arguments:
@@ -990,7 +991,7 @@ def text2vec_google(
990991
) -> _NamedVectorConfigCreate:
991992
"""Create a named vector using the `text2vec_palm` model.
992993
993-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-google)
994+
See the [documentation]https://weaviate.io/developers/weaviate/model-providers/google/embeddings)
994995
for detailed usage.
995996
996997
Arguments:
@@ -1043,7 +1044,7 @@ def text2vec_transformers(
10431044
) -> _NamedVectorConfigCreate:
10441045
"""Create a named vector using the `text2vec_transformers` model.
10451046
1046-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-transformers)
1047+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/transformers/embeddings)
10471048
for detailed usage.
10481049
10491050
Arguments:
@@ -1090,7 +1091,7 @@ def text2vec_jinaai(
10901091
) -> _NamedVectorConfigCreate:
10911092
"""Create a named vector using the `text2vec-jinaai` model.
10921093
1093-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-jinaai)
1094+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings)
10941095
for detailed usage.
10951096
10961097
Arguments:
@@ -1109,7 +1110,7 @@ def text2vec_jinaai(
11091110
`model`
11101111
The model to use. Defaults to `None`, which uses the server-defined default.
11111112
See the
1112-
[documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-jinaai#available-models) for more details.
1113+
[documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings#available-models) for more details.
11131114
"""
11141115
return _NamedVectorConfigCreate(
11151116
name=name,
@@ -1123,6 +1124,53 @@ def text2vec_jinaai(
11231124
vector_index_config=vector_index_config,
11241125
)
11251126

1127+
@staticmethod
1128+
def multi2vec_jinaai(
1129+
name: str,
1130+
*,
1131+
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
1132+
vectorize_collection_name: bool = True,
1133+
base_url: Optional[AnyHttpUrl] = None,
1134+
model: Optional[Union[JinaMultimodalModel, str]] = None,
1135+
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
1136+
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
1137+
) -> _NamedVectorConfigCreate:
1138+
"""Create a named vector using the `multi2vec_jinaai` model.
1139+
1140+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings-multimodal)
1141+
for detailed usage.
1142+
1143+
Arguments:
1144+
`name`
1145+
The name of the named vector.
1146+
`vector_index_config`
1147+
The configuration for Weaviate's vector index. Use wvc.config.Configure.VectorIndex to create a vector index configuration. None by default
1148+
`vectorize_collection_name`
1149+
Whether to vectorize the collection name. Defaults to `True`.
1150+
`model`
1151+
The model to use. Defaults to `None`, which uses the server-defined default.
1152+
`base_url`
1153+
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
1154+
`image_fields`
1155+
The image fields to use in vectorization.
1156+
`text_fields`
1157+
The text fields to use in vectorization.
1158+
1159+
Raises:
1160+
`pydantic.ValidationError` if `model` is not a valid value from the `JinaMultimodalModel` type.
1161+
"""
1162+
return _NamedVectorConfigCreate(
1163+
name=name,
1164+
vectorizer=_Multi2VecJinaConfig(
1165+
baseURL=base_url,
1166+
model=model,
1167+
vectorizeClassName=vectorize_collection_name,
1168+
imageFields=_map_multi2vec_fields(image_fields),
1169+
textFields=_map_multi2vec_fields(text_fields),
1170+
),
1171+
vector_index_config=vector_index_config,
1172+
)
1173+
11261174
@staticmethod
11271175
def text2vec_voyageai(
11281176
name: str,
@@ -1136,7 +1184,7 @@ def text2vec_voyageai(
11361184
) -> _NamedVectorConfigCreate:
11371185
"""Create a named vector using the `text2vec-jinaai` model.
11381186
1139-
See the [documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-jinaai)
1187+
See the [documentation](https://weaviate.io/developers/weaviate/model-providers/voyageai/embeddings)
11401188
for detailed usage.
11411189
11421190
Arguments:
@@ -1151,7 +1199,7 @@ def text2vec_voyageai(
11511199
`model`
11521200
The model to use. Defaults to `None`, which uses the server-defined default.
11531201
See the
1154-
[documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-voyageai#available-models) for more details.
1202+
[documentation](https://weaviate.io/developers/weaviate/model-providers/voyageai/embeddings#available-models) for more details.
11551203
`base_url`
11561204
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
11571205
`truncate`

0 commit comments

Comments
 (0)