Пример 1
from transformers import AutoModel, AutoTokenizer, AutoModelForSequenceClassification
import torch
sigmoid_fn = torch.nn.Sigmoid()
model = AutoModelForSequenceClassification.from_pretrained("PitKoro/cross-encoder-ru-msmarco-passage")
tokenizer = AutoTokenizer.from_pretrained("PitKoro/cross-encoder-ru-msmarco-passage")
text = [['привет', 'привет'],['привет', 'пока']]
tokenized = tokenizer(text, return_tensors='pt')
logits = model(**tokenized).logits
output = sigmoid_fn(logits.flatten())
print(output)
Пример 2
from sentence_transformers.cross_encoder import CrossEncoder
model = CrossEncoder("PitKoro/cross-encoder-ru-msmarco-passage", max_length=512)
text = [['привет', 'привет'],['привет', 'пока']]
output = model.predict(text)
print(output)