fastembed-gpu 0.6.0__tar.gz → 0.6.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.
Files changed (56) hide show
  1. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/PKG-INFO +18 -1
  2. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/README.md +17 -0
  3. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/model_description.py +5 -0
  4. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/model_management.py +3 -1
  5. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/onnx_embedding.py +1 -2
  6. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction/colbert.py +3 -3
  7. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction_multimodal/colpali.py +2 -2
  8. fastembed_gpu-0.6.1/fastembed/rerank/cross_encoder/custom_text_cross_encoder.py +46 -0
  9. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/rerank/cross_encoder/text_cross_encoder.py +38 -1
  10. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/splade_pp.py +2 -2
  11. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/multitask_embedding.py +26 -15
  12. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/onnx_embedding.py +5 -2
  13. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/onnx_text_model.py +1 -1
  14. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/pooled_embedding.py +2 -1
  15. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/pooled_normalized_embedding.py +2 -2
  16. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/pyproject.toml +1 -1
  17. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/LICENSE +0 -0
  18. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/NOTICE +0 -0
  19. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/__init__.py +0 -0
  20. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/__init__.py +0 -0
  21. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/onnx_model.py +0 -0
  22. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/preprocessor_utils.py +0 -0
  23. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/types.py +0 -0
  24. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/common/utils.py +0 -0
  25. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/embedding.py +0 -0
  26. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/__init__.py +0 -0
  27. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/image_embedding.py +0 -0
  28. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/image_embedding_base.py +0 -0
  29. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/onnx_image_model.py +0 -0
  30. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/transform/functional.py +0 -0
  31. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/image/transform/operators.py +0 -0
  32. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction/__init__.py +0 -0
  33. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction/jina_colbert.py +0 -0
  34. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction/late_interaction_embedding_base.py +0 -0
  35. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction/late_interaction_text_embedding.py +0 -0
  36. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction_multimodal/__init__.py +0 -0
  37. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py +0 -0
  38. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding_base.py +0 -0
  39. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/late_interaction_multimodal/onnx_multimodal_model.py +0 -0
  40. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/parallel_processor.py +0 -0
  41. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/py.typed +0 -0
  42. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/rerank/cross_encoder/__init__.py +0 -0
  43. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/rerank/cross_encoder/onnx_text_cross_encoder.py +0 -0
  44. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/rerank/cross_encoder/onnx_text_model.py +0 -0
  45. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/rerank/cross_encoder/text_cross_encoder_base.py +0 -0
  46. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/__init__.py +0 -0
  47. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/bm25.py +0 -0
  48. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/bm42.py +0 -0
  49. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/sparse_embedding_base.py +0 -0
  50. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/sparse_text_embedding.py +0 -0
  51. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/sparse/utils/tokenizer.py +0 -0
  52. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/__init__.py +0 -0
  53. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/clip_embedding.py +0 -0
  54. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/custom_text_embedding.py +0 -0
  55. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/text_embedding.py +0 -0
  56. {fastembed_gpu-0.6.0 → fastembed_gpu-0.6.1}/fastembed/text/text_embedding_base.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fastembed-gpu
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Fast, light, accurate library built for retrieval embedding generation
5
5
  License: Apache License
6
6
  Keywords: vector,embedding,neural,search,qdrant,sentence-transformers
@@ -225,6 +225,23 @@ scores = list(encoder.rerank(query, documents))
225
225
  # [-11.48061752319336, 5.472434997558594]
226
226
  ```
227
227
 
228
+ Text cross encoders can also be extended with models which are not in the list of supported models.
229
+
230
+ ```python
231
+ from fastembed.rerank.cross_encoder import TextCrossEncoder
232
+ from fastembed.common.model_description import ModelSource
233
+
234
+ TextCrossEncoder.add_custom_model(
235
+ model="Xenova/ms-marco-MiniLM-L-4-v2",
236
+ model_file="onnx/model.onnx",
237
+ sources=ModelSource(hf="Xenova/ms-marco-MiniLM-L-4-v2"),
238
+ )
239
+ model = TextCrossEncoder(model_name="Xenova/ms-marco-MiniLM-L-4-v2")
240
+ scores = list(model.rerank_pairs(
241
+ [("What is AI?", "Artificial intelligence is ..."), ("What is ML?", "Machine learning is ..."),]
242
+ ))
243
+ ```
244
+
228
245
  ## ⚡️ FastEmbed on a GPU
229
246
 
230
247
  FastEmbed supports running on GPU devices.
@@ -190,6 +190,23 @@ scores = list(encoder.rerank(query, documents))
190
190
  # [-11.48061752319336, 5.472434997558594]
191
191
  ```
192
192
 
193
+ Text cross encoders can also be extended with models which are not in the list of supported models.
194
+
195
+ ```python
196
+ from fastembed.rerank.cross_encoder import TextCrossEncoder
197
+ from fastembed.common.model_description import ModelSource
198
+
199
+ TextCrossEncoder.add_custom_model(
200
+ model="Xenova/ms-marco-MiniLM-L-4-v2",
201
+ model_file="onnx/model.onnx",
202
+ sources=ModelSource(hf="Xenova/ms-marco-MiniLM-L-4-v2"),
203
+ )
204
+ model = TextCrossEncoder(model_name="Xenova/ms-marco-MiniLM-L-4-v2")
205
+ scores = list(model.rerank_pairs(
206
+ [("What is AI?", "Artificial intelligence is ..."), ("What is ML?", "Machine learning is ..."),]
207
+ ))
208
+ ```
209
+
193
210
  ## ⚡️ FastEmbed on a GPU
194
211
 
195
212
  FastEmbed supports running on GPU devices.
@@ -7,6 +7,11 @@ from typing import Optional, Any
7
7
  class ModelSource:
8
8
  hf: Optional[str] = None
9
9
  url: Optional[str] = None
10
+ _deprecated_tar_struct: bool = False
11
+
12
+ @property
13
+ def deprecated_tar_struct(self) -> bool:
14
+ return self._deprecated_tar_struct
10
15
 
11
16
  def __post_init__(self) -> None:
12
17
  if self.hf is None and self.url is None:
@@ -330,9 +330,10 @@ class ModelManagement(Generic[T]):
330
330
  model_name: str,
331
331
  source_url: str,
332
332
  cache_dir: str,
333
+ deprecated_tar_struct: bool = False,
333
334
  local_files_only: bool = False,
334
335
  ) -> Path:
335
- fast_model_name = f"fast-{model_name.split('/')[-1]}"
336
+ fast_model_name = f"{'fast-' if deprecated_tar_struct else ''}{model_name.split('/')[-1]}"
336
337
  cache_tmp_dir = Path(cache_dir) / "tmp"
337
338
  model_tmp_dir = cache_tmp_dir / fast_model_name
338
339
  model_dir = Path(cache_dir) / fast_model_name
@@ -438,6 +439,7 @@ class ModelManagement(Generic[T]):
438
439
  model.model,
439
440
  str(url_source),
440
441
  str(cache_dir),
442
+ deprecated_tar_struct=model.sources.deprecated_tar_struct,
441
443
  local_files_only=local_files_only,
442
444
  )
443
445
  except Exception:
@@ -1,6 +1,5 @@
1
1
  from typing import Any, Iterable, Optional, Sequence, Type, Union
2
2
 
3
- import numpy as np
4
3
 
5
4
  from fastembed.common.types import NumpyArray
6
5
  from fastembed.common import ImageInput, OnnxProvider
@@ -195,7 +194,7 @@ class OnnxImageEmbedding(ImageEmbeddingBase, OnnxImageModel[NumpyArray]):
195
194
  return onnx_input
196
195
 
197
196
  def _post_process_onnx_output(self, output: OnnxOutputContext) -> Iterable[NumpyArray]:
198
- return normalize(output.model_output).astype(np.float32)
197
+ return normalize(output.model_output)
199
198
 
200
199
 
201
200
  class OnnxImageEmbeddingWorker(ImageEmbeddingWorker[NumpyArray]):
@@ -46,7 +46,7 @@ class Colbert(LateInteractionTextEmbeddingBase, OnnxTextModel[NumpyArray]):
46
46
  self, output: OnnxOutputContext, is_doc: bool = True
47
47
  ) -> Iterable[NumpyArray]:
48
48
  if not is_doc:
49
- return output.model_output.astype(np.float32)
49
+ return output.model_output
50
50
 
51
51
  if output.input_ids is None or output.attention_mask is None:
52
52
  raise ValueError(
@@ -58,11 +58,11 @@ class Colbert(LateInteractionTextEmbeddingBase, OnnxTextModel[NumpyArray]):
58
58
  if token_id in self.skip_list or token_id == self.pad_token_id:
59
59
  output.attention_mask[i, j] = 0
60
60
 
61
- output.model_output *= np.expand_dims(output.attention_mask, 2).astype(np.float32)
61
+ output.model_output *= np.expand_dims(output.attention_mask, 2)
62
62
  norm = np.linalg.norm(output.model_output, ord=2, axis=2, keepdims=True)
63
63
  norm_clamped = np.maximum(norm, 1e-12)
64
64
  output.model_output /= norm_clamped
65
- return output.model_output.astype(np.float32)
65
+ return output.model_output
66
66
 
67
67
  def _preprocess_onnx_input(
68
68
  self, onnx_input: dict[str, NumpyArray], is_doc: bool = True, **kwargs: Any
@@ -142,7 +142,7 @@ class ColPali(LateInteractionMultimodalEmbeddingBase, OnnxMultimodalModel[NumpyA
142
142
  assert self.model_description.dim is not None, "Model dim is not defined"
143
143
  return output.model_output.reshape(
144
144
  output.model_output.shape[0], -1, self.model_description.dim
145
- ).astype(np.float32)
145
+ )
146
146
 
147
147
  def _post_process_onnx_text_output(
148
148
  self,
@@ -157,7 +157,7 @@ class ColPali(LateInteractionMultimodalEmbeddingBase, OnnxMultimodalModel[NumpyA
157
157
  Returns:
158
158
  Iterable[NumpyArray]: Post-processed output as NumPy arrays.
159
159
  """
160
- return output.model_output.astype(np.float32)
160
+ return output.model_output
161
161
 
162
162
  def tokenize(self, documents: list[str], **kwargs: Any) -> list[Encoding]:
163
163
  texts_query: list[str] = []
@@ -0,0 +1,46 @@
1
+ from typing import Optional, Sequence, Any
2
+
3
+ from fastembed.common import OnnxProvider
4
+ from fastembed.common.model_description import BaseModelDescription
5
+ from fastembed.rerank.cross_encoder.onnx_text_cross_encoder import OnnxTextCrossEncoder
6
+
7
+
8
+ class CustomTextCrossEncoder(OnnxTextCrossEncoder):
9
+ SUPPORTED_MODELS: list[BaseModelDescription] = []
10
+
11
+ def __init__(
12
+ self,
13
+ model_name: str,
14
+ cache_dir: Optional[str] = None,
15
+ threads: Optional[int] = None,
16
+ providers: Optional[Sequence[OnnxProvider]] = None,
17
+ cuda: bool = False,
18
+ device_ids: Optional[list[int]] = None,
19
+ lazy_load: bool = False,
20
+ device_id: Optional[int] = None,
21
+ specific_model_path: Optional[str] = None,
22
+ **kwargs: Any,
23
+ ):
24
+ super().__init__(
25
+ model_name=model_name,
26
+ cache_dir=cache_dir,
27
+ threads=threads,
28
+ providers=providers,
29
+ cuda=cuda,
30
+ device_ids=device_ids,
31
+ lazy_load=lazy_load,
32
+ device_id=device_id,
33
+ specific_model_path=specific_model_path,
34
+ **kwargs,
35
+ )
36
+
37
+ @classmethod
38
+ def _list_supported_models(cls) -> list[BaseModelDescription]:
39
+ return cls.SUPPORTED_MODELS
40
+
41
+ @classmethod
42
+ def add_model(
43
+ cls,
44
+ model_description: BaseModelDescription,
45
+ ) -> None:
46
+ cls.SUPPORTED_MODELS.append(model_description)
@@ -3,13 +3,19 @@ from dataclasses import asdict
3
3
 
4
4
  from fastembed.common import OnnxProvider
5
5
  from fastembed.rerank.cross_encoder.onnx_text_cross_encoder import OnnxTextCrossEncoder
6
+ from fastembed.rerank.cross_encoder.custom_text_cross_encoder import CustomTextCrossEncoder
7
+
6
8
  from fastembed.rerank.cross_encoder.text_cross_encoder_base import TextCrossEncoderBase
7
- from fastembed.common.model_description import BaseModelDescription
9
+ from fastembed.common.model_description import (
10
+ ModelSource,
11
+ BaseModelDescription,
12
+ )
8
13
 
9
14
 
10
15
  class TextCrossEncoder(TextCrossEncoderBase):
11
16
  CROSS_ENCODER_REGISTRY: list[Type[TextCrossEncoderBase]] = [
12
17
  OnnxTextCrossEncoder,
18
+ CustomTextCrossEncoder,
13
19
  ]
14
20
 
15
21
  @classmethod
@@ -124,3 +130,34 @@ class TextCrossEncoder(TextCrossEncoderBase):
124
130
  yield from self.model.rerank_pairs(
125
131
  pairs, batch_size=batch_size, parallel=parallel, **kwargs
126
132
  )
133
+
134
+ @classmethod
135
+ def add_custom_model(
136
+ cls,
137
+ model: str,
138
+ sources: ModelSource,
139
+ model_file: str = "onnx/model.onnx",
140
+ description: str = "",
141
+ license: str = "",
142
+ size_in_gb: float = 0.0,
143
+ additional_files: Optional[list[str]] = None,
144
+ ) -> None:
145
+ registered_models = cls._list_supported_models()
146
+ for registered_model in registered_models:
147
+ if model == registered_model.model:
148
+ raise ValueError(
149
+ f"Model {model} is already registered in CrossEncoderModel, if you still want to add this model, "
150
+ f"please use another model name"
151
+ )
152
+
153
+ CustomTextCrossEncoder.add_model(
154
+ BaseModelDescription(
155
+ model=model,
156
+ sources=sources,
157
+ model_file=model_file,
158
+ description=description,
159
+ license=license,
160
+ size_in_GB=size_in_gb,
161
+ additional_files=additional_files or [],
162
+ )
163
+ )
@@ -18,7 +18,7 @@ supported_splade_models: list[SparseModelDescription] = [
18
18
  description="Independent Implementation of SPLADE++ Model for English.",
19
19
  license="apache-2.0",
20
20
  size_in_GB=0.532,
21
- sources=ModelSource(hf="Qdrant/SPLADE_PP_en_v1"),
21
+ sources=ModelSource(hf="Qdrant/Splade_PP_en_v1"),
22
22
  model_file="model.onnx",
23
23
  ),
24
24
  SparseModelDescription(
@@ -27,7 +27,7 @@ supported_splade_models: list[SparseModelDescription] = [
27
27
  description="Independent Implementation of SPLADE++ Model for English.",
28
28
  license="apache-2.0",
29
29
  size_in_GB=0.532,
30
- sources=ModelSource(hf="Qdrant/SPLADE_PP_en_v1"),
30
+ sources=ModelSource(hf="Qdrant/Splade_PP_en_v1"),
31
31
  model_file="model.onnx",
32
32
  ),
33
33
  ]
@@ -3,6 +3,7 @@ from typing import Any, Type, Iterable, Union, Optional
3
3
 
4
4
  import numpy as np
5
5
 
6
+ from fastembed.common.onnx_model import OnnxOutputContext
6
7
  from fastembed.common.types import NumpyArray
7
8
  from fastembed.text.pooled_normalized_embedding import PooledNormalizedEmbedding
8
9
  from fastembed.text.onnx_embedding import OnnxTextEmbeddingWorker
@@ -44,9 +45,11 @@ class JinaEmbeddingV3(PooledNormalizedEmbedding):
44
45
  PASSAGE_TASK = Task.RETRIEVAL_PASSAGE
45
46
  QUERY_TASK = Task.RETRIEVAL_QUERY
46
47
 
47
- def __init__(self, *args: Any, **kwargs: Any):
48
+ def __init__(self, *args: Any, task_id: Optional[int] = None, **kwargs: Any):
48
49
  super().__init__(*args, **kwargs)
49
- self.current_task_id: Union[Task, int] = self.PASSAGE_TASK
50
+ self.default_task_id: Union[Task, int] = (
51
+ task_id if task_id is not None else self.PASSAGE_TASK
52
+ )
50
53
 
51
54
  @classmethod
52
55
  def _get_worker_class(cls) -> Type[OnnxTextEmbeddingWorker]:
@@ -57,9 +60,14 @@ class JinaEmbeddingV3(PooledNormalizedEmbedding):
57
60
  return supported_multitask_models
58
61
 
59
62
  def _preprocess_onnx_input(
60
- self, onnx_input: dict[str, NumpyArray], **kwargs: Any
63
+ self,
64
+ onnx_input: dict[str, NumpyArray],
65
+ task_id: Optional[Union[int, Task]] = None,
66
+ **kwargs: Any,
61
67
  ) -> dict[str, NumpyArray]:
62
- onnx_input["task_id"] = np.array(self.current_task_id, dtype=np.int64)
68
+ if task_id is None:
69
+ raise ValueError(f"task_id must be provided for JinaEmbeddingV3, got <{task_id}>")
70
+ onnx_input["task_id"] = np.array(task_id, dtype=np.int64)
63
71
  return onnx_input
64
72
 
65
73
  def embed(
@@ -67,20 +75,19 @@ class JinaEmbeddingV3(PooledNormalizedEmbedding):
67
75
  documents: Union[str, Iterable[str]],
68
76
  batch_size: int = 256,
69
77
  parallel: Optional[int] = None,
70
- task_id: int = PASSAGE_TASK,
78
+ task_id: Optional[int] = None,
71
79
  **kwargs: Any,
72
80
  ) -> Iterable[NumpyArray]:
73
- self.current_task_id = task_id
74
- kwargs["task_id"] = task_id
75
- yield from super().embed(documents, batch_size, parallel, **kwargs)
81
+ task_id = (
82
+ task_id if task_id is not None else self.default_task_id
83
+ ) # required for multiprocessing
84
+ yield from super().embed(documents, batch_size, parallel, task_id=task_id, **kwargs)
76
85
 
77
86
  def query_embed(self, query: Union[str, Iterable[str]], **kwargs: Any) -> Iterable[NumpyArray]:
78
- self.current_task_id = self.QUERY_TASK
79
- yield from super().embed(query, **kwargs)
87
+ yield from super().embed(query, task_id=self.QUERY_TASK, **kwargs)
80
88
 
81
89
  def passage_embed(self, texts: Iterable[str], **kwargs: Any) -> Iterable[NumpyArray]:
82
- self.current_task_id = self.PASSAGE_TASK
83
- yield from super().embed(texts, **kwargs)
90
+ yield from super().embed(texts, task_id=self.PASSAGE_TASK, **kwargs)
84
91
 
85
92
 
86
93
  class JinaEmbeddingV3Worker(OnnxTextEmbeddingWorker):
@@ -90,11 +97,15 @@ class JinaEmbeddingV3Worker(OnnxTextEmbeddingWorker):
90
97
  cache_dir: str,
91
98
  **kwargs: Any,
92
99
  ) -> JinaEmbeddingV3:
93
- model = JinaEmbeddingV3(
100
+ return JinaEmbeddingV3(
94
101
  model_name=model_name,
95
102
  cache_dir=cache_dir,
96
103
  threads=1,
97
104
  **kwargs,
98
105
  )
99
- model.current_task_id = kwargs["task_id"]
100
- return model
106
+
107
+ def process(self, items: Iterable[tuple[int, Any]]) -> Iterable[tuple[int, OnnxOutputContext]]:
108
+ self.model: JinaEmbeddingV3 # mypy complaints `self.model` does not have `default_task_id`
109
+ for idx, batch in items:
110
+ onnx_output = self.model.onnx_embed(batch, task_id=self.model.default_task_id)
111
+ yield idx, onnx_output
@@ -1,6 +1,5 @@
1
1
  from typing import Any, Iterable, Optional, Sequence, Type, Union
2
2
 
3
- import numpy as np
4
3
  from fastembed.common.types import NumpyArray, OnnxProvider
5
4
  from fastembed.common.onnx_model import OnnxOutputContext
6
5
  from fastembed.common.utils import define_cache_dir, normalize
@@ -21,6 +20,7 @@ supported_onnx_models: list[DenseModelDescription] = [
21
20
  sources=ModelSource(
22
21
  hf="Qdrant/fast-bge-base-en",
23
22
  url="https://storage.googleapis.com/qdrant-fastembed/fast-bge-base-en.tar.gz",
23
+ _deprecated_tar_struct=True,
24
24
  ),
25
25
  model_file="model_optimized.onnx",
26
26
  ),
@@ -36,6 +36,7 @@ supported_onnx_models: list[DenseModelDescription] = [
36
36
  sources=ModelSource(
37
37
  hf="qdrant/bge-base-en-v1.5-onnx-q",
38
38
  url="https://storage.googleapis.com/qdrant-fastembed/fast-bge-base-en-v1.5.tar.gz",
39
+ _deprecated_tar_struct=True,
39
40
  ),
40
41
  model_file="model_optimized.onnx",
41
42
  ),
@@ -63,6 +64,7 @@ supported_onnx_models: list[DenseModelDescription] = [
63
64
  sources=ModelSource(
64
65
  hf="Qdrant/bge-small-en",
65
66
  url="https://storage.googleapis.com/qdrant-fastembed/BAAI-bge-small-en.tar.gz",
67
+ _deprecated_tar_struct=True,
66
68
  ),
67
69
  model_file="model_optimized.onnx",
68
70
  ),
@@ -90,6 +92,7 @@ supported_onnx_models: list[DenseModelDescription] = [
90
92
  sources=ModelSource(
91
93
  hf="Qdrant/bge-small-zh-v1.5",
92
94
  url="https://storage.googleapis.com/qdrant-fastembed/fast-bge-small-zh-v1.5.tar.gz",
95
+ _deprecated_tar_struct=True,
93
96
  ),
94
97
  model_file="model_optimized.onnx",
95
98
  ),
@@ -309,7 +312,7 @@ class OnnxTextEmbedding(TextEmbeddingBase, OnnxTextModel[NumpyArray]):
309
312
  processed_embeddings = embeddings
310
313
  else:
311
314
  raise ValueError(f"Unsupported embedding shape: {embeddings.shape}")
312
- return normalize(processed_embeddings).astype(np.float32)
315
+ return normalize(processed_embeddings)
313
316
 
314
317
  def load_onnx_model(self) -> None:
315
318
  self._load_onnx_model(
@@ -115,7 +115,7 @@ class OnnxTextModel(OnnxModel[T]):
115
115
  if not hasattr(self, "model") or self.model is None:
116
116
  self.load_onnx_model()
117
117
  for batch in iter_batch(documents, batch_size):
118
- yield from self._post_process_onnx_output(self.onnx_embed(batch))
118
+ yield from self._post_process_onnx_output(self.onnx_embed(batch, **kwargs))
119
119
  else:
120
120
  if parallel == 0:
121
121
  parallel = os.cpu_count()
@@ -82,6 +82,7 @@ supported_pooled_models: list[DenseModelDescription] = [
82
82
  sources=ModelSource(
83
83
  hf="qdrant/multilingual-e5-large-onnx",
84
84
  url="https://storage.googleapis.com/qdrant-fastembed/fast-multilingual-e5-large.tar.gz",
85
+ _deprecated_tar_struct=True,
85
86
  ),
86
87
  model_file="model.onnx",
87
88
  additional_files=["model.onnx_data"],
@@ -115,7 +116,7 @@ class PooledEmbedding(OnnxTextEmbedding):
115
116
 
116
117
  embeddings = output.model_output
117
118
  attn_mask = output.attention_mask
118
- return self.mean_pooling(embeddings, attn_mask).astype(np.float32)
119
+ return self.mean_pooling(embeddings, attn_mask)
119
120
 
120
121
 
121
122
  class PooledEmbeddingWorker(OnnxTextEmbeddingWorker):
@@ -1,6 +1,5 @@
1
1
  from typing import Any, Iterable, Type
2
2
 
3
- import numpy as np
4
3
 
5
4
  from fastembed.common.types import NumpyArray
6
5
  from fastembed.common.onnx_model import OnnxOutputContext
@@ -22,6 +21,7 @@ supported_pooled_normalized_models: list[DenseModelDescription] = [
22
21
  sources=ModelSource(
23
22
  url="https://storage.googleapis.com/qdrant-fastembed/sentence-transformers-all-MiniLM-L6-v2.tar.gz",
24
23
  hf="qdrant/all-MiniLM-L6-v2-onnx",
24
+ _deprecated_tar_struct=True,
25
25
  ),
26
26
  model_file="model.onnx",
27
27
  ),
@@ -144,7 +144,7 @@ class PooledNormalizedEmbedding(PooledEmbedding):
144
144
 
145
145
  embeddings = output.model_output
146
146
  attn_mask = output.attention_mask
147
- return normalize(self.mean_pooling(embeddings, attn_mask)).astype(np.float32)
147
+ return normalize(self.mean_pooling(embeddings, attn_mask))
148
148
 
149
149
 
150
150
  class PooledNormalizedEmbeddingWorker(OnnxTextEmbeddingWorker):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "fastembed-gpu"
3
- version = "0.6.0"
3
+ version = "0.6.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