Update README.md
Browse files
README.md
CHANGED
@@ -14,7 +14,7 @@ Note: dense and ColBERT embeddings are normalized like the default behavior in t
|
|
14 |
|
15 |
Install the necessary modules:
|
16 |
```bash
|
17 |
-
pip install
|
18 |
```
|
19 |
|
20 |
You can then use the model to compute embeddings, as follows:
|
@@ -24,8 +24,6 @@ from huggingface_hub import hf_hub_download
|
|
24 |
import onnxruntime as ort
|
25 |
from transformers import AutoTokenizer
|
26 |
|
27 |
-
tokenizer = AutoTokenizer.from_pretrained("ddmitov/bge_m3_dense_colbert_onnx")
|
28 |
-
|
29 |
hf_hub_download(
|
30 |
repo_id="ddmitov/bge_m3_dense_colbert_onnx",
|
31 |
filename="model.onnx",
|
@@ -40,6 +38,8 @@ hf_hub_download(
|
|
40 |
repo_type="model"
|
41 |
)
|
42 |
|
|
|
|
|
43 |
ort_session = ort.InferenceSession("/tmp/model.onnx")
|
44 |
|
45 |
inputs = tokenizer(
|
@@ -48,7 +48,9 @@ inputs = tokenizer(
|
|
48 |
return_tensors="np"
|
49 |
)
|
50 |
|
51 |
-
inputs_onnx = {
|
|
|
|
|
52 |
|
53 |
outputs = ort_session.run(None, inputs_onnx)
|
54 |
|
|
|
14 |
|
15 |
Install the necessary modules:
|
16 |
```bash
|
17 |
+
pip install huggingface-hub onnxruntime transformers
|
18 |
```
|
19 |
|
20 |
You can then use the model to compute embeddings, as follows:
|
|
|
24 |
import onnxruntime as ort
|
25 |
from transformers import AutoTokenizer
|
26 |
|
|
|
|
|
27 |
hf_hub_download(
|
28 |
repo_id="ddmitov/bge_m3_dense_colbert_onnx",
|
29 |
filename="model.onnx",
|
|
|
38 |
repo_type="model"
|
39 |
)
|
40 |
|
41 |
+
tokenizer = AutoTokenizer.from_pretrained("ddmitov/bge_m3_dense_colbert_onnx")
|
42 |
+
|
43 |
ort_session = ort.InferenceSession("/tmp/model.onnx")
|
44 |
|
45 |
inputs = tokenizer(
|
|
|
48 |
return_tensors="np"
|
49 |
)
|
50 |
|
51 |
+
inputs_onnx = {
|
52 |
+
key: ort.OrtValue.ortvalue_from_numpy(value) for key, value in inputs.items()
|
53 |
+
}
|
54 |
|
55 |
outputs = ort_session.run(None, inputs_onnx)
|
56 |
|