模型:
vicgalle/xlm-roberta-large-xnli-anli
XLM-RoBERTa-large模型在多个NLI数据集上进行微调,可用于零-shot分类。
下面是几个测试数据集的准确率:
XNLI-es | XNLI-fr | ANLI-R1 | ANLI-R2 | ANLI-R3 | |
---|---|---|---|---|---|
xlm-roberta-large-xnli-anli | 93.7% | 93.2% | 68.5% | 53.6% | 49.0% |
可以使用零-shot-classification管道加载模型,如下所示:
from transformers import pipeline classifier = pipeline("zero-shot-classification", model="vicgalle/xlm-roberta-large-xnli-anli")
然后,您可以使用该管道将序列分类为您指定的任何类名:
sequence_to_classify = "Algún día iré a ver el mundo" candidate_labels = ['viaje', 'cocina', 'danza'] classifier(sequence_to_classify, candidate_labels) #{'sequence': 'Algún día iré a ver el mundo', #'labels': ['viaje', 'danza', 'cocina'], #'scores': [0.9991760849952698, 0.0004178212257102132, 0.0004059972707182169]}