🚀 deberta-v3-base-zeroshot-v1
本模型专为使用Hugging Face管道进行零样本分类而设计,在零样本分类任务上,相比作者在Hugging Face hub(https://huggingface.co/MoritzLaurer )上的其他零样本模型,性能有显著提升。
🚀 快速开始
本模型可完成一项通用任务:给定一段文本,判断一个假设是true
还是not_true
(也称为entailment
与not_entailment
)。此任务格式基于自然语言推理任务(NLI),具有很强的通用性,任何分类任务都可转化为该任务。
✨ 主要特性
- 专为零样本分类设计,在零样本分类任务上表现优于作者其他相关模型。
- 基于通用任务格式,可将任何分类任务转化为此任务进行处理。
- 相比其他NLI模型,该模型仅预测两个类别(
entailment
与not_entailment
),而非三个类别(entailment/neutral/contradiction)。
📦 安装指南
暂未提及具体安装步骤,可参考Hugging Face Transformers库的安装方式。
💻 使用示例
基础用法
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-base-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)
📚 详细文档
训练数据
该模型在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"
数据和训练详情
数据准备、模型训练和评估的代码完全开源,可查看:https://github.com/MoritzLaurer/zeroshot-classifier/tree/main
局限性和偏差
该模型仅能处理文本分类任务。有关潜在偏差,请参考原始DeBERTa论文以及不同数据集的相关论文。
许可证
基础模型(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},
}
合作建议或疑问
如果您有合作想法或疑问,请通过m{dot}laurer{at}vu{dot}nl联系作者,或访问LinkedIn。
调试和问题
请注意,DeBERTa-v3于2021年12月6日发布,较旧版本的HF Transformers库在运行该模型时可能会出现问题(例如分词器相关问题)。使用Transformers >= 4.13版本可能会解决部分问题。
🔧 技术细节
该模型基于自然语言推理任务(NLI)的通用任务格式进行设计,通过将各种分类任务转化为判断假设是否成立的任务,实现零样本分类。在训练过程中,使用了多种分类任务和NLI数据集的混合数据,以提升模型的泛化能力。
📄 许可证
基础模型(DeBERTa-v3)遵循MIT许可证发布。模型微调所用的数据集遵循多种不同的许可证,具体信息可参考:https://docs.google.com/spreadsheets/d/1Z18tMh02IiWgh6o8pfoMiI_LH4IXpr78wd_nmNd5FaE/edit?usp=sharing 。
📦 模型信息
属性 |
详情 |
模型类型 |
用于零样本分类的DeBERTa-v3-base模型 |
训练数据 |
26个分类任务(约400k文本)和5个NLI数据集(约885k文本) |
⚠️ 重要提示
较旧版本的HF Transformers库在运行该模型时可能会出现问题,使用Transformers >= 4.13版本可能会解决部分问题。
💡 使用建议
若有合作想法或疑问,可通过m{dot}laurer{at}vu{dot}nl联系作者,或访问LinkedIn。