Skip to content

Commit

Permalink
Merge pull request #1426 from weaviate/m2v-jina-updates
Browse files Browse the repository at this point in the history
m2v-jina: Add v1 clip model; dimensions param
  • Loading branch information
dirkkul authored Nov 20, 2024
2 parents acf7c0d + 1793762 commit 915c3cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion test/collection/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,13 @@ def test_basic_config():
(
Configure.Vectorizer.multi2vec_jinaai(
model="jina-clip-v2",
dimensions=512,
vectorize_collection_name=False,
),
{
"multi2vec-jinaai": {
"model": "jina-clip-v2",
"dimensions": 512,
"vectorizeClassName": False,
}
},
Expand Down Expand Up @@ -1276,11 +1278,16 @@ def test_vector_config_flat_pq() -> None:
},
),
(
[Configure.NamedVectors.multi2vec_jinaai(name="test", text_fields=["prop"])],
[
Configure.NamedVectors.multi2vec_jinaai(
name="test", dimensions=256, text_fields=["prop"]
)
],
{
"test": {
"vectorizer": {
"multi2vec-jinaai": {
"dimensions": 256,
"vectorizeClassName": True,
"textFields": ["prop"],
}
Expand Down
4 changes: 4 additions & 0 deletions weaviate/collections/classes/config_named_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ def multi2vec_jinaai(
vectorize_collection_name: bool = True,
base_url: Optional[AnyHttpUrl] = None,
model: Optional[Union[JinaMultimodalModel, str]] = None,
dimensions: Optional[int] = None,
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
) -> _NamedVectorConfigCreate:
Expand All @@ -1151,6 +1152,8 @@ def multi2vec_jinaai(
The model to use. Defaults to `None`, which uses the server-defined default.
`base_url`
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
`dimensions`
The number of dimensions for the generated embeddings (only available for some models). Defaults to `None`, which uses the server-defined default.
`image_fields`
The image fields to use in vectorization.
`text_fields`
Expand All @@ -1164,6 +1167,7 @@ def multi2vec_jinaai(
vectorizer=_Multi2VecJinaConfig(
baseURL=base_url,
model=model,
dimensions=dimensions,
vectorizeClassName=vectorize_collection_name,
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
Expand Down
10 changes: 9 additions & 1 deletion weaviate/collections/classes/config_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"jina-embeddings-v2-base-code",
"jina-embeddings-v3",
]
JinaMultimodalModel: TypeAlias = Literal["jina-clip-v2",]
JinaMultimodalModel: TypeAlias = Literal[
"jina-clip-v1",
"jina-clip-v2",
]
VoyageModel: TypeAlias = Literal[
"voyage-3",
"voyage-3-lite",
Expand Down Expand Up @@ -405,6 +408,7 @@ class _Multi2VecJinaConfig(_Multi2VecBase):
)
baseURL: Optional[AnyHttpUrl]
model: Optional[str]
dimensions: Optional[int]

def _to_dict(self) -> Dict[str, Any]:
ret_dict = super()._to_dict()
Expand Down Expand Up @@ -1220,6 +1224,7 @@ def multi2vec_jinaai(
model: Optional[Union[JinaMultimodalModel, str]] = None,
vectorize_collection_name: bool = True,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
) -> _VectorizerConfigCreate:
Expand All @@ -1235,6 +1240,8 @@ def multi2vec_jinaai(
Whether to vectorize the collection name. Defaults to `True`.
`base_url`
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
`dimensions`
The number of dimensions for the generated embeddings (only available for some models). Defaults to `None`, which uses the server-defined default.
`image_fields`
The image fields to use in vectorization.
`text_fields`
Expand All @@ -1246,6 +1253,7 @@ def multi2vec_jinaai(
return _Multi2VecJinaConfig(
baseURL=base_url,
model=model,
dimensions=dimensions,
vectorizeClassName=vectorize_collection_name,
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
Expand Down

0 comments on commit 915c3cb

Please sign in to comment.