英文

DeBERTa-v3-base-mnli-fever-docnli-ling-2c

模型描述

该模型在8个自然语言推理(NLI)数据集中使用1,279,665个假设-前提对进行训练: MultiNLI Fever-NLI LingNLI DocNLI (包括 ANLI ,QNLI, DUC,CNN / DailyMail,Curation)。

这是模型库中唯一在8个NLI数据集上训练的模型,包括使用非常长的文本进行长距离推理的DocNLI。请注意,该模型是在二进制NLI上进行训练的,以预测"entailment"或"not-entailment"。

DocNLI将"neural"和"contradiction"类合并为"not-entailment",以便包含DocNLI数据集。

基础模型为 DeBERTa-v3-base from Microsoft 。DeBERTa的v3变种通过包含不同的预训练目标明显优于模型的先前版本,请参阅原始 DeBERTa paper 的附录11,以及 DeBERTa-V3 paper

为了获得最佳性能(但速度较慢),建议使用 https://huggingface.co/MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli

如何使用该模型

简单的零样本分类流水线

from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c")
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用例
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-docnli-ling-2c"
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", "not_entailment"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)

训练数据

该模型使用了8个NLI数据集中的1,279,665个假设-前提对进行训练: MultiNLI Fever-NLI LingNLI DocNLI (包括 ANLI ,QNLI,DUC,CNN / DailyMail,Curation)。

训练过程

DeBERTa-v3-small-mnli-fever-docnli-ling-2c是使用Hugging Face Trainer和以下超参数进行训练的。

评估结果

该模型使用MultiNLI和ANLI的二进制测试集以及Fever-NLI的二进制开发集进行评估(两个类别而不是三个)。使用的指标是准确率。

限制和偏差

请参考原始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 .

合作想法或问题?

如果您有问题或合作想法,请通过m(dot)laurer(at)vu(dot)nl或 LinkedIn 与我联系。

调试和问题

请注意,DeBERTa-v3于06.12.21发布,旧版本的HF Transformers似乎存在运行该模型的问题(例如,令牌化器出现问题)。使用Transformers>=4.13可能会解决一些问题。