michaelfeil commited on
Commit
6bd989d
1 Parent(s): 7d4ba8c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -7
README.md CHANGED
@@ -373,8 +373,8 @@ import torch
373
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
374
 
375
  tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-reranker-large')
376
- model = AutoModelForSequenceClassification.from_pretrained('BAAI/bge-reranker-large')
377
- model_ort = ORTModelForFeatureExtraction.from_pretrained('BAAI/bge-reranker-large', file_name="onnx/model.onnx")
378
 
379
  # Sentences we want sentence embeddings for
380
  pairs = [['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']]
@@ -382,25 +382,25 @@ pairs = [['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropo
382
  # Tokenize sentences
383
  encoded_input = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt')
384
 
385
- scores_ort = model_ort(**inputs, return_dict=True).logits.view(-1, ).float()
386
  # Compute token embeddings
387
  with torch.inference_mode():
388
- scores = model_ort(**inputs, return_dict=True).logits.view(-1, ).float()
389
 
390
  # scores and scores_ort are identical
391
  ```
392
  #### Usage reranker with infinity
393
 
394
- Its also possible to deploy the onnx files with the [infinity_emb](https://github.com/michaelfeil/infinity) pip package.
395
  ```python
396
  import asyncio
397
  from infinity_emb import AsyncEmbeddingEngine, EngineArgs
398
 
399
- query='what is panda?'
400
  docs = ['The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear', "Paris is in France."]
401
 
402
  engine = AsyncEmbeddingEngine.from_args(
403
- EngineArgs(model_name_or_path = "BAAI/bge-large-en-v1.5", device="cpu", engine="optimum" # or engine="torch"
404
  ))
405
 
406
  async def main():
 
373
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
374
 
375
  tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-reranker-large')
376
+ model = AutoModelForSequenceClassification.from_pretrained('BAAI/bge-reranker-base')
377
+ model_ort = ORTModelForSequenceClassification.from_pretrained('BAAI/bge-reranker-base', file_name="onnx/model.onnx")
378
 
379
  # Sentences we want sentence embeddings for
380
  pairs = [['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']]
 
382
  # Tokenize sentences
383
  encoded_input = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt')
384
 
385
+ scores_ort = model_ort(**encoded_input, return_dict=True).logits.view(-1, ).float()
386
  # Compute token embeddings
387
  with torch.inference_mode():
388
+ scores = model_ort(**encoded_input, return_dict=True).logits.view(-1, ).float()
389
 
390
  # scores and scores_ort are identical
391
  ```
392
  #### Usage reranker with infinity
393
 
394
+ Its also possible to deploy the onnx/torch files with the [infinity_emb](https://github.com/michaelfeil/infinity) pip package.
395
  ```python
396
  import asyncio
397
  from infinity_emb import AsyncEmbeddingEngine, EngineArgs
398
 
399
+ query='what is a panda?'
400
  docs = ['The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear', "Paris is in France."]
401
 
402
  engine = AsyncEmbeddingEngine.from_args(
403
+ EngineArgs(model_name_or_path = "BAAI/bge-reranker-base", device="cpu", engine="torch" # or engine="optimum" for onnx
404
  ))
405
 
406
  async def main():