DeBERTa-v3-base-mnli-fever-anli
该模型在MultiNLI、Fever-NLI和Adversarial-NLI(ANLI)数据集上进行了训练,这些数据集包含763,913个自然语言推理(NLI)假设-前提对。此基础模型在ANLI基准测试中的表现几乎优于所有大型模型。基础模型为微软的DeBERTa-v3-base。DeBERTa的v3变体通过引入不同的预训练目标,显著优于该模型的先前版本,详见原始DeBERTa论文的附录11。
简单的零样本分类流程 #!pip install transformers
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli")
sequence_to_classify = "Angela Merkel is a politician in Germany and leader of the CDU"
candidate_labels = ["politics", "economy", "entertainment", "environment"]
output = classifier(sequence_to_classify, candidate_labels, multi_label=False)
print(output)
NLI use-case
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model_name = "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
premise = "I first thought that I liked the movie, but upon second thought it was actually disappointing."
hypothesis = "The movie was good."
input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
output = model(input["input_ids"].to(device)) # device = "cuda:0" or "cpu"
prediction = torch.softmax(output["logits"][0], -1).tolist()
label_names = ["entailment", "neutral", "contradiction"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)DeBERTa-v3-base-mnli-fever-anli 在 MultiNLI、Fever-NLI 和 Adversarial-NLI(ANLI)数据集上进行训练,这些数据集包含 763,913 个自然语言推理(NLI)假设-前提对。
该模型使用 MultiNLI 和 ANLI 的测试集以及 Fever-NLI 的开发集进行评估。所使用的指标为准确率。
mnli-m mnli-mm fever-nli anli-all anli-r3 0.903 0.903 0.777 0.579 0.495 局限性与偏差 有关潜在偏差,请参考原始 DeBERTa 论文以及关于不同 NLI 数据集的文献。
如果您使用此模型,请引用:Laurer, Moritz, Wouter van Atteveldt, Andreu Salleras Casas, and Kasper Welbers. 2022. ‘Less Annotating, More Classifying – Addressing the Data Scarcity Issue of Supervised Machine Learning with Deep Transfer Learning and BERT - NLI’. Preprint, June. Open Science Framework. https://osf.io/74b8k.
请注意,DeBERTa-v3 于 2021 年 12 月 6 日发布,旧版本的 Hugging Face Transformers 可能在运行该模型时存在问题(例如,导致分词器出现问题)。使用 Transformers>=4.13 可能会解决部分问题。同时,请确保安装 sentencepiece 以避免分词器错误。运行:pip install transformers[sentencepiece] 或 pip install sentencepiece
使用 MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli 作为基础模型在 36 个数据集上进行评估,平均得分为 79.69,而 microsoft/deberta-v3-base 的平均得分为 79.04。
截至 2023 年 1 月 9 日,该模型在所有 microsoft/deberta-v3-base 架构的测试模型中排名第二。
20_newsgroup ag_news amazon_reviews_multi anli boolq cb cola copa dbpedia esnli financial_phrasebank imdb isear mnli mrpc multirc poem_sentiment qnli qqp rotten_tomatoes rte sst2 sst_5bins stsb trec_coarse trec_fine tweet_ev_emoji tweet_ev_emotion tweet_ev_hate tweet_ev_irony tweet_ev_offensive tweet_ev_sentiment wic wnli wsc yahoo_answers 85.8072 90.4333 67.32 59.625 85.107 91.0714 85.8102 67 79.0333 91.6327 82.5 94.02 71.6428 89.5749 89.7059 64.1708 88.4615 93.575 91.4148 89.6811 86.2816 94.6101 57.0588 91.5508 97.6 91.2 45.264 82.6179 54.5455 74.3622 84.8837 71.6949 71.0031 69.0141 68.2692 71.3333 欲了解更多信息,请参见:Model Recycling