zyznull commited on
Commit
a624cb7
1 Parent(s): b61e919

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -3
README.md CHANGED
@@ -1,3 +1,21 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ ### Usage
6
+
7
+ Using Huggingface transformers
8
+ ```
9
+ import torch
10
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
11
+
12
+ tokenizer = AutoTokenizer.from_pretrained('Alibaba-NLP/gte-multilingual-reranker-base')
13
+ model = AutoModelForSequenceClassification.from_pretrained('Alibaba-NLP/gte-multilingual-reranker-base', trust_remote_code=True)
14
+ model.eval()
15
+
16
+ pairs = [["中国的首都在哪儿","北京"], ["what is the capital of China?", "北京"], ["how to implement quick sort in python?","Introduction of quick sort"]]
17
+ with torch.no_grad():
18
+ inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
19
+ scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
20
+ print(scores)
21
+ ```