Skip to content

Commit d725974

Browse files
authored
new: update docs (#257)
1 parent 14c067e commit d725974

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

docs/Getting Started.ipynb

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"\n",
1212
"## Quick Start\n",
1313
"\n",
14-
"The fastembed package is designed to be easy to use. We'll be using `TextEmbedding` class. It takes a list of strings as input and returns an generator of vectors. If you're seeing generators for the first time, don't worry, you can convert it to a list using `list()`.\n",
14+
"The fastembed package is designed to be easy to use. We'll be using `TextEmbedding` class. It takes a list of strings as input and returns a generator of vectors.\n",
1515
"\n",
1616
"> 💡 You can learn more about generators from [Python Wiki](https://wiki.python.org/moin/Generators)"
1717
]
@@ -23,7 +23,7 @@
2323
"metadata": {},
2424
"outputs": [],
2525
"source": [
26-
"!pip install -Uqq fastembed # Install fastembed"
26+
"!pip install -Uqq fastembed"
2727
]
2828
},
2929
{
@@ -65,9 +65,12 @@
6565
}
6666
],
6767
"source": [
68+
"from typing import List\n",
69+
"\n",
6870
"import numpy as np\n",
71+
"\n",
6972
"from fastembed import TextEmbedding\n",
70-
"from typing import List\n",
73+
"\n",
7174
"\n",
7275
"# Example list of documents\n",
7376
"documents: List[str] = [\n",
@@ -79,9 +82,8 @@
7982
"embedding_model = TextEmbedding()\n",
8083
"print(\"The model BAAI/bge-small-en-v1.5 is ready to use.\")\n",
8184
"\n",
82-
"embeddings_generator = embedding_model.embed(documents) # reminder this is a generator\n",
85+
"embeddings_generator = embedding_model.embed(documents)\n",
8386
"embeddings_list = list(embeddings_generator)\n",
84-
"# you can also convert the generator to a list, and that to a numpy array\n",
8587
"len(embeddings_list[0]) # Vector of 384 dimensions"
8688
]
8789
},
@@ -113,7 +115,7 @@
113115
}
114116
],
115117
"source": [
116-
"embeddings_generator = embedding_model.embed(documents) # reminder this is a generator\n",
118+
"embeddings_generator = embedding_model.embed(documents)\n",
117119
"\n",
118120
"for doc, vector in zip(documents, embeddings_generator):\n",
119121
" print(\"Document:\", doc)\n",
@@ -138,9 +140,7 @@
138140
}
139141
],
140142
"source": [
141-
"embeddings_list = np.array(\n",
142-
" list(embedding_model.embed(documents))\n",
143-
") # you can also convert the generator to a list, and that to a numpy array\n",
143+
"embeddings_list = np.array(list(embedding_model.embed(documents)))\n",
144144
"embeddings_list.shape"
145145
]
146146
},
@@ -185,7 +185,7 @@
185185
}
186186
],
187187
"source": [
188-
"multilingual_large_model = TextEmbedding(\"intfloat/multilingual-e5-large\") # This can take a few minutes to download"
188+
"multilingual_large_model = TextEmbedding(\"intfloat/multilingual-e5-large\")"
189189
]
190190
},
191191
{

docs/index.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
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.
44

5-
The default embedding supports "query" and "passage" prefixes for the input text. The default model is Flag Embedding, which is top of the [MTEB](https://huggingface.co/spaces/mteb/leaderboard) leaderboard. Here is an example for [Retrieval Embedding Generation](https://qdrant.github.io/fastembed/examples/Retrieval%20with%20FastEmbed/) and how to use [FastEmbed with Qdrant](https://qdrant.github.io/fastembed/examples/Usage_With_Qdrant/).
6-
75
1. Light & Fast
86
- Quantized model weights
9-
- ONNX Runtime for inference via [Optimum](https://github.com/huggingface/optimum)
7+
- ONNX Runtime for inference
108

119
2. Accuracy/Recall
1210
- Better than OpenAI Ada-002
13-
- Default is Flag Embedding, which is top of the [MTEB](https://huggingface.co/spaces/mteb/leaderboard) leaderboard
11+
- Default is Flag Embedding, which has shown good results on the [MTEB](https://huggingface.co/spaces/mteb/leaderboard) leaderboard
1412
- List of [supported models](https://qdrant.github.io/fastembed/examples/Supported_Models/) - including multilingual models
1513

14+
Here is an example for [Retrieval Embedding Generation](https://qdrant.github.io/fastembed/examples/Retrieval%20with%20FastEmbed/) and how to use [FastEmbed with Qdrant](https://qdrant.github.io/fastembed/examples/Usage_With_Qdrant/).
15+
1616
## 🚀 Installation
1717

1818
To install the FastEmbed library, pip works:
@@ -24,16 +24,16 @@ pip install fastembed
2424
## 📖 Usage
2525

2626
```python
27-
from fastembed.embedding import FlagEmbedding as Embedding
27+
from fastembed import TextEmbedding
2828

2929
documents: List[str] = [
3030
"passage: Hello, World!",
31-
"query: Hello, World!", # these are two different embedding
31+
"query: Hello, World!",
3232
"passage: This is an example passage.",
33-
"fastembed is supported by and maintained by Qdrant." # You can leave out the prefix but it's recommended
33+
"fastembed is supported by and maintained by Qdrant."
3434
]
35-
embedding_model = Embedding(model_name="BAAI/bge-base-en", max_length=512)
36-
embeddings: List[np.ndarray] = embedding_model.embed(documents) # If you use
35+
embedding_model = TextEmbedding()
36+
embeddings: List[np.ndarray] = embedding_model.embed(documents)
3737
```
3838

3939
## Usage with Qdrant
@@ -50,17 +50,16 @@ Might have to use ```pip install 'qdrant-client[fastembed]'``` on zsh.
5050
from qdrant_client import QdrantClient
5151

5252
# Initialize the client
53-
client = QdrantClient(":memory:") # or QdrantClient(path="path/to/db")
53+
client = QdrantClient(":memory:") # Using an in-process Qdrant
5454

5555
# Prepare your documents, metadata, and IDs
5656
docs = ["Qdrant has Langchain integrations", "Qdrant also has Llama Index integrations"]
5757
metadata = [
5858
{"source": "Langchain-docs"},
59-
{"source": "Linkedin-docs"},
59+
{"source": "Llama-index-docs"},
6060
]
6161
ids = [42, 2]
6262

63-
# Use the new add method
6463
client.add(
6564
collection_name="demo_collection",
6665
documents=docs,

0 commit comments

Comments
 (0)