🚀 DeBERTa-v3-base-mnli-fever-anli
本模型是用於零樣本分類的文本分類模型,基於MultiNLI數據集訓練,能有效進行自然語言推理任務。
🚀 快速開始
模型使用示例
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "MoritzLaurer/DeBERTa-v3-base-mnli"
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))
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)
✨ 主要特性
- 基於MultiNLI數據集訓練,該數據集包含392702個自然語言推理(NLI)的假設 - 前提對。
- 基礎模型採用微軟的DeBERTa - v3 - base,其v3變體通過不同的預訓練目標顯著優於之前的版本。
- 可用於零樣本分類任務,在自然語言推理方面表現出色。
📦 安裝指南
文檔未提及安裝步驟,暫不提供。
💻 使用示例
基礎用法
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "MoritzLaurer/DeBERTa-v3-base-mnli"
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))
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)
📚 詳細文檔
訓練數據
本模型在MultiNLI數據集上進行訓練,該數據集包含392702個NLI假設 - 前提對。
訓練過程
DeBERTa - v3 - base - mnli使用Hugging Face訓練器進行訓練,超參數如下:
training_args = TrainingArguments(
num_train_epochs=5, # total number of training epochs
learning_rate=2e-05,
per_device_train_batch_size=32, # batch size per device during training
per_device_eval_batch_size=32, # batch size for evaluation
warmup_ratio=0.1, # number of warmup steps for learning rate scheduler
weight_decay=0.06, # strength of weight decay
fp16=True # mixed precision training
)
評估結果
該模型使用匹配測試集進行評估,準確率達到0.90。
🔧 技術細節
DeBERTa - v3的v3變體通過不同的預訓練目標顯著優於之前的版本,具體可參考原始DeBERTa論文的附錄11。
📄 許可證
文檔未提及許可證信息,暫不提供。
侷限性和偏差
請參考原始DeBERTa論文和不同NLI數據集的相關文獻,以瞭解潛在的偏差。
BibTeX引用和引用信息
如果您想引用此模型,請引用原始DeBERTa論文、相應的NLI數據集,幷包含該模型在Hugging Face hub上的鏈接。
合作想法或問題諮詢
如果您有合作想法或問題,請通過m{dot}laurer{at}vu{dot}nl或LinkedIn與我聯繫。
調試與問題
請注意,DeBERTa - v3最近才發佈,較舊版本的HF Transformers在運行該模型時似乎存在問題(例如,導致分詞器出現問題)。使用Transformers==4.13可能會解決一些問題。
模型回收
以MoritzLaurer/DeBERTa - v3 - base - mnli為基礎模型,在36個數據集上進行評估,與microsoft/deberta - v3 - base相比,平均得分達到80.01(後者為79.04)。截至2023年09月01日,該模型在所有測試的microsoft/deberta - v3 - base架構模型中排名第1。
評估結果如下:
數據集 |
得分 |
20_newsgroup |
86.0196 |
ag_news |
90.6333 |
amazon_reviews_multi |
66.96 |
anli |
60.0938 |
boolq |
83.792 |
cb |
83.9286 |
cola |
86.5772 |
copa |
72 |
dbpedia |
79.2 |
esnli |
91.419 |
financial_phrasebank |
85.1 |
imdb |
94.232 |
isear |
71.5124 |
mnli |
89.4426 |
mrpc |
90.4412 |
multirc |
63.7583 |
poem_sentiment |
86.5385 |
qnli |
93.8129 |
qqp |
91.9144 |
rotten_tomatoes |
89.8687 |
rte |
85.9206 |
sst2 |
95.4128 |
sst_5bins |
57.3756 |
stsb |
91.377 |
trec_coarse |
97.4 |
trec_fine |
91 |
tweet_ev_emoji |
47.302 |
tweet_ev_emotion |
83.6031 |
tweet_ev_hate |
57.6431 |
tweet_ev_irony |
77.1684 |
tweet_ev_offensive |
83.3721 |
tweet_ev_sentiment |
70.2947 |
wic |
71.7868 |
wnli |
67.6056 |
wsc |
74.0385 |
yahoo_answers |
71.7 |
更多信息請參考:模型回收