模型描述:deberta-v3-large-zeroshot-v1.1-all-33
该模型专为使用Hugging Face流水线进行零样本分类而设计。
该模型可执行一项通用分类任务:给定一段文本,判断假设是"真实"还是"不真实"(蕴含
vs. 不蕴含
)。
此任务格式基于自然语言推理任务(NLI)。该任务具有高度通用性,任何分类任务均可重新表述为此形式。
关于模型训练方式及使用方法的详细说明,请参阅此论文。
训练数据
该模型在__33个数据集和387个类别__的混合数据上进行训练,这些数据已被重新格式化为通用形式:
- 五个NLI数据集,约88.5万文本:"mnli"、"anli"、"fever"、"wanli"、"ling"
- 28个分类任务重新格式化为通用NLI形式。为避免过拟合,使用了约5.1万条清洗后的文本:
'amazonpolarity', 'imdb', 'appreviews', 'yelpreviews', 'rottentomatoes',
'emotiondair', 'emocontext', 'empathetic',
'financialphrasebank', 'banking77', 'massive',
'wikitoxic_toxicaggregated', 'wikitoxic_obscene', 'wikitoxic_threat', 'wikitoxic_insult', 'wikitoxic_identityhate',
'hateoffensive', 'hatexplain', 'biasframes_offensive', 'biasframes_sex', 'biasframes_intent',
'agnews', 'yahootopics',
'trueteacher', 'spam', 'wellformedquery',
'manifesto', 'capsotu'.
各数据集详情参见:https://github.com/MoritzLaurer/zeroshot-classifier/blob/main/datasets_overview.csv
注意:与其他NLI模型不同,该模型预测两个类别(蕴含
vs. 不蕴含
),而非三个类别(蕴含/中立/矛盾)
该模型仅在英文数据上训练。对于__多语言场景__,建议使用EasyNMT等库将文本机器翻译为英文。纯英文模型通常表现优于多语言模型,且若您不熟悉语料库中的所有语言,使用英文数据验证会更方便。
如何使用模型
简单零样本分类流水线
from transformers import pipeline
text = "安格拉·默克尔是德国政治家,基民盟领导人"
hypothesis_template = "这个例子是关于{}的"
classes_verbalized = ["政治", "经济", "娱乐", "环境"]
zeroshot_classifier = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-large-zeroshot-v1.1-all-33")
output = zeroshot_classifier(text, classes_verbalised, hypothesis_template=hypothesis_template, multi_label=False)
print(output)
数据与训练详情
数据准备及模型训练评估的完整开源代码见:https://github.com/MoritzLaurer/zeroshot-classifier/tree/main
超参数等详细信息见此Weights & Biases仓库:https://wandb.ai/moritzlaurer/deberta-v3-large-zeroshot-v1-1-all-33/table?workspace=user-
指标
报告所有数据集的平衡准确率。
deberta-v3-large-zeroshot-v1.1-all-33
在所有数据集上训练,每类最多使用500个文本以避免过拟合。
因此这些数据集上的指标并非严格零样本,因为模型在训练过程中已见过每个任务的某些数据。
deberta-v3-large-zeroshot-v1.1-heldout
表示在相应数据集上的零样本性能。
为计算这些零样本指标,流水线运行了28次,每次训练时保留一个数据集以模拟零样本设置。

|
deberta-v3-large-mnli-fever-anli-ling-wanli-binary |
deberta-v3-large-zeroshot-v1.1-heldout |
deberta-v3-large-zeroshot-v1.1-all-33 |
datasets mean (w/o nli) |
64.1 |
73.4 |
85.2 |
amazonpolarity (2) |
94.7 |
96.6 |
96.8 |
imdb (2) |
90.3 |
95.2 |
95.5 |
appreviews (2) |
93.6 |
94.3 |
94.7 |
yelpreviews (2) |
98.5 |
98.4 |
98.9 |
rottentomatoes (2) |
83.9 |
90.5 |
90.8 |
emotiondair (6) |
49.2 |
42.1 |
72.1 |
emocontext (4) |
57 |
69.3 |
82.4 |
empathetic (32) |
42 |
34.4 |
58 |
financialphrasebank (3) |
77.4 |
77.5 |
91.9 |
banking77 (72) |
29.1 |
52.8 |
72.2 |
massive (59) |
47.3 |
64.7 |
77.3 |
wikitoxic_toxicaggreg (2) |
81.6 |
86.6 |
91 |
wikitoxic_obscene (2) |
85.9 |
91.9 |
93.1 |
wikitoxic_threat (2) |
77.9 |
93.7 |
97.6 |
wikitoxic_insult (2) |
77.8 |
91.1 |
92.3 |
wikitoxic_identityhate (2) |
86.4 |
89.8 |
95.7 |
hateoffensive (3) |
62.8 |
66.5 |
88.4 |
hatexplain (3) |
46.9 |
61 |
76.9 |
biasframes_offensive (2) |
62.5 |
86.6 |
89 |
biasframes_sex (2) |
87.6 |
89.6 |
92.6 |
biasframes_intent (2) |
54.8 |
88.6 |
89.9 |
agnews (4) |
81.9 |
82.8 |
90.9 |
yahootopics (10) |
37.7 |
65.6 |
74.3 |
trueteacher (2) |
51.2 |
54.9 |
86.6 |
spam (2) |
52.6 |
51.8 |
97.1 |
wellformedquery (2) |
49.9 |
40.4 |
82.7 |
manifesto (56) |
10.6 |
29.4 |
44.1 |
capsotu (21) |
23.2 |
69.4 |
74 |
mnli_m (2) |
93.1 |
nan |
93.1 |
mnli_mm (2) |
93.2 |
nan |
93.2 |
fevernli (2) |
89.3 |
nan |
89.5 |
anli_r1 (2) |
87.9 |
nan |
87.3 |
anli_r2 (2) |
76.3 |
nan |
78 |
anli_r3 (2) |
73.6 |
nan |
74.1 |
wanli (2) |
82.8 |
nan |
82.7 |
lingnli (2) |
90.2 |
nan |
89.6 |