michaelfeil
commited on
Commit
•
4386d50
1
Parent(s):
3777b8d
Update README.md
Browse files
README.md
CHANGED
@@ -383,25 +383,25 @@ pairs = [['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropo
|
|
383 |
# Tokenize sentences
|
384 |
encoded_input = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt')
|
385 |
|
386 |
-
scores_ort = model_ort(**
|
387 |
# Compute token embeddings
|
388 |
with torch.inference_mode():
|
389 |
-
scores = model_ort(**
|
390 |
|
391 |
# scores and scores_ort are identical
|
392 |
```
|
393 |
#### Usage reranker with infinity
|
394 |
|
395 |
-
Its also possible to deploy the onnx files with the [infinity_emb](https://github.com/michaelfeil/infinity) pip package.
|
396 |
```python
|
397 |
import asyncio
|
398 |
from infinity_emb import AsyncEmbeddingEngine, EngineArgs
|
399 |
|
400 |
-
query='what is panda?'
|
401 |
docs = ['The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear', "Paris is in France."]
|
402 |
|
403 |
engine = AsyncEmbeddingEngine.from_args(
|
404 |
-
EngineArgs(model_name_or_path = "BAAI/bge-reranker-base", device="cpu", engine="
|
405 |
))
|
406 |
|
407 |
async def main():
|
|
|
383 |
# Tokenize sentences
|
384 |
encoded_input = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt')
|
385 |
|
386 |
+
scores_ort = model_ort(**encoded_input, return_dict=True).logits.view(-1, ).float()
|
387 |
# Compute token embeddings
|
388 |
with torch.inference_mode():
|
389 |
+
scores = model_ort(**encoded_input, return_dict=True).logits.view(-1, ).float()
|
390 |
|
391 |
# scores and scores_ort are identical
|
392 |
```
|
393 |
#### Usage reranker with infinity
|
394 |
|
395 |
+
Its also possible to deploy the onnx/torch files with the [infinity_emb](https://github.com/michaelfeil/infinity) pip package.
|
396 |
```python
|
397 |
import asyncio
|
398 |
from infinity_emb import AsyncEmbeddingEngine, EngineArgs
|
399 |
|
400 |
+
query='what is a panda?'
|
401 |
docs = ['The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear', "Paris is in France."]
|
402 |
|
403 |
engine = AsyncEmbeddingEngine.from_args(
|
404 |
+
EngineArgs(model_name_or_path = "BAAI/bge-reranker-base", device="cpu", engine="torch" # or engine="optimum" for onnx
|
405 |
))
|
406 |
|
407 |
async def main():
|