模型:

Elron/bleurt-large-128

英文

\n## BLEURT

ACL论文 "BLEURT: Learning Robust Metrics for Text Generation" 中谷歌研究员 Thibault Sellam、Dipanjan Das 和 Ankur P. Parikh 开发的 BLEURT 模型的 Pytorch 版本。

模型转换的代码源于 提及的 this notebook 。

使用示例

from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

tokenizer = AutoTokenizer.from_pretrained("Elron/bleurt-large-128")
model = AutoModelForSequenceClassification.from_pretrained("Elron/bleurt-large-128")
model.eval()

references = ["hello world", "hello world"]
candidates = ["hi universe", "bye world"]

with torch.no_grad():
  scores = model(**tokenizer(references, candidates, return_tensors='pt'))[0].squeeze()

print(scores) # tensor([ 0.0020, -0.6647])