Xlm Roberta Large It Mnli
基於xlm-roberta-large微調的意大利語零樣本分類模型,支持多語言文本分類
下載量 937
發布時間 : 3/2/2022
模型概述
該模型在從MNLI語料庫自動翻譯的意大利語子集上進行微調,專用於意大利語文本的零樣本分類,也可用於其他語言的分類任務。
模型特點
多語言支持
基於XLM-RoBERTa-large預訓練,支持100種語言的文本分類
零樣本分類
無需特定領域訓練即可對新類別進行分類
多標籤分類
支持同時為文本分配多個相關標籤
模型能力
意大利語文本分類
跨語言文本分類
多標籤分類
自然語言推理
使用案例
文本分類
歷史文本分類
對歷史相關文本進行分類,識別其主題
準確區分戰爭、歷史等類別
地理信息分類
對地理相關文本進行分類
準確識別地理相關內容
🚀 XLM-roBERTa-large-it-mnli
這個模型基於xlm-roberta-large
,在MNLI語料庫的自動翻譯版本的NLI數據子集上進行微調。它主要用於零樣本文本分類任務,能對意大利語等多種語言的文本進行分類。
🚀 快速開始
零樣本分類管道加載模型
from transformers import pipeline
classifier = pipeline("zero-shot-classification",
model="Jiva/xlm-roberta-large-it-mnli", device=0, use_fast=True, multi_label=True)
分類示例
# 我們將對以下關於撒丁島的維基百科條目進行分類
sequence_to_classify = "La Sardegna è una regione italiana a statuto speciale di 1 592 730 abitanti con capoluogo Cagliari, la cui denominazione bilingue utilizzata nella comunicazione ufficiale è Regione Autonoma della Sardegna / Regione Autònoma de Sardigna."
# 我們可以用意大利語指定候選標籤
candidate_labels = ["geografia", "politica", "macchine", "cibo", "moda"]
classifier(sequence_to_classify, candidate_labels)
# {'labels': ['geografia', 'moda', 'politica', 'macchine', 'cibo'],
# 'scores': [0.38871392607688904, 0.22633370757102966, 0.19398456811904907, 0.13735772669315338, 0.13708525896072388]}
指定假設模板
sequence_to_classify = "La Sardegna è una regione italiana a statuto speciale di 1 592 730 abitanti con capoluogo Cagliari, la cui denominazione bilingue utilizzata nella comunicazione ufficiale è Regione Autonoma della Sardegna / Regione Autònoma de Sardigna."
candidate_labels = ["geografia", "politica", "macchine", "cibo", "moda"]
hypothesis_template = "si parla di {}"
# classifier(sequence_to_classify, candidate_labels, hypothesis_template=hypothesis_template)
# 'scores': [0.6068345904350281, 0.34715887904167175, 0.32433947920799255, 0.3068877160549164, 0.18744681775569916]}
手動使用PyTorch
# 將序列作為NLI前提,標籤作為假設
from transformers import AutoModelForSequenceClassification, AutoTokenizer
nli_model = AutoModelForSequenceClassification.from_pretrained('Jiva/xlm-roberta-large-it-mnli')
tokenizer = AutoTokenizer.from_pretrained('Jiva/xlm-roberta-large-it-mnli')
premise = sequence
hypothesis = f'si parla di {}.'
# 通過在MNLI上預訓練的模型運行
x = tokenizer.encode(premise, hypothesis, return_tensors='pt',
truncation_strategy='only_first')
logits = nli_model(x.to(device))[0]
# 我們去掉“中立”(維度1),並將“蘊含”(2)的概率作為標籤為真的概率
entail_contradiction_logits = logits[:,[0,2]]
probs = entail_contradiction_logits.softmax(dim=1)
prob_label_is_true = probs[:,1]
✨ 主要特性
- 多語言支持:基於預訓練的
xlm-roberta-large
模型,該模型在100種不同語言上進行了預訓練,因此除了意大利語,在其他語言的零樣本文本分類任務中也表現出一定的有效性。 - 零樣本分類:可用於零樣本的文本分類任務,無需針對特定任務進行大量的標註數據訓練。
- 微調優化:在MNLI語料庫的自動翻譯版本的NLI數據子集上進行微調,提高了在意大利語相關任務上的性能。
📦 安裝指南
文檔未提及具體安裝步驟,可參考Hugging Face Transformers庫的安裝方法:
pip install transformers
💻 使用示例
基礎用法
from transformers import pipeline
classifier = pipeline("zero-shot-classification",
model="Jiva/xlm-roberta-large-it-mnli", device=0, use_fast=True, multi_label=True)
sequence_to_classify = "La Sardegna è una regione italiana a statuto speciale di 1 592 730 abitanti con capoluogo Cagliari, la cui denominazione bilingue utilizzata nella comunicazione ufficiale è Regione Autonoma della Sardegna / Regione Autònoma de Sardigna."
candidate_labels = ["geografia", "politica", "macchine", "cibo", "moda"]
result = classifier(sequence_to_classify, candidate_labels)
print(result)
高級用法
# 指定假設模板
sequence_to_classify = "La Sardegna è una regione italiana a statuto speciale di 1 592 730 abitanti con capoluogo Cagliari, la cui denominazione bilingue utilizzata nella comunicazione ufficiale è Regione Autonoma della Sardegna / Regione Autònoma de Sardigna."
candidate_labels = ["geografia", "politica", "macchine", "cibo", "moda"]
hypothesis_template = "si parla di {}"
result = classifier(sequence_to_classify, candidate_labels, hypothesis_template=hypothesis_template)
print(result)
📚 詳細文檔
模型描述
該模型以xlm-roberta-large為基礎,在從MNLI語料庫的自動翻譯版本中提取的NLI數據子集上進行微調。它旨在用於零樣本文本分類,例如使用Hugging Face的ZeroShotClassificationPipeline。
預期用途
此模型旨在用於意大利語文本的零樣本分類。由於基礎模型在100種不同語言上進行了預訓練,因此該模型在上述語言之外的其他語言中也顯示出一定的有效性。有關預訓練語言的完整列表,請參閱XLM Roberata論文的附錄A。對於僅英語的分類任務,建議使用bart-large-mnli或蒸餾的bart MNLI模型。
🔧 技術細節
版本0.1
該模型現在已在完整的訓練集上進行了重新訓練。由於翻譯模型的錯誤翻譯,大約1000個句子對已從數據集中移除。
指標 | 值 |
---|---|
學習率 | 4e-6 |
優化器 | AdamW |
批量大小 | 80 |
MCC | 0.77 |
訓練損失 | 0.34 |
評估損失 | 0.40 |
停止步驟 | 9754 |
版本0.0
該模型在100種語言的數據集上進行了預訓練,如原始論文所述。然後在MNLI數據集的意大利語翻譯版本上針對NLI任務進行了微調(到目前為止僅使用了訓練集的85%)。用於翻譯文本的模型是Helsinki-NLP/opus-mt-en-it,最大輸出序列長度為120。該模型以學習率4e-6和批量大小80進行了1個epoch的訓練,目前在剩餘15%的訓練集上的準確率為82%。
📄 許可證
本模型採用MIT許可證。
Distilbert Base Uncased Finetuned Sst 2 English
Apache-2.0
基於DistilBERT-base-uncased在SST-2情感分析數據集上微調的文本分類模型,準確率91.3%
文本分類 英語
D
distilbert
5.2M
746
Xlm Roberta Base Language Detection
MIT
基於XLM-RoBERTa的多語言檢測模型,支持20種語言的文本分類
文本分類
Transformers 支持多種語言

X
papluca
2.7M
333
Roberta Hate Speech Dynabench R4 Target
該模型通過動態生成數據集來改進在線仇恨檢測,專注於從最差案例中學習以提高檢測效果。
文本分類
Transformers 英語

R
facebook
2.0M
80
Bert Base Multilingual Uncased Sentiment
MIT
基於bert-base-multilingual-uncased微調的多語言情感分析模型,支持6種語言的商品評論情感分析
文本分類 支持多種語言
B
nlptown
1.8M
371
Emotion English Distilroberta Base
基於DistilRoBERTa-base微調的英文文本情感分類模型,可預測埃克曼六種基本情緒及中性類別。
文本分類
Transformers 英語

E
j-hartmann
1.1M
402
Robertuito Sentiment Analysis
基於RoBERTuito的西班牙語推文情感分析模型,支持POS(積極)/NEG(消極)/NEU(中性)三類情感分類
文本分類 西班牙語
R
pysentimiento
1.0M
88
Finbert Tone
FinBERT是一款基於金融通訊文本預訓練的BERT模型,專注於金融自然語言處理領域。finbert-tone是其微調版本,用於金融情感分析任務。
文本分類
Transformers 英語

F
yiyanghkust
998.46k
178
Roberta Base Go Emotions
MIT
基於RoBERTa-base的多標籤情感分類模型,在go_emotions數據集上訓練,支持28種情感標籤識別。
文本分類
Transformers 英語

R
SamLowe
848.12k
565
Xlm Emo T
XLM-EMO是一個基於XLM-T模型微調的多語言情感分析模型,支持19種語言,專門針對社交媒體文本的情感預測。
文本分類
Transformers 其他

X
MilaNLProc
692.30k
7
Deberta V3 Base Mnli Fever Anli
MIT
基於MultiNLI、Fever-NLI和ANLI數據集訓練的DeBERTa-v3模型,擅長零樣本分類和自然語言推理任務
文本分類
Transformers 英語

D
MoritzLaurer
613.93k
204
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98