Downloads · 30 days
22
0% of all-time downloads
Pristinenlp/alime-reranker-large-zh
alime-reranker-large-zh is a text classification model from Pristinenlp. Use it when you need a label for a piece of text. It is set up for transformers.
Downloads · 30 days
22
0% of all-time downloads
All-time downloads
7.4K
Public
Repo size
4.5 GB
Likes
9
Public
Click a slice to open those files.
.bin2.2 GB · 100%
From the Hugging Face model README
The alime reranker model.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
pairs = [["西湖在哪?", "西湖风景名胜区位于浙江省杭州市"],["今天天气不错","你吓死我了"]]
if torch.cuda.is_available():
device = torch.device("cuda")
else:
device = torch.device("cpu")
tokenizer = AutoTokenizer.from_pretrained("Pristinenlp/alime-reranker-large-zh")
model = AutoModelForSequenceClassification.from_pretrained("Pristinenlp/alime-reranker-large-zh").to(device)
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512).to(device)
scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
print(scores.tolist())