Added a model card.
Browse files
README.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
pipeline_tag: sentence-similarity
|
6 |
+
---
|
7 |
+
Repository with files to perform BM25 searches with [FastEmbed](https://github.com/qdrant/fastembed).
|
8 |
+
|
9 |
+
[BM25 (Best Matching 25)](https://en.wikipedia.org/wiki/Okapi_BM25) is a ranking function used by search engines to estimate the relevance of documents to a given search query.
|
10 |
+
|
11 |
+
### Usage
|
12 |
+
|
13 |
+
Here's an example of BM25 with [FastEmbed](https://github.com/qdrant/fastembed).
|
14 |
+
|
15 |
+
```py
|
16 |
+
from fastembed import SparseTextEmbedding
|
17 |
+
|
18 |
+
documents = [
|
19 |
+
"You should stay, study and sprint.",
|
20 |
+
"History can only prepare us to be surprised yet again.",
|
21 |
+
]
|
22 |
+
|
23 |
+
model = SparseTextEmbedding(model_name="Qdrant/bm25")
|
24 |
+
embeddings = list(embedding_model.embed(documents))
|
25 |
+
|
26 |
+
# [
|
27 |
+
# SparseEmbedding(
|
28 |
+
# values=array([1.67419738, 1.67419738, 1.67419738, 1.67419738]),
|
29 |
+
# indices=array([171321964, 1881538586, 150760872, 1932363795])),
|
30 |
+
# SparseEmbedding(values=array(
|
31 |
+
# [1.66973021, 1.66973021, 1.66973021, 1.66973021, 1.66973021]),
|
32 |
+
# indices=array([
|
33 |
+
# 578407224, 1849833631, 1008800696, 2090661150,
|
34 |
+
# 1117393019
|
35 |
+
# ]))
|
36 |
+
# ]
|
37 |
+
|
38 |
+
```
|