fastembed-gpu 0.5.1__py3-none-any.whl

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 (47) hide show
  1. fastembed/__init__.py +20 -0
  2. fastembed/common/__init__.py +3 -0
  3. fastembed/common/model_management.py +301 -0
  4. fastembed/common/onnx_model.py +132 -0
  5. fastembed/common/preprocessor_utils.py +82 -0
  6. fastembed/common/types.py +16 -0
  7. fastembed/common/utils.py +55 -0
  8. fastembed/embedding.py +24 -0
  9. fastembed/image/__init__.py +3 -0
  10. fastembed/image/image_embedding.py +97 -0
  11. fastembed/image/image_embedding_base.py +44 -0
  12. fastembed/image/onnx_embedding.py +211 -0
  13. fastembed/image/onnx_image_model.py +131 -0
  14. fastembed/image/transform/functional.py +150 -0
  15. fastembed/image/transform/operators.py +268 -0
  16. fastembed/late_interaction/__init__.py +5 -0
  17. fastembed/late_interaction/colbert.py +256 -0
  18. fastembed/late_interaction/jina_colbert.py +62 -0
  19. fastembed/late_interaction/late_interaction_embedding_base.py +62 -0
  20. fastembed/late_interaction/late_interaction_text_embedding.py +114 -0
  21. fastembed/parallel_processor.py +252 -0
  22. fastembed/rerank/cross_encoder/__init__.py +3 -0
  23. fastembed/rerank/cross_encoder/onnx_text_cross_encoder.py +224 -0
  24. fastembed/rerank/cross_encoder/onnx_text_model.py +150 -0
  25. fastembed/rerank/cross_encoder/text_cross_encoder.py +120 -0
  26. fastembed/rerank/cross_encoder/text_cross_encoder_base.py +58 -0
  27. fastembed/sparse/__init__.py +4 -0
  28. fastembed/sparse/bm25.py +347 -0
  29. fastembed/sparse/bm42.py +340 -0
  30. fastembed/sparse/sparse_embedding_base.py +83 -0
  31. fastembed/sparse/sparse_text_embedding.py +121 -0
  32. fastembed/sparse/splade_pp.py +180 -0
  33. fastembed/sparse/utils/tokenizer.py +120 -0
  34. fastembed/text/__init__.py +3 -0
  35. fastembed/text/clip_embedding.py +54 -0
  36. fastembed/text/e5_onnx_embedding.py +72 -0
  37. fastembed/text/onnx_embedding.py +333 -0
  38. fastembed/text/onnx_text_model.py +145 -0
  39. fastembed/text/pooled_embedding.py +92 -0
  40. fastembed/text/pooled_normalized_embedding.py +125 -0
  41. fastembed/text/text_embedding.py +107 -0
  42. fastembed/text/text_embedding_base.py +62 -0
  43. fastembed_gpu-0.5.1.dist-info/LICENSE +201 -0
  44. fastembed_gpu-0.5.1.dist-info/METADATA +262 -0
  45. fastembed_gpu-0.5.1.dist-info/NOTICE +14 -0
  46. fastembed_gpu-0.5.1.dist-info/RECORD +47 -0
  47. fastembed_gpu-0.5.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.3
2
+ Name: fastembed-gpu
3
+ Version: 0.5.1
4
+ Summary: Fast, light, accurate library built for retrieval embedding generation
5
+ License: Apache License
6
+ Keywords: vector,embedding,neural,search,qdrant,sentence-transformers
7
+ Author: Qdrant Team
8
+ Author-email: info@qdrant.tech
9
+ Requires-Python: >=3.9.0
10
+ Classifier: License :: Other/Proprietary License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Dist: huggingface-hub (>=0.20,<1.0)
18
+ Requires-Dist: loguru (>=0.7.2,<0.8.0)
19
+ Requires-Dist: mmh3 (>=4.1.0,<5.0.0)
20
+ Requires-Dist: numpy (>=1.21) ; python_version >= "3.10" and python_version < "3.12"
21
+ Requires-Dist: numpy (>=1.21,<2.1.0) ; python_version < "3.10"
22
+ Requires-Dist: numpy (>=1.26) ; python_version >= "3.12" and python_version < "3.13"
23
+ Requires-Dist: numpy (>=2.1.0) ; python_version >= "3.13"
24
+ Requires-Dist: onnxruntime-gpu (>1.20.0) ; python_version >= "3.13"
25
+ Requires-Dist: onnxruntime-gpu (>=1.17.0,!=1.20.0) ; python_version >= "3.10" and python_version < "3.13"
26
+ Requires-Dist: onnxruntime-gpu (>=1.17.0,<1.20.0) ; python_version < "3.10"
27
+ Requires-Dist: pillow (>=10.3.0,<11.0.0)
28
+ Requires-Dist: py-rust-stemmers (>=0.1.0,<0.2.0)
29
+ Requires-Dist: requests (>=2.31,<3.0)
30
+ Requires-Dist: tokenizers (>=0.15,<1.0)
31
+ Requires-Dist: tqdm (>=4.66,<5.0)
32
+ Project-URL: Homepage, https://github.com/qdrant/fastembed
33
+ Project-URL: Repository, https://github.com/qdrant/fastembed
34
+ Description-Content-Type: text/markdown
35
+
36
+ # ⚡️ What is FastEmbed?
37
+
38
+ FastEmbed is a lightweight, fast, Python library built for embedding generation. We [support popular text models](https://qdrant.github.io/fastembed/examples/Supported_Models/). Please [open a GitHub issue](https://github.com/qdrant/fastembed/issues/new) if you want us to add a new model.
39
+
40
+ The default text embedding (`TextEmbedding`) model is Flag Embedding, presented in the [MTEB](https://huggingface.co/spaces/mteb/leaderboard) leaderboard. It supports "query" and "passage" prefixes for the input text. Here is an example for [Retrieval Embedding Generation](https://qdrant.github.io/fastembed/qdrant/Retrieval_with_FastEmbed/) and how to use [FastEmbed with Qdrant](https://qdrant.github.io/fastembed/qdrant/Usage_With_Qdrant/).
41
+
42
+ ## 📈 Why FastEmbed?
43
+
44
+ 1. Light: FastEmbed is a lightweight library with few external dependencies. We don't require a GPU and don't download GBs of PyTorch dependencies, and instead use the ONNX Runtime. This makes it a great candidate for serverless runtimes like AWS Lambda.
45
+
46
+ 2. Fast: FastEmbed is designed for speed. We use the ONNX Runtime, which is faster than PyTorch. We also use data parallelism for encoding large datasets.
47
+
48
+ 3. Accurate: FastEmbed is better than OpenAI Ada-002. We also [support](https://qdrant.github.io/fastembed/examples/Supported_Models/) an ever-expanding set of models, including a few multilingual models.
49
+
50
+ ## 🚀 Installation
51
+
52
+ To install the FastEmbed library, pip works best. You can install it with or without GPU support:
53
+
54
+ ```bash
55
+ pip install fastembed
56
+
57
+ # or with GPU support
58
+
59
+ pip install fastembed-gpu
60
+ ```
61
+
62
+ ## 📖 Quickstart
63
+
64
+ ```python
65
+ from fastembed import TextEmbedding
66
+
67
+
68
+ # Example list of documents
69
+ documents: list[str] = [
70
+ "This is built to be faster and lighter than other embedding libraries e.g. Transformers, Sentence-Transformers, etc.",
71
+ "fastembed is supported by and maintained by Qdrant.",
72
+ ]
73
+
74
+ # This will trigger the model download and initialization
75
+ embedding_model = TextEmbedding()
76
+ print("The model BAAI/bge-small-en-v1.5 is ready to use.")
77
+
78
+ embeddings_generator = embedding_model.embed(documents) # reminder this is a generator
79
+ embeddings_list = list(embedding_model.embed(documents))
80
+ # you can also convert the generator to a list, and that to a numpy array
81
+ len(embeddings_list[0]) # Vector of 384 dimensions
82
+ ```
83
+
84
+ Fastembed supports a variety of models for different tasks and modalities.
85
+ The list of all the available models can be found [here](https://qdrant.github.io/fastembed/examples/Supported_Models/)
86
+ ### 🎒 Dense text embeddings
87
+
88
+ ```python
89
+ from fastembed import TextEmbedding
90
+
91
+ model = TextEmbedding(model_name="BAAI/bge-small-en-v1.5")
92
+ embeddings = list(model.embed(documents))
93
+
94
+ # [
95
+ # array([-0.1115, 0.0097, 0.0052, 0.0195, ...], dtype=float32),
96
+ # array([-0.1019, 0.0635, -0.0332, 0.0522, ...], dtype=float32)
97
+ # ]
98
+
99
+ ```
100
+
101
+
102
+
103
+ ### 🔱 Sparse text embeddings
104
+
105
+ * SPLADE++
106
+
107
+ ```python
108
+ from fastembed import SparseTextEmbedding
109
+
110
+ model = SparseTextEmbedding(model_name="prithivida/Splade_PP_en_v1")
111
+ embeddings = list(model.embed(documents))
112
+
113
+ # [
114
+ # SparseEmbedding(indices=[ 17, 123, 919, ... ], values=[0.71, 0.22, 0.39, ...]),
115
+ # SparseEmbedding(indices=[ 38, 12, 91, ... ], values=[0.11, 0.22, 0.39, ...])
116
+ # ]
117
+ ```
118
+
119
+ <!--
120
+ * BM42 - ([link](ToDo))
121
+
122
+ ```
123
+ from fastembed import SparseTextEmbedding
124
+
125
+ model = SparseTextEmbedding(model_name="Qdrant/bm42-all-minilm-l6-v2-attentions")
126
+ embeddings = list(model.embed(documents))
127
+
128
+ # [
129
+ # SparseEmbedding(indices=[ 17, 123, 919, ... ], values=[0.71, 0.22, 0.39, ...]),
130
+ # SparseEmbedding(indices=[ 38, 12, 91, ... ], values=[0.11, 0.22, 0.39, ...])
131
+ # ]
132
+ ```
133
+ -->
134
+
135
+ ### 🦥 Late interaction models (aka ColBERT)
136
+
137
+
138
+ ```python
139
+ from fastembed import LateInteractionTextEmbedding
140
+
141
+ model = LateInteractionTextEmbedding(model_name="colbert-ir/colbertv2.0")
142
+ embeddings = list(model.embed(documents))
143
+
144
+ # [
145
+ # array([
146
+ # [-0.1115, 0.0097, 0.0052, 0.0195, ...],
147
+ # [-0.1019, 0.0635, -0.0332, 0.0522, ...],
148
+ # ]),
149
+ # array([
150
+ # [-0.9019, 0.0335, -0.0032, 0.0991, ...],
151
+ # [-0.2115, 0.8097, 0.1052, 0.0195, ...],
152
+ # ]),
153
+ # ]
154
+ ```
155
+
156
+ ### 🖼️ Image embeddings
157
+
158
+ ```python
159
+ from fastembed import ImageEmbedding
160
+
161
+ images = [
162
+ "./path/to/image1.jpg",
163
+ "./path/to/image2.jpg",
164
+ ]
165
+
166
+ model = ImageEmbedding(model_name="Qdrant/clip-ViT-B-32-vision")
167
+ embeddings = list(model.embed(images))
168
+
169
+ # [
170
+ # array([-0.1115, 0.0097, 0.0052, 0.0195, ...], dtype=float32),
171
+ # array([-0.1019, 0.0635, -0.0332, 0.0522, ...], dtype=float32)
172
+ # ]
173
+ ```
174
+
175
+ ### 🔄 Rerankers
176
+ ```python
177
+ from fastembed.rerank.cross_encoder import TextCrossEncoder
178
+
179
+ query = "Who is maintaining Qdrant?"
180
+ documents: list[str] = [
181
+ "This is built to be faster and lighter than other embedding libraries e.g. Transformers, Sentence-Transformers, etc.",
182
+ "fastembed is supported by and maintained by Qdrant.",
183
+ ]
184
+ encoder = TextCrossEncoder(model_name="Xenova/ms-marco-MiniLM-L-6-v2")
185
+ scores = list(encoder.rerank(query, documents))
186
+
187
+ # [-11.48061752319336, 5.472434997558594]
188
+ ```
189
+
190
+ ## ⚡️ FastEmbed on a GPU
191
+
192
+ FastEmbed supports running on GPU devices.
193
+ It requires installation of the `fastembed-gpu` package.
194
+
195
+ ```bash
196
+ pip install fastembed-gpu
197
+ ```
198
+
199
+ Check our [example](https://qdrant.github.io/fastembed/examples/FastEmbed_GPU/) for detailed instructions, CUDA 12.x support and troubleshooting of the common issues.
200
+
201
+ ```python
202
+ from fastembed import TextEmbedding
203
+
204
+ embedding_model = TextEmbedding(
205
+ model_name="BAAI/bge-small-en-v1.5",
206
+ providers=["CUDAExecutionProvider"]
207
+ )
208
+ print("The model BAAI/bge-small-en-v1.5 is ready to use on a GPU.")
209
+
210
+ ```
211
+
212
+ ## Usage with Qdrant
213
+
214
+ Installation with Qdrant Client in Python:
215
+
216
+ ```bash
217
+ pip install qdrant-client[fastembed]
218
+ ```
219
+
220
+ or
221
+
222
+ ```bash
223
+ pip install qdrant-client[fastembed-gpu]
224
+ ```
225
+
226
+ You might have to use quotes ```pip install 'qdrant-client[fastembed]'``` on zsh.
227
+
228
+ ```python
229
+ from qdrant_client import QdrantClient
230
+
231
+ # Initialize the client
232
+ client = QdrantClient("localhost", port=6333) # For production
233
+ # client = QdrantClient(":memory:") # For small experiments
234
+
235
+ # Prepare your documents, metadata, and IDs
236
+ docs = ["Qdrant has Langchain integrations", "Qdrant also has Llama Index integrations"]
237
+ metadata = [
238
+ {"source": "Langchain-docs"},
239
+ {"source": "Llama-index-docs"},
240
+ ]
241
+ ids = [42, 2]
242
+
243
+ # If you want to change the model:
244
+ # client.set_model("sentence-transformers/all-MiniLM-L6-v2")
245
+ # List of supported models: https://qdrant.github.io/fastembed/examples/Supported_Models
246
+
247
+ # Use the new add() instead of upsert()
248
+ # This internally calls embed() of the configured embedding model
249
+ client.add(
250
+ collection_name="demo_collection",
251
+ documents=docs,
252
+ metadata=metadata,
253
+ ids=ids
254
+ )
255
+
256
+ search_result = client.query(
257
+ collection_name="demo_collection",
258
+ query_text="This is a query document"
259
+ )
260
+ print(search_result)
261
+ ```
262
+
@@ -0,0 +1,14 @@
1
+ Copyright 2024 Qdrant
2
+
3
+ This product includes software developed by Qdrant
4
+
5
+ This distribution includes the following Jina AI models, each with its respective license:
6
+ - jinaai/jina-colbert-v2
7
+ - License: cc-by-nc-4.0
8
+ - jinaai/jina-reranker-v2-base-multilingual
9
+ - License: cc-by-nc-4.0
10
+
11
+ These models are developed by Jina (https://jina.ai/) and are subject to Jina AI's licensing terms.
12
+
13
+ Additional Notes:
14
+ This project also includes third-party libraries with their respective licenses. Please refer to the documentation of each library for details regarding its usage and licensing terms.
@@ -0,0 +1,47 @@
1
+ fastembed/__init__.py,sha256=yvbEcZ02gISaHABht6wKK-vNrXKJs_w0dNPJzU6ZJCw,582
2
+ fastembed/common/__init__.py,sha256=iD2VNgUkOTWLDtqrM3m5ZO_cMv4uqJ2hmEoGOYfU2h8,148
3
+ fastembed/common/model_management.py,sha256=M_CZ3qEHRr7ODlhLHhBu9421tTUzzoD8M7neUjW8GNw,10752
4
+ fastembed/common/onnx_model.py,sha256=XlUVmIjW-JuCeNtyCQ-hWWszMLUAQ8yCnx4MA4Q8634,4681
5
+ fastembed/common/preprocessor_utils.py,sha256=7AtbogjuKUqOJjpLV_rbPHBdHRB8gje2HrewQGj0Nek,3174
6
+ fastembed/common/types.py,sha256=MKNVj2YEHnNgea0QYWTHsYs_AYdZ6E29-xW0fnnBMDw,450
7
+ fastembed/common/utils.py,sha256=PXGYQC3FzAQZXZAeAkN_cWj4KWVH4GdP5q9TBT5EfHQ,1539
8
+ fastembed/embedding.py,sha256=HeG031cG03UebIstWRDxjYwCq3oqK_JHFHlyeMAroSw,604
9
+ fastembed/image/__init__.py,sha256=YQ3NHSIW1ufR5iEaBzzJ1cVeOIFE5O6TpfdNKtWrbvg,89
10
+ fastembed/image/image_embedding.py,sha256=svqrJn0Jp8mw2SMp0F6ZHek8NI1oNpJiDu5nZgu6olo,3565
11
+ fastembed/image/image_embedding_base.py,sha256=zf5jYw9TEQbu-4eaQLBF_NFLya52KUU8ZO--Zxhvb18,1408
12
+ fastembed/image/onnx_embedding.py,sha256=Jx48aS55sKHlJTkIWVeJNxCmSRaoAevs1iFLARUQEyk,7691
13
+ fastembed/image/onnx_image_model.py,sha256=AgQyeYd_nteXeyXqhOiJysgph5h7CXf2nCcBLOMgtuQ,4570
14
+ fastembed/image/transform/functional.py,sha256=Uk1Ps3w0FYMVHoBVpngt881oILCUvPLeeesVhvjkir8,4296
15
+ fastembed/image/transform/operators.py,sha256=1Amzd-OlYLKZ_BZb60JbMtbgoxqFz98mHJRiMFMOCIw,9854
16
+ fastembed/late_interaction/__init__.py,sha256=-Bi1ZtgzgpbFm9bpd5V3QcJROF4cOgyiZlEHl--zQSg,153
17
+ fastembed/late_interaction/colbert.py,sha256=Zkjw6_jj2ubWosMtd2RX-Xb2dvbNjIwCelHQ_3dk0EM,10292
18
+ fastembed/late_interaction/jina_colbert.py,sha256=flmLSbFtR3wJikN9s4_eaW4EQL5dffl2F7VpZxxznlc,1959
19
+ fastembed/late_interaction/late_interaction_embedding_base.py,sha256=U_yrFurIX_CC2KdKjprCxtksxNSH1ywmsBqsW_ovrs8,1919
20
+ fastembed/late_interaction/late_interaction_text_embedding.py,sha256=B_tW1wMwbu9IyEQ-1jh3DP5zcbaZ3HGqYrOcaK34B10,4217
21
+ fastembed/parallel_processor.py,sha256=A050kBiKlfGGAc3-jB7fhUpCY5kEChFtR9ynaeYvYzk,9045
22
+ fastembed/rerank/cross_encoder/__init__.py,sha256=3AS7tS1WALEOJmNId9Xxk1BwI-x0fJKHFSVyJpSJvkc,111
23
+ fastembed/rerank/cross_encoder/onnx_text_cross_encoder.py,sha256=aLCyDbkogwQ53fYODaB3azkUj4BJinXaqsCYks908vk,8384
24
+ fastembed/rerank/cross_encoder/onnx_text_model.py,sha256=UwWPrTwNj8UamYN6sTLjGzBK2yhJWqfG7MFTOJ5WzmA,5445
25
+ fastembed/rerank/cross_encoder/text_cross_encoder.py,sha256=m3Rcnoim95ms5RTPMyxRIFX5EA3xI7fLwFqtnub4JFY,4702
26
+ fastembed/rerank/cross_encoder/text_cross_encoder_base.py,sha256=XP7XRnM2bgPhqFQYIF_FLWKguNHZrR3YCulvDctP-0o,2121
27
+ fastembed/sparse/__init__.py,sha256=GeUoN_fpiBPoqkO1cOITxf8po0lVdcPV07CEfELsUI0,192
28
+ fastembed/sparse/bm25.py,sha256=JYvXGg2-_M2cFjddGicM442JR5YGDh0_l8jWb_2KGTk,11571
29
+ fastembed/sparse/bm42.py,sha256=p1o9IrJc0skwqHwlyRsn3oPcc9nkteD9rclc6ygXrVs,13288
30
+ fastembed/sparse/sparse_embedding_base.py,sha256=pBDgKmLd90h3ShAdi0pOzUE3OdHhSibFIPmQYpL9mo4,2607
31
+ fastembed/sparse/sparse_text_embedding.py,sha256=RCLqNZQy_VLT441cZniA4l-ris0yse141rzBvkrBrFw,4466
32
+ fastembed/sparse/splade_pp.py,sha256=hc67-oB-_TyG-2LawBmH6E0aibZ1Y_I2vryTtjOtNvo,7041
33
+ fastembed/sparse/utils/tokenizer.py,sha256=5bgI72YyqolTYufXxsCiuZP1jcIXMqD1oCaNaAxrPwY,3868
34
+ fastembed/text/__init__.py,sha256=5_J8_ASHoG-LrVFvJ_F5ow56PHv5i9j4sziAyxMqKdk,85
35
+ fastembed/text/clip_embedding.py,sha256=xbqj508dXXdKoaby15s4Y7xFndw1A6fKGLDDiOGwPBQ,1611
36
+ fastembed/text/e5_onnx_embedding.py,sha256=F_uJD3OL5VMpT5QcmZhioyBwBPB1DRn9kWQgyQ8lGoQ,2361
37
+ fastembed/text/onnx_embedding.py,sha256=0sonH355K7zvXuxXE9I7BlHMWFQButiRngLxin0WUek,13186
38
+ fastembed/text/onnx_text_model.py,sha256=ZRwAhSB4rsM9KhNq6pbZZgkfgndDNbqtKzNrhrQduvc,5169
39
+ fastembed/text/pooled_embedding.py,sha256=h91VqsEaAkb0sSdEJqvvYNWaF7lh8vBCT2How5aA4eU,3390
40
+ fastembed/text/pooled_normalized_embedding.py,sha256=ZdWNYVswdyn9z2RGfMKhPJTM3EW3V1ou70w09sh3Hiw,5189
41
+ fastembed/text/text_embedding.py,sha256=fGw07_vabsuEdC6r1tJUaDvD-fuc05YGaW1vWf0ir1w,4130
42
+ fastembed/text/text_embedding_base.py,sha256=eMz-3FOSv8gP2eRylAtfJD-Duc6n7lbZQEw7giY61gM,1904
43
+ fastembed_gpu-0.5.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
44
+ fastembed_gpu-0.5.1.dist-info/METADATA,sha256=HUPqlLMn4Ut2zamUYyVknpvmhGCc32_J42LG8n2S2xQ,8538
45
+ fastembed_gpu-0.5.1.dist-info/NOTICE,sha256=9YiH-TydSDnhGoP8pxZZpHa0kdEEoeAfggFq9qO4TmM,595
46
+ fastembed_gpu-0.5.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
47
+ fastembed_gpu-0.5.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.0.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any