File size: 1,350 Bytes
7dab1a1
 
 
 
 
 
 
6afa911
 
 
 
7dab1a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
license: apache-2.0
language:
- en
pipeline_tag: sentence-similarity
---

ONNX port of [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) adjusted to return attention weights. To be used for [BM42 searches](https://qdrant.tech/articles/bm42/).

> Note:
This model is supposed to be used with Qdrant. Vectors have to be configured with [Modifier.IDF](https://qdrant.tech/documentation/concepts/indexing/?q=modifier#idf-modifier).

### Usage

Here's an example of performing inference using the model with [FastEmbed](https://github.com/qdrant/fastembed).

```py
from fastembed import SparseTextEmbedding

documents = [
    "You should stay, study and sprint.",
    "History can only prepare us to be surprised yet again.",
]

model = SparseTextEmbedding(model_name="Qdrant/bm42-all-minilm-l6-v2-attentions")
embeddings = list(model.embed(documents))

# [
#     SparseEmbedding(values=array([0.26399775, 0.24662513, 0.47077307]),
#                     indices=array([1881538586, 150760872, 1932363795])),
#     SparseEmbedding(values=array(
#         [0.38320042, 0.25453135, 0.18017513, 0.30432631, 0.1373556]),
#                     indices=array([
#                         733618285, 1849833631, 1008800696, 2090661150,
#                         1117393019
#                     ]))
# ]

```