fastembed-gpu 0.2.7__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.
- fastembed/__init__.py +12 -0
- fastembed/common/__init__.py +3 -0
- fastembed/common/model_management.py +244 -0
- fastembed/common/models.py +54 -0
- fastembed/common/onnx_model.py +165 -0
- fastembed/common/utils.py +33 -0
- fastembed/embedding.py +24 -0
- fastembed/image/__init__.py +0 -0
- fastembed/parallel_processor.py +209 -0
- fastembed/sparse/__init__.py +4 -0
- fastembed/sparse/sparse_embedding_base.py +44 -0
- fastembed/sparse/sparse_text_embedding.py +86 -0
- fastembed/sparse/splade_pp.py +138 -0
- fastembed/text/__init__.py +3 -0
- fastembed/text/e5_onnx_embedding.py +62 -0
- fastembed/text/jina_onnx_embedding.py +67 -0
- fastembed/text/onnx_embedding.py +298 -0
- fastembed/text/text_embedding.py +93 -0
- fastembed/text/text_embedding_base.py +60 -0
- fastembed_gpu-0.2.7.dist-info/LICENSE +201 -0
- fastembed_gpu-0.2.7.dist-info/METADATA +145 -0
- fastembed_gpu-0.2.7.dist-info/RECORD +23 -0
- fastembed_gpu-0.2.7.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fastembed-gpu
|
|
3
|
+
Version: 0.2.7
|
|
4
|
+
Summary: Fast, light, accurate library built for retrieval embedding generation
|
|
5
|
+
Home-page: https://github.com/qdrant/fastembed
|
|
6
|
+
License: Apache License
|
|
7
|
+
Keywords: vector,embedding,neural,search,qdrant,sentence-transformers
|
|
8
|
+
Author: NirantK
|
|
9
|
+
Author-email: nirant.bits@gmail.com
|
|
10
|
+
Requires-Python: >=3.8.0,<3.13
|
|
11
|
+
Classifier: License :: Other/Proprietary License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Dist: huggingface-hub (>=0.20,<0.21)
|
|
19
|
+
Requires-Dist: loguru (>=0.7.2,<0.8.0)
|
|
20
|
+
Requires-Dist: numpy (>=1.21) ; python_version < "3.12"
|
|
21
|
+
Requires-Dist: numpy (>=1.26) ; python_version >= "3.12"
|
|
22
|
+
Requires-Dist: onnxruntime-gpu (>=1.17.0,<2.0.0)
|
|
23
|
+
Requires-Dist: requests (>=2.31,<3.0)
|
|
24
|
+
Requires-Dist: tokenizers (>=0.15,<0.16)
|
|
25
|
+
Requires-Dist: tqdm (>=4.66,<5.0)
|
|
26
|
+
Project-URL: Repository, https://github.com/qdrant/fastembed
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# ⚡️ What is FastEmbed?
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
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/).
|
|
34
|
+
|
|
35
|
+
## 📈 Why FastEmbed?
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
3. Accurate: FastEmbed is better than OpenAI Ada-002. We also [supported](https://qdrant.github.io/fastembed/examples/Supported_Models/) an ever expanding set of models, including a few multilingual models.
|
|
42
|
+
|
|
43
|
+
## 🚀 Installation
|
|
44
|
+
|
|
45
|
+
To install the FastEmbed library, pip works best. You can install it with or without GPU support:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install fastembed
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### ⚡️ With GPU
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install fastembed-gpu
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 📖 Quickstart
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from fastembed import TextEmbedding
|
|
61
|
+
from typing import List
|
|
62
|
+
|
|
63
|
+
# Example list of documents
|
|
64
|
+
documents: List[str] = [
|
|
65
|
+
"This is built to be faster and lighter than other embedding libraries e.g. Transformers, Sentence-Transformers, etc.",
|
|
66
|
+
"fastembed is supported by and maintained by Qdrant.",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
# This will trigger the model download and initialization
|
|
70
|
+
embedding_model = TextEmbedding()
|
|
71
|
+
print("The model BAAI/bge-small-en-v1.5 is ready to use.")
|
|
72
|
+
|
|
73
|
+
embeddings_generator = embedding_model.embed(documents) # reminder this is a generator
|
|
74
|
+
embeddings_list = list(embedding_model.embed(documents))
|
|
75
|
+
# you can also convert the generator to a list, and that to a numpy array
|
|
76
|
+
len(embeddings_list[0]) # Vector of 384 dimensions
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### ⚡️ FastEmbed on a GPU
|
|
80
|
+
|
|
81
|
+
FastEmbed supports running on GPU devices. It requires installation of the `fastembed-gpu` package.
|
|
82
|
+
Make sure not to have the `fastembed` package installed, as it might interfere with the `fastembed-gpu` package.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install fastembed-gpu
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from fastembed import TextEmbedding
|
|
90
|
+
|
|
91
|
+
embedding_model = TextEmbedding(model_name="BAAI/bge-small-en-v1.5", providers=["CUDAExecutionProvider"])
|
|
92
|
+
print("The model BAAI/bge-small-en-v1.5 is ready to use on a GPU.")
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Usage with Qdrant
|
|
97
|
+
|
|
98
|
+
Installation with Qdrant Client in Python:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install qdrant-client[fastembed]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
or
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install qdrant-client[fastembed-gpu]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
You might have to use quotes ```pip install 'qdrant-client[fastembed]'``` on zsh.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from qdrant_client import QdrantClient
|
|
114
|
+
|
|
115
|
+
# Initialize the client
|
|
116
|
+
client = QdrantClient("localhost", port=6333) # For production
|
|
117
|
+
# client = QdrantClient(":memory:") # For small experiments
|
|
118
|
+
|
|
119
|
+
# Prepare your documents, metadata, and IDs
|
|
120
|
+
docs = ["Qdrant has Langchain integrations", "Qdrant also has Llama Index integrations"]
|
|
121
|
+
metadata = [
|
|
122
|
+
{"source": "Langchain-docs"},
|
|
123
|
+
{"source": "Llama-index-docs"},
|
|
124
|
+
]
|
|
125
|
+
ids = [42, 2]
|
|
126
|
+
|
|
127
|
+
# If you want to change the model:
|
|
128
|
+
# client.set_model("sentence-transformers/all-MiniLM-L6-v2")
|
|
129
|
+
# List of supported models: https://qdrant.github.io/fastembed/examples/Supported_Models
|
|
130
|
+
|
|
131
|
+
# Use the new add() instead of upsert()
|
|
132
|
+
# This internally calls embed() of the configured embedding model
|
|
133
|
+
client.add(
|
|
134
|
+
collection_name="demo_collection",
|
|
135
|
+
documents=docs,
|
|
136
|
+
metadata=metadata,
|
|
137
|
+
ids=ids
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
search_result = client.query(
|
|
141
|
+
collection_name="demo_collection",
|
|
142
|
+
query_text="This is a query document"
|
|
143
|
+
)
|
|
144
|
+
print(search_result)
|
|
145
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
fastembed/__init__.py,sha256=9xHkflFR7kG3MaY3mTTox4tMuISvIBO79HbesyxI3PU,398
|
|
2
|
+
fastembed/common/__init__.py,sha256=rEIRzzSomx25bbFhNQBCPmuuFCtQsygqA6jx36MRoT4,81
|
|
3
|
+
fastembed/common/model_management.py,sha256=Hfl2XWVY58EEqHTeeo08xLaFHZ59IiCrUlKxgisFRHw,8675
|
|
4
|
+
fastembed/common/models.py,sha256=JjRKsco0rHrCVRiA3nVF0LkFgII2n93xX9xDoZd0Aqw,2030
|
|
5
|
+
fastembed/common/onnx_model.py,sha256=2WjoZnp8Pbhp7InMq0EAuovvqCcdz2-YI19c_8sXh9M,5266
|
|
6
|
+
fastembed/common/utils.py,sha256=Xa6JqwOsrSNM8Ti8DRH0PdTwjyqNJFiM7jVb_0qih64,890
|
|
7
|
+
fastembed/embedding.py,sha256=HeG031cG03UebIstWRDxjYwCq3oqK_JHFHlyeMAroSw,604
|
|
8
|
+
fastembed/image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
fastembed/parallel_processor.py,sha256=TNhzVp056oVILRMOn5WrUuaVdNwTxSXuTJXiA4lKfts,7539
|
|
10
|
+
fastembed/sparse/__init__.py,sha256=GeUoN_fpiBPoqkO1cOITxf8po0lVdcPV07CEfELsUI0,192
|
|
11
|
+
fastembed/sparse/sparse_embedding_base.py,sha256=3--H1ZHRFXSksmEMnW9D24MDxjSEjF5MRfX4X1N_91A,1133
|
|
12
|
+
fastembed/sparse/sparse_text_embedding.py,sha256=QkXRESUZkkN07qZemL-N6JC-Y2RKZAO0xosQjtkxZLg,3234
|
|
13
|
+
fastembed/sparse/splade_pp.py,sha256=PflMeseKd3uxT6x4Od2t1Nqe0dMb_m1uYHDcd678qBM,4902
|
|
14
|
+
fastembed/text/__init__.py,sha256=5_J8_ASHoG-LrVFvJ_F5ow56PHv5i9j4sziAyxMqKdk,85
|
|
15
|
+
fastembed/text/e5_onnx_embedding.py,sha256=1DBKfybzLlRMXIjKn1lK4tvMcQ8Zt2NJdjz5FnqXLGQ,2049
|
|
16
|
+
fastembed/text/jina_onnx_embedding.py,sha256=4ML25k-Tq3r0GoJRS9yXT7ELAIg30vPR8NhuFQPmhrE,2273
|
|
17
|
+
fastembed/text/onnx_embedding.py,sha256=-mHpG5e_-G5AAnvV3J_grktTjSGD82V6cNvSkKYHU2Y,10151
|
|
18
|
+
fastembed/text/text_embedding.py,sha256=EN3gfTP2A_Oljj1933qpU_rg0Ys19sngltkF7S_odW0,3570
|
|
19
|
+
fastembed/text/text_embedding_base.py,sha256=dzcZSkXokuQ-sPigVB6hN3Xj4fW50teQK4OGZR3Jjv4,1890
|
|
20
|
+
fastembed_gpu-0.2.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
21
|
+
fastembed_gpu-0.2.7.dist-info/METADATA,sha256=8OT_j9htZFQ1ZZ3VcWQ3gGJ3jvW5xrnTFCLvYIGSziI,5299
|
|
22
|
+
fastembed_gpu-0.2.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
23
|
+
fastembed_gpu-0.2.7.dist-info/RECORD,,
|