Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/collection/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,28 @@ def test_config_with_named_vectors(
}
},
),
(
[
Configure.Vectors.multi2vec_twelvelabs(
name="test",
image_fields=["image"],
text_fields=["prop"],
model="marengo3.0",
)
],
{
"test": {
"vectorizer": {
"multi2vec-twelvelabs": {
"imageFields": ["image"],
"textFields": ["prop"],
"model": "marengo3.0",
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[Configure.Vectors.multi2vec_jinaai(name="test", dimensions=256, text_fields=["prop"])],
{
Expand Down
16 changes: 16 additions & 0 deletions weaviate/collections/classes/config_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Vectorizers(str, Enum):
MULTI2VEC_BIND: Weaviate module backed by the ImageBind model for images, text, audio, depth, IMU, thermal, and video.
MULTI2VEC_VOYAGEAI: Weaviate module backed by a Voyage AI multimodal embedding models.
MULTI2VEC_NVIDIA: Weaviate module backed by NVIDIA multimodal embedding models.
MULTI2VEC_TWELVELABS: Weaviate module backed by TwelveLabs multimodal embedding models.
REF2VEC_CENTROID: Weaviate module backed by a centroid-based model that calculates an object's vectors from its referenced vectors.
"""

Expand Down Expand Up @@ -144,6 +145,7 @@ class Vectorizers(str, Enum):
MULTI2VEC_PALM = "multi2vec-palm" # change to google once 1.27 is the lowest supported version
MULTI2VEC_VOYAGEAI = "multi2vec-voyageai"
MULTI2VEC_NVIDIA = "multi2vec-nvidia"
MULTI2VEC_TWELVELABS = "multi2vec-twelvelabs"
REF2VEC_CENTROID = "ref2vec-centroid"


Expand Down Expand Up @@ -619,6 +621,20 @@ def _to_dict(self) -> Dict[str, Any]:
return ret_dict


class _Multi2VecTwelvelabsConfig(_Multi2VecBase):
vectorizer: Union[Vectorizers, _EnumLikeStr] = Field(
default=Vectorizers.MULTI2VEC_TWELVELABS, frozen=True, exclude=True
)
baseURL: Optional[AnyHttpUrl]
model: Optional[str]

def _to_dict(self) -> Dict[str, Any]:
ret_dict = super()._to_dict()
if self.baseURL is not None:
ret_dict["baseURL"] = self.baseURL.unicode_string()
return ret_dict


class _Ref2VecCentroidConfig(_VectorizerConfigCreate):
vectorizer: Union[Vectorizers, _EnumLikeStr] = Field(
default=Vectorizers.REF2VEC_CENTROID, frozen=True, exclude=True
Expand Down
37 changes: 37 additions & 0 deletions weaviate/collections/classes/config_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
_Multi2VecGoogleConfig,
_Multi2VecJinaConfig,
_Multi2VecNvidiaConfig,
_Multi2VecTwelvelabsConfig,
_Multi2VecVoyageaiConfig,
_Ref2VecCentroidConfig,
_Text2ColbertJinaAIConfig,
Expand Down Expand Up @@ -1311,6 +1312,42 @@ def multi2vec_nvidia(
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
)

@staticmethod
def multi2vec_twelvelabs(
*,
name: Optional[str] = None,
quantizer: Optional[_QuantizerConfigCreate] = None,
base_url: Optional[AnyHttpUrl] = None,
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
model: Optional[str] = None,
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
) -> _VectorConfigCreate:
"""Create a vector using the `multi2vec-twelvelabs` module.

See the [documentation](https://weaviate.io/developers/weaviate/model-providers/twelvelabs/embeddings-multimodal)
for detailed usage.

Args:
name: The name of the vector.
quantizer: The quantizer to use for the vector index. If not provided, no quantization will be applied.
base_url: The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
image_fields: The image fields to use in vectorization.
model: The model to use. Defaults to `None`, which uses the server-defined default.
text_fields: The text fields to use in vectorization.
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default
"""
return _VectorConfigCreate(
name=name,
vectorizer=_Multi2VecTwelvelabsConfig(
baseURL=base_url,
model=model,
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
),
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
)

@staticmethod
def ref2vec_centroid(
*,
Expand Down