🚀 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版本可能會解決一些運行該模型時出現的問題。