🚀 deberta-v3-large-zeroshot-v1
该模型专为使用Hugging Face管道进行零样本分类而设计,在零样本分类任务上,相比Hugging Face hub上作者的其他零样本模型有显著提升。它能够完成一项通用任务:根据给定文本判断假设是否为true
或not_true
(也称为entailment
与not_entailment
)。
🚀 快速开始
简单的零样本分类管道
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-large-zeroshot-v1")
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)
✨ 主要特性
- 专为零样本分类设计,可通过Hugging Face管道使用。
- 相比作者在Hugging Face hub上的其他零样本模型,在零样本分类任务上表现更优。
- 能够完成通用任务,可将任何分类任务转化为判断假设是否为
true
或not_true
的任务。
📦 安装指南
文档未提及具体安装步骤,可参考Hugging Face相关文档进行安装。
💻 使用示例
基础用法
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-large-zeroshot-v1")
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)
📚 详细文档
模型描述
该模型专为使用Hugging Face管道进行零样本分类而设计。在零样本分类方面,该模型比作者在Hugging Face hub上的其他零样本模型(https://huggingface.co/MoritzLaurer )有显著提升。
该模型可以完成一项通用任务:根据给定文本(也称为前提)判断一个假设是true
还是not_true
(也称为entailment
与not_entailment
)。此任务格式基于自然语言推理任务(NLI)。该任务具有通用性,任何分类任务都可以重新表述为这个任务。
训练数据
该模型在27个任务和310个类别的混合数据上进行训练,这些数据已被重新格式化为通用格式。
- 26个分类任务,约400k文本:
'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'.
每个数据集的详细信息请见:https://docs.google.com/spreadsheets/d/1Z18tMh02IiWgh6o8pfoMiI_LH4IXpr78wd_nmNd5FaE/edit?usp=sharing
- 五个NLI数据集,约885k文本:"mnli", "anli", "fever", "wanli", "ling"
请注意,与其他NLI模型相比,该模型预测两个类别(entailment
与not_entailment
),而不是三个类别(entailment/neutral/contradiction)
数据和训练详情
准备数据以及训练和评估模型的代码完全开源,地址为:https://github.com/MoritzLaurer/zeroshot-classifier/tree/main
🔧 技术细节
该模型基于自然语言推理任务(NLI),能够将任何分类任务转化为判断假设是否为true
或not_true
的任务。在训练时,使用了27个任务和310个类别的混合数据,这些数据被重新格式化为通用格式。
📄 许可证
基础模型(DeBERTa-v3)根据MIT许可证发布。模型微调所用的数据集根据不同的许可证发布。以下电子表格提供了用于微调的非NLI数据集的概述,其中包含许可证、基础论文等信息:https://docs.google.com/spreadsheets/d/1Z18tMh02IiWgh6o8pfoMiI_LH4IXpr78wd_nmNd5FaE/edit?usp=sharing
此外,该模型还在以下NLI数据集上进行了训练:MNLI、ANLI、WANLI、LING-NLI、FEVER-NLI。
引用
如果使用此模型,请引用:
@article{laurer_less_2023,
title = {Less {Annotating}, {More} {Classifying}: {Addressing} the {Data} {Scarcity} {Issue} of {Supervised} {Machine} {Learning} with {Deep} {Transfer} {Learning} and {BERT}-{NLI}},
issn = {1047-1987, 1476-4989},
shorttitle = {Less {Annotating}, {More} {Classifying}},
url = {https://www.cambridge.org/core/product/identifier/S1047198723000207/type/journal_article},
doi = {10.1017/pan.2023.20},
language = {en},
urldate = {2023-06-20},
journal = {Political Analysis},
author = {Laurer, Moritz and Van Atteveldt, Wouter and Casas, Andreu and Welbers, Kasper},
month = jun,
year = {2023},
pages = {1--33},
}
限制和偏差
该模型仅能处理文本分类任务。
有关潜在偏差,请参考原始DeBERTa论文以及不同数据集的相关论文。
合作建议或问题咨询
如果您有问题或合作建议,请通过m{dot}laurer{at}vu{dot}nl联系我,或在LinkedIn上与我交流。
调试和问题解决
请注意,DeBERTa-v3于2021年12月6日发布,较旧版本的HF Transformers在运行该模型时可能会出现问题(例如,分词器出现问题)。使用Transformers >= 4.13可能会解决一些问题。
⚠️ 重要提示
该模型仅能处理文本分类任务。有关潜在偏差,请参考原始DeBERTa论文以及不同数据集的相关论文。
💡 使用建议
使用Transformers >= 4.13版本可能会解决一些运行该模型时出现的问题。