Spaces:
Runtime error
Runtime error
File size: 806 Bytes
4e0f879 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("davebulaval/MeaningBERT")
scorer = AutoModelForSequenceClassification.from_pretrained("davebulaval/MeaningBERT")
scorer.eval()
documents = [
"He wanted to make them pay.",
"This sandwich looks delicious.",
"He wants to eat.",
]
simplifications = [
"He wanted to make them pay.",
"This sandwich looks delicious.",
"Whatever, whenever, this is a sentence.",
]
# We tokenize the text as a pair and return Pytorch Tensors
tokenize_text = tokenizer(
documents, simplifications, truncation=True, padding=True, return_tensors="pt"
)
with torch.no_grad():
# We process the text
scores = scorer(**tokenize_text)
print(scores.logits.tolist())
|