fastembed-gpu 0.7.0__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/PKG-INFO +1 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/image_embedding.py +34 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/image_embedding_base.py +11 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/onnx_embedding.py +4 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/onnx_image_model.py +4 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction/colbert.py +4 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction/late_interaction_embedding_base.py +11 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction/late_interaction_text_embedding.py +34 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction/token_embeddings.py +1 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/colpali.py +7 -2
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py +34 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding_base.py +11 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/onnx_multimodal_model.py +8 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/onnx_text_cross_encoder.py +4 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/onnx_text_model.py +4 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/bm25.py +8 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/bm42.py +4 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/minicoil.py +8 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/sparse_text_embedding.py +1 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/splade_pp.py +4 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/custom_text_embedding.py +5 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/onnx_embedding.py +4 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/onnx_text_model.py +4 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/text_embedding.py +41 -7
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/text_embedding_base.py +11 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/pyproject.toml +1 -1
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/LICENSE +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/NOTICE +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/README.md +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/model_description.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/model_management.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/onnx_model.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/preprocessor_utils.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/types.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/common/utils.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/embedding.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/transform/functional.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/image/transform/operators.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction/jina_colbert.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/parallel_processor.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/py.typed +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/custom_text_cross_encoder.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/text_cross_encoder.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/text_cross_encoder_base.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/sparse_embedding_base.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/utils/minicoil_encoder.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/utils/sparse_vectors_converter.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/utils/tokenizer.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/utils/vocab_resolver.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/__init__.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/clip_embedding.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/multitask_embedding.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/pooled_embedding.py +0 -0
- {fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/text/pooled_normalized_embedding.py +0 -0
|
@@ -77,6 +77,40 @@ class ImageEmbedding(ImageEmbeddingBase):
|
|
|
77
77
|
"Please check the supported models using `ImageEmbedding.list_supported_models()`"
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
+
@property
|
|
81
|
+
def embedding_size(self) -> int:
|
|
82
|
+
"""Get the embedding size of the current model"""
|
|
83
|
+
if self._embedding_size is None:
|
|
84
|
+
self._embedding_size = self.get_embedding_size(self.model_name)
|
|
85
|
+
return self._embedding_size
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
89
|
+
"""Get the embedding size of the passed model
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
model_name (str): The name of the model to get embedding size for.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
int: The size of the embedding.
|
|
96
|
+
|
|
97
|
+
Raises:
|
|
98
|
+
ValueError: If the model name is not found in the supported models.
|
|
99
|
+
"""
|
|
100
|
+
descriptions = cls._list_supported_models()
|
|
101
|
+
embedding_size: Optional[int] = None
|
|
102
|
+
for description in descriptions:
|
|
103
|
+
if description.model.lower() == model_name.lower():
|
|
104
|
+
embedding_size = description.dim
|
|
105
|
+
break
|
|
106
|
+
if embedding_size is None:
|
|
107
|
+
model_names = [description.model for description in descriptions]
|
|
108
|
+
raise ValueError(
|
|
109
|
+
f"Embedding size for model {model_name} was None. "
|
|
110
|
+
f"Available model names: {model_names}"
|
|
111
|
+
)
|
|
112
|
+
return embedding_size
|
|
113
|
+
|
|
80
114
|
def embed(
|
|
81
115
|
self,
|
|
82
116
|
images: Union[ImageInput, Iterable[ImageInput]],
|
|
@@ -18,6 +18,7 @@ class ImageEmbeddingBase(ModelManagement[DenseModelDescription]):
|
|
|
18
18
|
self.cache_dir = cache_dir
|
|
19
19
|
self.threads = threads
|
|
20
20
|
self._local_files_only = kwargs.pop("local_files_only", False)
|
|
21
|
+
self._embedding_size: Optional[int] = None
|
|
21
22
|
|
|
22
23
|
def embed(
|
|
23
24
|
self,
|
|
@@ -42,3 +43,13 @@ class ImageEmbeddingBase(ModelManagement[DenseModelDescription]):
|
|
|
42
43
|
Iterable[NdArray]: The embeddings.
|
|
43
44
|
"""
|
|
44
45
|
raise NotImplementedError()
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
49
|
+
"""Returns embedding size of the chosen model."""
|
|
50
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def embedding_size(self) -> int:
|
|
54
|
+
"""Returns embedding size for the current model"""
|
|
55
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
@@ -112,11 +112,12 @@ class OnnxImageEmbedding(ImageEmbeddingBase, OnnxImageModel[NumpyArray]):
|
|
|
112
112
|
|
|
113
113
|
self.model_description = self._get_model_description(model_name)
|
|
114
114
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
115
|
+
self._specific_model_path = specific_model_path
|
|
115
116
|
self._model_dir = self.download_model(
|
|
116
117
|
self.model_description,
|
|
117
118
|
self.cache_dir,
|
|
118
119
|
local_files_only=self._local_files_only,
|
|
119
|
-
specific_model_path=
|
|
120
|
+
specific_model_path=self._specific_model_path,
|
|
120
121
|
)
|
|
121
122
|
|
|
122
123
|
if not self.lazy_load:
|
|
@@ -177,6 +178,8 @@ class OnnxImageEmbedding(ImageEmbeddingBase, OnnxImageModel[NumpyArray]):
|
|
|
177
178
|
providers=self.providers,
|
|
178
179
|
cuda=self.cuda,
|
|
179
180
|
device_ids=self.device_ids,
|
|
181
|
+
local_files_only=self._local_files_only,
|
|
182
|
+
specific_model_path=self._specific_model_path,
|
|
180
183
|
**kwargs,
|
|
181
184
|
)
|
|
182
185
|
|
|
@@ -97,6 +97,8 @@ class OnnxImageModel(OnnxModel[T]):
|
|
|
97
97
|
providers: Optional[Sequence[OnnxProvider]] = None,
|
|
98
98
|
cuda: bool = False,
|
|
99
99
|
device_ids: Optional[list[int]] = None,
|
|
100
|
+
local_files_only: bool = False,
|
|
101
|
+
specific_model_path: Optional[str] = None,
|
|
100
102
|
**kwargs: Any,
|
|
101
103
|
) -> Iterable[T]:
|
|
102
104
|
is_small = False
|
|
@@ -123,6 +125,8 @@ class OnnxImageModel(OnnxModel[T]):
|
|
|
123
125
|
"model_name": model_name,
|
|
124
126
|
"cache_dir": cache_dir,
|
|
125
127
|
"providers": providers,
|
|
128
|
+
"local_files_only": local_files_only,
|
|
129
|
+
"specific_model_path": specific_model_path,
|
|
126
130
|
**kwargs,
|
|
127
131
|
}
|
|
128
132
|
|
|
@@ -169,11 +169,12 @@ class Colbert(LateInteractionTextEmbeddingBase, OnnxTextModel[NumpyArray]):
|
|
|
169
169
|
self.model_description = self._get_model_description(model_name)
|
|
170
170
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
171
171
|
|
|
172
|
+
self._specific_model_path = specific_model_path
|
|
172
173
|
self._model_dir = self.download_model(
|
|
173
174
|
self.model_description,
|
|
174
175
|
self.cache_dir,
|
|
175
176
|
local_files_only=self._local_files_only,
|
|
176
|
-
specific_model_path=
|
|
177
|
+
specific_model_path=self._specific_model_path,
|
|
177
178
|
)
|
|
178
179
|
self.mask_token_id: Optional[int] = None
|
|
179
180
|
self.pad_token_id: Optional[int] = None
|
|
@@ -233,6 +234,8 @@ class Colbert(LateInteractionTextEmbeddingBase, OnnxTextModel[NumpyArray]):
|
|
|
233
234
|
providers=self.providers,
|
|
234
235
|
cuda=self.cuda,
|
|
235
236
|
device_ids=self.device_ids,
|
|
237
|
+
local_files_only=self._local_files_only,
|
|
238
|
+
specific_model_path=self._specific_model_path,
|
|
236
239
|
**kwargs,
|
|
237
240
|
)
|
|
238
241
|
|
|
@@ -17,6 +17,7 @@ class LateInteractionTextEmbeddingBase(ModelManagement[DenseModelDescription]):
|
|
|
17
17
|
self.cache_dir = cache_dir
|
|
18
18
|
self.threads = threads
|
|
19
19
|
self._local_files_only = kwargs.pop("local_files_only", False)
|
|
20
|
+
self._embedding_size: Optional[int] = None
|
|
20
21
|
|
|
21
22
|
def embed(
|
|
22
23
|
self,
|
|
@@ -58,3 +59,13 @@ class LateInteractionTextEmbeddingBase(ModelManagement[DenseModelDescription]):
|
|
|
58
59
|
yield from self.embed([query], **kwargs)
|
|
59
60
|
else:
|
|
60
61
|
yield from self.embed(query, **kwargs)
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
65
|
+
"""Returns embedding size of the chosen model."""
|
|
66
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def embedding_size(self) -> int:
|
|
70
|
+
"""Returns embedding size for the current model"""
|
|
71
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
@@ -80,6 +80,40 @@ class LateInteractionTextEmbedding(LateInteractionTextEmbeddingBase):
|
|
|
80
80
|
"Please check the supported models using `LateInteractionTextEmbedding.list_supported_models()`"
|
|
81
81
|
)
|
|
82
82
|
|
|
83
|
+
@property
|
|
84
|
+
def embedding_size(self) -> int:
|
|
85
|
+
"""Get the embedding size of the current model"""
|
|
86
|
+
if self._embedding_size is None:
|
|
87
|
+
self._embedding_size = self.get_embedding_size(self.model_name)
|
|
88
|
+
return self._embedding_size
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
92
|
+
"""Get the embedding size of the passed model
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
model_name (str): The name of the model to get embedding size for.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
int: The size of the embedding.
|
|
99
|
+
|
|
100
|
+
Raises:
|
|
101
|
+
ValueError: If the model name is not found in the supported models.
|
|
102
|
+
"""
|
|
103
|
+
descriptions = cls._list_supported_models()
|
|
104
|
+
embedding_size: Optional[int] = None
|
|
105
|
+
for description in descriptions:
|
|
106
|
+
if description.model.lower() == model_name.lower():
|
|
107
|
+
embedding_size = description.dim
|
|
108
|
+
break
|
|
109
|
+
if embedding_size is None:
|
|
110
|
+
model_names = [description.model for description in descriptions]
|
|
111
|
+
raise ValueError(
|
|
112
|
+
f"Embedding size for model {model_name} was None. "
|
|
113
|
+
f"Available model names: {model_names}"
|
|
114
|
+
)
|
|
115
|
+
return embedding_size
|
|
116
|
+
|
|
83
117
|
def embed(
|
|
84
118
|
self,
|
|
85
119
|
documents: Union[str, Iterable[str]],
|
|
@@ -9,7 +9,7 @@ from fastembed.late_interaction.late_interaction_embedding_base import (
|
|
|
9
9
|
)
|
|
10
10
|
from fastembed.text.onnx_embedding import OnnxTextEmbedding
|
|
11
11
|
from fastembed.text.onnx_text_model import TextEmbeddingWorker
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
|
|
14
14
|
supported_token_embeddings_models = [
|
|
15
15
|
DenseModelDescription(
|
{fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/colpali.py
RENAMED
|
@@ -95,11 +95,12 @@ class ColPali(LateInteractionMultimodalEmbeddingBase, OnnxMultimodalModel[NumpyA
|
|
|
95
95
|
self.model_description = self._get_model_description(model_name)
|
|
96
96
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
97
97
|
|
|
98
|
+
self._specific_model_path = specific_model_path
|
|
98
99
|
self._model_dir = self.download_model(
|
|
99
100
|
self.model_description,
|
|
100
101
|
self.cache_dir,
|
|
101
102
|
local_files_only=self._local_files_only,
|
|
102
|
-
specific_model_path=
|
|
103
|
+
specific_model_path=self._specific_model_path,
|
|
103
104
|
)
|
|
104
105
|
self.mask_token_id = None
|
|
105
106
|
self.pad_token_id = None
|
|
@@ -174,7 +175,7 @@ class ColPali(LateInteractionMultimodalEmbeddingBase, OnnxMultimodalModel[NumpyA
|
|
|
174
175
|
) -> dict[str, NumpyArray]:
|
|
175
176
|
onnx_input["input_ids"] = np.array(
|
|
176
177
|
[
|
|
177
|
-
self.QUERY_MARKER_TOKEN_ID + input_ids[2:].tolist()
|
|
178
|
+
self.QUERY_MARKER_TOKEN_ID + input_ids[2:].tolist() # type: ignore[index]
|
|
178
179
|
for input_ids in onnx_input["input_ids"]
|
|
179
180
|
]
|
|
180
181
|
)
|
|
@@ -235,6 +236,8 @@ class ColPali(LateInteractionMultimodalEmbeddingBase, OnnxMultimodalModel[NumpyA
|
|
|
235
236
|
providers=self.providers,
|
|
236
237
|
cuda=self.cuda,
|
|
237
238
|
device_ids=self.device_ids,
|
|
239
|
+
local_files_only=self._local_files_only,
|
|
240
|
+
specific_model_path=self._specific_model_path,
|
|
238
241
|
**kwargs,
|
|
239
242
|
)
|
|
240
243
|
|
|
@@ -268,6 +271,8 @@ class ColPali(LateInteractionMultimodalEmbeddingBase, OnnxMultimodalModel[NumpyA
|
|
|
268
271
|
providers=self.providers,
|
|
269
272
|
cuda=self.cuda,
|
|
270
273
|
device_ids=self.device_ids,
|
|
274
|
+
local_files_only=self._local_files_only,
|
|
275
|
+
specific_model_path=self._specific_model_path,
|
|
271
276
|
**kwargs,
|
|
272
277
|
)
|
|
273
278
|
|
|
@@ -83,6 +83,40 @@ class LateInteractionMultimodalEmbedding(LateInteractionMultimodalEmbeddingBase)
|
|
|
83
83
|
"Please check the supported models using `LateInteractionMultimodalEmbedding.list_supported_models()`"
|
|
84
84
|
)
|
|
85
85
|
|
|
86
|
+
@property
|
|
87
|
+
def embedding_size(self) -> int:
|
|
88
|
+
"""Get the embedding size of the current model"""
|
|
89
|
+
if self._embedding_size is None:
|
|
90
|
+
self._embedding_size = self.get_embedding_size(self.model_name)
|
|
91
|
+
return self._embedding_size
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
95
|
+
"""Get the embedding size of the passed model
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
model_name (str): The name of the model to get embedding size for.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
int: The size of the embedding.
|
|
102
|
+
|
|
103
|
+
Raises:
|
|
104
|
+
ValueError: If the model name is not found in the supported models.
|
|
105
|
+
"""
|
|
106
|
+
descriptions = cls._list_supported_models()
|
|
107
|
+
embedding_size: Optional[int] = None
|
|
108
|
+
for description in descriptions:
|
|
109
|
+
if description.model.lower() == model_name.lower():
|
|
110
|
+
embedding_size = description.dim
|
|
111
|
+
break
|
|
112
|
+
if embedding_size is None:
|
|
113
|
+
model_names = [description.model for description in descriptions]
|
|
114
|
+
raise ValueError(
|
|
115
|
+
f"Embedding size for model {model_name} was None. "
|
|
116
|
+
f"Available model names: {model_names}"
|
|
117
|
+
)
|
|
118
|
+
return embedding_size
|
|
119
|
+
|
|
86
120
|
def embed_text(
|
|
87
121
|
self,
|
|
88
122
|
documents: Union[str, Iterable[str]],
|
|
@@ -19,6 +19,7 @@ class LateInteractionMultimodalEmbeddingBase(ModelManagement[DenseModelDescripti
|
|
|
19
19
|
self.cache_dir = cache_dir
|
|
20
20
|
self.threads = threads
|
|
21
21
|
self._local_files_only = kwargs.pop("local_files_only", False)
|
|
22
|
+
self._embedding_size: Optional[int] = None
|
|
22
23
|
|
|
23
24
|
def embed_text(
|
|
24
25
|
self,
|
|
@@ -65,3 +66,13 @@ class LateInteractionMultimodalEmbeddingBase(ModelManagement[DenseModelDescripti
|
|
|
65
66
|
List of embeddings, one per image
|
|
66
67
|
"""
|
|
67
68
|
raise NotImplementedError()
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
72
|
+
"""Returns embedding size of the chosen model."""
|
|
73
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def embedding_size(self) -> int:
|
|
77
|
+
"""Returns embedding size for the current model"""
|
|
78
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
@@ -120,6 +120,8 @@ class OnnxMultimodalModel(OnnxModel[T]):
|
|
|
120
120
|
providers: Optional[Sequence[OnnxProvider]] = None,
|
|
121
121
|
cuda: bool = False,
|
|
122
122
|
device_ids: Optional[list[int]] = None,
|
|
123
|
+
local_files_only: bool = False,
|
|
124
|
+
specific_model_path: Optional[str] = None,
|
|
123
125
|
**kwargs: Any,
|
|
124
126
|
) -> Iterable[T]:
|
|
125
127
|
is_small = False
|
|
@@ -146,6 +148,8 @@ class OnnxMultimodalModel(OnnxModel[T]):
|
|
|
146
148
|
"model_name": model_name,
|
|
147
149
|
"cache_dir": cache_dir,
|
|
148
150
|
"providers": providers,
|
|
151
|
+
"local_files_only": local_files_only,
|
|
152
|
+
"specific_model_path": specific_model_path,
|
|
149
153
|
**kwargs,
|
|
150
154
|
}
|
|
151
155
|
|
|
@@ -183,6 +187,8 @@ class OnnxMultimodalModel(OnnxModel[T]):
|
|
|
183
187
|
providers: Optional[Sequence[OnnxProvider]] = None,
|
|
184
188
|
cuda: bool = False,
|
|
185
189
|
device_ids: Optional[list[int]] = None,
|
|
190
|
+
local_files_only: bool = False,
|
|
191
|
+
specific_model_path: Optional[str] = None,
|
|
186
192
|
**kwargs: Any,
|
|
187
193
|
) -> Iterable[T]:
|
|
188
194
|
is_small = False
|
|
@@ -209,6 +215,8 @@ class OnnxMultimodalModel(OnnxModel[T]):
|
|
|
209
215
|
"model_name": model_name,
|
|
210
216
|
"cache_dir": cache_dir,
|
|
211
217
|
"providers": providers,
|
|
218
|
+
"local_files_only": local_files_only,
|
|
219
|
+
"specific_model_path": specific_model_path,
|
|
212
220
|
**kwargs,
|
|
213
221
|
}
|
|
214
222
|
|
|
@@ -131,11 +131,12 @@ class OnnxTextCrossEncoder(TextCrossEncoderBase, OnnxCrossEncoderModel):
|
|
|
131
131
|
|
|
132
132
|
self.model_description = self._get_model_description(model_name)
|
|
133
133
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
134
|
+
self._specific_model_path = specific_model_path
|
|
134
135
|
self._model_dir = self.download_model(
|
|
135
136
|
self.model_description,
|
|
136
137
|
self.cache_dir,
|
|
137
138
|
local_files_only=self._local_files_only,
|
|
138
|
-
specific_model_path=
|
|
139
|
+
specific_model_path=self._specific_model_path,
|
|
139
140
|
)
|
|
140
141
|
|
|
141
142
|
if not self.lazy_load:
|
|
@@ -189,6 +190,8 @@ class OnnxTextCrossEncoder(TextCrossEncoderBase, OnnxCrossEncoderModel):
|
|
|
189
190
|
providers=self.providers,
|
|
190
191
|
cuda=self.cuda,
|
|
191
192
|
device_ids=self.device_ids,
|
|
193
|
+
local_files_only=self._local_files_only,
|
|
194
|
+
specific_model_path=self._specific_model_path,
|
|
192
195
|
**kwargs,
|
|
193
196
|
)
|
|
194
197
|
|
{fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/onnx_text_model.py
RENAMED
|
@@ -94,6 +94,8 @@ class OnnxCrossEncoderModel(OnnxModel[float]):
|
|
|
94
94
|
providers: Optional[Sequence[OnnxProvider]] = None,
|
|
95
95
|
cuda: bool = False,
|
|
96
96
|
device_ids: Optional[list[int]] = None,
|
|
97
|
+
local_files_only: bool = False,
|
|
98
|
+
specific_model_path: Optional[str] = None,
|
|
97
99
|
**kwargs: Any,
|
|
98
100
|
) -> Iterable[float]:
|
|
99
101
|
is_small = False
|
|
@@ -120,6 +122,8 @@ class OnnxCrossEncoderModel(OnnxModel[float]):
|
|
|
120
122
|
"model_name": model_name,
|
|
121
123
|
"cache_dir": cache_dir,
|
|
122
124
|
"providers": providers,
|
|
125
|
+
"local_files_only": local_files_only,
|
|
126
|
+
"specific_model_path": specific_model_path,
|
|
123
127
|
**kwargs,
|
|
124
128
|
}
|
|
125
129
|
|
|
@@ -115,11 +115,12 @@ class Bm25(SparseTextEmbeddingBase):
|
|
|
115
115
|
model_description = self._get_model_description(model_name)
|
|
116
116
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
117
117
|
|
|
118
|
+
self._specific_model_path = specific_model_path
|
|
118
119
|
self._model_dir = self.download_model(
|
|
119
120
|
model_description,
|
|
120
121
|
self.cache_dir,
|
|
121
122
|
local_files_only=self._local_files_only,
|
|
122
|
-
specific_model_path=
|
|
123
|
+
specific_model_path=self._specific_model_path,
|
|
123
124
|
)
|
|
124
125
|
|
|
125
126
|
self.token_max_length = token_max_length
|
|
@@ -160,6 +161,8 @@ class Bm25(SparseTextEmbeddingBase):
|
|
|
160
161
|
documents: Union[str, Iterable[str]],
|
|
161
162
|
batch_size: int = 256,
|
|
162
163
|
parallel: Optional[int] = None,
|
|
164
|
+
local_files_only: bool = False,
|
|
165
|
+
specific_model_path: Optional[str] = None,
|
|
163
166
|
) -> Iterable[SparseEmbedding]:
|
|
164
167
|
is_small = False
|
|
165
168
|
|
|
@@ -188,6 +191,8 @@ class Bm25(SparseTextEmbeddingBase):
|
|
|
188
191
|
"language": self.language,
|
|
189
192
|
"token_max_length": self.token_max_length,
|
|
190
193
|
"disable_stemmer": self.disable_stemmer,
|
|
194
|
+
"local_files_only": local_files_only,
|
|
195
|
+
"specific_model_path": specific_model_path,
|
|
191
196
|
}
|
|
192
197
|
pool = ParallelWorkerPool(
|
|
193
198
|
num_workers=parallel or 1,
|
|
@@ -226,6 +231,8 @@ class Bm25(SparseTextEmbeddingBase):
|
|
|
226
231
|
documents=documents,
|
|
227
232
|
batch_size=batch_size,
|
|
228
233
|
parallel=parallel,
|
|
234
|
+
local_files_only=self._local_files_only,
|
|
235
|
+
specific_model_path=self._specific_model_path,
|
|
229
236
|
)
|
|
230
237
|
|
|
231
238
|
def _stem(self, tokens: list[str]) -> list[str]:
|
|
@@ -110,11 +110,12 @@ class Bm42(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
110
110
|
self.model_description = self._get_model_description(model_name)
|
|
111
111
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
112
112
|
|
|
113
|
+
self._specific_model_path = specific_model_path
|
|
113
114
|
self._model_dir = self.download_model(
|
|
114
115
|
self.model_description,
|
|
115
116
|
self.cache_dir,
|
|
116
117
|
local_files_only=self._local_files_only,
|
|
117
|
-
specific_model_path=
|
|
118
|
+
specific_model_path=self._specific_model_path,
|
|
118
119
|
)
|
|
119
120
|
|
|
120
121
|
self.invert_vocab: dict[int, str] = {}
|
|
@@ -301,6 +302,8 @@ class Bm42(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
301
302
|
cuda=self.cuda,
|
|
302
303
|
device_ids=self.device_ids,
|
|
303
304
|
alpha=self.alpha,
|
|
305
|
+
local_files_only=self._local_files_only,
|
|
306
|
+
specific_model_path=self._specific_model_path,
|
|
304
307
|
)
|
|
305
308
|
|
|
306
309
|
@classmethod
|
|
@@ -127,11 +127,12 @@ class MiniCOIL(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
127
127
|
|
|
128
128
|
self.model_description = self._get_model_description(model_name)
|
|
129
129
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
130
|
+
self._specific_model_path = specific_model_path
|
|
130
131
|
self._model_dir = self.download_model(
|
|
131
132
|
self.model_description,
|
|
132
133
|
self.cache_dir,
|
|
133
134
|
local_files_only=self._local_files_only,
|
|
134
|
-
specific_model_path=
|
|
135
|
+
specific_model_path=self._specific_model_path,
|
|
135
136
|
)
|
|
136
137
|
|
|
137
138
|
if not self.lazy_load:
|
|
@@ -211,6 +212,9 @@ class MiniCOIL(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
211
212
|
b=self.b,
|
|
212
213
|
avg_len=self.avg_len,
|
|
213
214
|
is_query=False,
|
|
215
|
+
local_files_only=self._local_files_only,
|
|
216
|
+
specific_model_path=self._specific_model_path,
|
|
217
|
+
**kwargs,
|
|
214
218
|
)
|
|
215
219
|
|
|
216
220
|
def query_embed(
|
|
@@ -230,6 +234,9 @@ class MiniCOIL(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
230
234
|
b=self.b,
|
|
231
235
|
avg_len=self.avg_len,
|
|
232
236
|
is_query=True,
|
|
237
|
+
local_files_only=self._local_files_only,
|
|
238
|
+
specific_model_path=self._specific_model_path,
|
|
239
|
+
**kwargs,
|
|
233
240
|
)
|
|
234
241
|
|
|
235
242
|
@classmethod
|
|
@@ -62,7 +62,7 @@ class SparseTextEmbedding(SparseTextEmbeddingBase):
|
|
|
62
62
|
**kwargs: Any,
|
|
63
63
|
):
|
|
64
64
|
super().__init__(model_name, cache_dir, threads, **kwargs)
|
|
65
|
-
if model_name == "prithvida/Splade_PP_en_v1":
|
|
65
|
+
if model_name.lower() == "prithvida/Splade_PP_en_v1".lower():
|
|
66
66
|
warnings.warn(
|
|
67
67
|
"The right spelling is prithivida/Splade_PP_en_v1. "
|
|
68
68
|
"Support of this name will be removed soon, please fix the model_name",
|
|
@@ -114,11 +114,12 @@ class SpladePP(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
114
114
|
self.model_description = self._get_model_description(model_name)
|
|
115
115
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
116
116
|
|
|
117
|
+
self._specific_model_path = specific_model_path
|
|
117
118
|
self._model_dir = self.download_model(
|
|
118
119
|
self.model_description,
|
|
119
120
|
self.cache_dir,
|
|
120
121
|
local_files_only=self._local_files_only,
|
|
121
|
-
specific_model_path=
|
|
122
|
+
specific_model_path=self._specific_model_path,
|
|
122
123
|
)
|
|
123
124
|
|
|
124
125
|
if not self.lazy_load:
|
|
@@ -165,6 +166,8 @@ class SpladePP(SparseTextEmbeddingBase, OnnxTextModel[SparseEmbedding]):
|
|
|
165
166
|
providers=self.providers,
|
|
166
167
|
cuda=self.cuda,
|
|
167
168
|
device_ids=self.device_ids,
|
|
169
|
+
local_files_only=self._local_files_only,
|
|
170
|
+
specific_model_path=self._specific_model_path,
|
|
168
171
|
**kwargs,
|
|
169
172
|
)
|
|
170
173
|
|
|
@@ -77,6 +77,11 @@ class CustomTextEmbedding(OnnxTextEmbedding):
|
|
|
77
77
|
if self._pooling == PoolingType.DISABLED:
|
|
78
78
|
return embeddings
|
|
79
79
|
|
|
80
|
+
raise ValueError(
|
|
81
|
+
f"Unsupported pooling type {self._pooling}. "
|
|
82
|
+
f"Supported types are: {PoolingType.CLS}, {PoolingType.MEAN}, {PoolingType.DISABLED}."
|
|
83
|
+
)
|
|
84
|
+
|
|
80
85
|
def _normalize(self, embeddings: NumpyArray) -> NumpyArray:
|
|
81
86
|
return normalize(embeddings) if self._normalization else embeddings
|
|
82
87
|
|
|
@@ -247,11 +247,12 @@ class OnnxTextEmbedding(TextEmbeddingBase, OnnxTextModel[NumpyArray]):
|
|
|
247
247
|
|
|
248
248
|
self.model_description = self._get_model_description(model_name)
|
|
249
249
|
self.cache_dir = str(define_cache_dir(cache_dir))
|
|
250
|
+
self._specific_model_path = specific_model_path
|
|
250
251
|
self._model_dir = self.download_model(
|
|
251
252
|
self.model_description,
|
|
252
253
|
self.cache_dir,
|
|
253
254
|
local_files_only=self._local_files_only,
|
|
254
|
-
specific_model_path=
|
|
255
|
+
specific_model_path=self._specific_model_path,
|
|
255
256
|
)
|
|
256
257
|
|
|
257
258
|
if not self.lazy_load:
|
|
@@ -288,6 +289,8 @@ class OnnxTextEmbedding(TextEmbeddingBase, OnnxTextModel[NumpyArray]):
|
|
|
288
289
|
providers=self.providers,
|
|
289
290
|
cuda=self.cuda,
|
|
290
291
|
device_ids=self.device_ids,
|
|
292
|
+
local_files_only=self._local_files_only,
|
|
293
|
+
specific_model_path=self._specific_model_path,
|
|
291
294
|
**kwargs,
|
|
292
295
|
)
|
|
293
296
|
|
|
@@ -108,6 +108,8 @@ class OnnxTextModel(OnnxModel[T]):
|
|
|
108
108
|
providers: Optional[Sequence[OnnxProvider]] = None,
|
|
109
109
|
cuda: bool = False,
|
|
110
110
|
device_ids: Optional[list[int]] = None,
|
|
111
|
+
local_files_only: bool = False,
|
|
112
|
+
specific_model_path: Optional[str] = None,
|
|
111
113
|
**kwargs: Any,
|
|
112
114
|
) -> Iterable[T]:
|
|
113
115
|
is_small = False
|
|
@@ -136,6 +138,8 @@ class OnnxTextModel(OnnxModel[T]):
|
|
|
136
138
|
"model_name": model_name,
|
|
137
139
|
"cache_dir": cache_dir,
|
|
138
140
|
"providers": providers,
|
|
141
|
+
"local_files_only": local_files_only,
|
|
142
|
+
"specific_model_path": specific_model_path,
|
|
139
143
|
**kwargs,
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -55,7 +55,7 @@ class TextEmbedding(TextEmbeddingBase):
|
|
|
55
55
|
) -> None:
|
|
56
56
|
registered_models = cls._list_supported_models()
|
|
57
57
|
for registered_model in registered_models:
|
|
58
|
-
if model == registered_model.model:
|
|
58
|
+
if model.lower() == registered_model.model.lower():
|
|
59
59
|
raise ValueError(
|
|
60
60
|
f"Model {model} is already registered in TextEmbedding, if you still want to add this model, "
|
|
61
61
|
f"please use another model name"
|
|
@@ -88,18 +88,18 @@ class TextEmbedding(TextEmbeddingBase):
|
|
|
88
88
|
**kwargs: Any,
|
|
89
89
|
):
|
|
90
90
|
super().__init__(model_name, cache_dir, threads, **kwargs)
|
|
91
|
-
if model_name == "nomic-ai/nomic-embed-text-v1.5-Q":
|
|
91
|
+
if model_name.lower() == "nomic-ai/nomic-embed-text-v1.5-Q".lower():
|
|
92
92
|
warnings.warn(
|
|
93
93
|
"The model 'nomic-ai/nomic-embed-text-v1.5-Q' has been updated on HuggingFace. Please review "
|
|
94
94
|
"the latest documentation on HF and release notes to ensure compatibility with your workflow. ",
|
|
95
95
|
UserWarning,
|
|
96
96
|
stacklevel=2,
|
|
97
97
|
)
|
|
98
|
-
if model_name in {
|
|
99
|
-
"sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
|
|
100
|
-
"thenlper/gte-large",
|
|
101
|
-
"intfloat/multilingual-e5-large",
|
|
102
|
-
"sentence-transformers/paraphrase-multilingual-mpnet-base-v2",
|
|
98
|
+
if model_name.lower() in {
|
|
99
|
+
"sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2".lower(),
|
|
100
|
+
"thenlper/gte-large".lower(),
|
|
101
|
+
"intfloat/multilingual-e5-large".lower(),
|
|
102
|
+
"sentence-transformers/paraphrase-multilingual-mpnet-base-v2".lower(),
|
|
103
103
|
}:
|
|
104
104
|
warnings.warn(
|
|
105
105
|
f"The model {model_name} now uses mean pooling instead of CLS embedding. "
|
|
@@ -128,6 +128,40 @@ class TextEmbedding(TextEmbeddingBase):
|
|
|
128
128
|
"Please check the supported models using `TextEmbedding.list_supported_models()`"
|
|
129
129
|
)
|
|
130
130
|
|
|
131
|
+
@property
|
|
132
|
+
def embedding_size(self) -> int:
|
|
133
|
+
"""Get the embedding size of the current model"""
|
|
134
|
+
if self._embedding_size is None:
|
|
135
|
+
self._embedding_size = self.get_embedding_size(self.model_name)
|
|
136
|
+
return self._embedding_size
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
140
|
+
"""Get the embedding size of the passed model
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
model_name (str): The name of the model to get embedding size for.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
int: The size of the embedding.
|
|
147
|
+
|
|
148
|
+
Raises:
|
|
149
|
+
ValueError: If the model name is not found in the supported models.
|
|
150
|
+
"""
|
|
151
|
+
descriptions = cls._list_supported_models()
|
|
152
|
+
embedding_size: Optional[int] = None
|
|
153
|
+
for description in descriptions:
|
|
154
|
+
if description.model.lower() == model_name.lower():
|
|
155
|
+
embedding_size = description.dim
|
|
156
|
+
break
|
|
157
|
+
if embedding_size is None:
|
|
158
|
+
model_names = [description.model for description in descriptions]
|
|
159
|
+
raise ValueError(
|
|
160
|
+
f"Embedding size for model {model_name} was None. "
|
|
161
|
+
f"Available model names: {model_names}"
|
|
162
|
+
)
|
|
163
|
+
return embedding_size
|
|
164
|
+
|
|
131
165
|
def embed(
|
|
132
166
|
self,
|
|
133
167
|
documents: Union[str, Iterable[str]],
|
|
@@ -17,6 +17,7 @@ class TextEmbeddingBase(ModelManagement[DenseModelDescription]):
|
|
|
17
17
|
self.cache_dir = cache_dir
|
|
18
18
|
self.threads = threads
|
|
19
19
|
self._local_files_only = kwargs.pop("local_files_only", False)
|
|
20
|
+
self._embedding_size: Optional[int] = None
|
|
20
21
|
|
|
21
22
|
def embed(
|
|
22
23
|
self,
|
|
@@ -58,3 +59,13 @@ class TextEmbeddingBase(ModelManagement[DenseModelDescription]):
|
|
|
58
59
|
yield from self.embed([query], **kwargs)
|
|
59
60
|
else:
|
|
60
61
|
yield from self.embed(query, **kwargs)
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def get_embedding_size(cls, model_name: str) -> int:
|
|
65
|
+
"""Returns embedding size of the passed model."""
|
|
66
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def embedding_size(self) -> int:
|
|
70
|
+
"""Returns embedding size for the current model"""
|
|
71
|
+
raise NotImplementedError("Subclasses must implement this method")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "fastembed-gpu"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.1"
|
|
4
4
|
description = "Fast, light, accurate library built for retrieval embedding generation"
|
|
5
5
|
authors = ["Qdrant Team <info@qdrant.tech>", "NirantK <nirant.bits@gmail.com>"]
|
|
6
6
|
license = "Apache License"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/late_interaction_multimodal/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/rerank/cross_encoder/text_cross_encoder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastembed_gpu-0.7.0 → fastembed_gpu-0.7.1}/fastembed/sparse/utils/sparse_vectors_converter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|