Skip to content

Commit 37e9659

Browse files
committed
typing fix for colpali
1 parent 1c9d9be commit 37e9659

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

fastembed/common/model_description.py

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class ModelDescription:
2828
tasks: Dict[str, int] = field(default_factory=dict)
2929

3030

31+
@dataclass(frozen=True)
32+
class MultimodalModelDescription(ModelDescription):
33+
dim: int
34+
35+
3136
@dataclass(frozen=True)
3237
class SparseModelDescription(ModelDescription):
3338
_vocab_size: InitVar[Optional[int]] = None

fastembed/late_interaction_multimodal/colpali.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
TextEmbeddingWorker,
1616
ImageEmbeddingWorker,
1717
)
18-
from fastembed.common.model_description import ModelDescription, ModelSource
18+
from fastembed.common.model_description import MultimodalModelDescription, ModelSource
1919

20-
supported_colpali_models: list[ModelDescription] = [
21-
ModelDescription(
20+
supported_colpali_models: list[MultimodalModelDescription] = [
21+
MultimodalModelDescription(
2222
model="Qdrant/colpali-v1.3-fp16",
2323
dim=128,
2424
description="Text embeddings, Multimodal (text&image), English, 50 tokens query length truncation, 2024.",
@@ -108,7 +108,7 @@ def __init__(
108108
self.load_onnx_model()
109109

110110
@classmethod
111-
def list_supported_models(cls) -> list[ModelDescription]:
111+
def list_supported_models(cls) -> list[MultimodalModelDescription]:
112112
"""Lists the supported models.
113113
114114
Returns:

fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Iterable, Optional, Sequence, Type, Union
1+
from typing import Any, Iterable, Optional, Sequence, Type, Union, cast
22

33
from fastembed.common import OnnxProvider, ImageInput
44
from fastembed.common.types import NumpyArray
@@ -7,14 +7,14 @@
77
from fastembed.late_interaction_multimodal.late_interaction_multimodal_embedding_base import (
88
LateInteractionMultimodalEmbeddingBase,
99
)
10-
from fastembed.common.model_description import ModelDescription
10+
from fastembed.common.model_description import MultimodalModelDescription
1111

1212

1313
class LateInteractionMultimodalEmbedding(LateInteractionMultimodalEmbeddingBase):
1414
EMBEDDINGS_REGISTRY: list[Type[LateInteractionMultimodalEmbeddingBase]] = [ColPali]
1515

1616
@classmethod
17-
def list_supported_models(cls) -> list[ModelDescription]:
17+
def list_supported_models(cls) -> list[MultimodalModelDescription]:
1818
"""
1919
Lists the supported models.
2020
@@ -41,9 +41,9 @@ def list_supported_models(cls) -> list[ModelDescription]:
4141
]
4242
```
4343
"""
44-
result: list[ModelDescription] = []
44+
result: list[MultimodalModelDescription] = []
4545
for embedding in cls.EMBEDDINGS_REGISTRY:
46-
result.extend(embedding.list_supported_models())
46+
result.extend(cast(MultimodalModelDescription, embedding.list_supported_models()))
4747
return result
4848

4949
def __init__(

0 commit comments

Comments
 (0)