🚀 drama-large-xnli-anli
本模型是 facebook/drama-large 在XNLI和ANLI數據集上的微調版本。它可用於零樣本分類任務,支持多種語言,為跨語言的文本分類提供了強大的解決方案。
🚀 快速開始
模型描述
DRAMA: Diverse Augmentation from Large Language Models to Smaller Dense Retrievers。
Xueguang Ma, Xi Victoria Lin, Barlas Oguz, Jimmy Lin, Wen - tau Yih, Xilun Chen, arXiv 2025
如何使用模型
零樣本分類管道
可以使用 zero-shot-classification
管道加載模型,示例代碼如下:
from transformers import AutoTokenizer, pipeline
model = "mjwong/drama-large-xnli-anli"
classifier = pipeline("zero-shot-classification",
model=model)
然後可以使用此管道將序列分類到指定的任何類別名稱中。
sequence_to_classify = "one day I will see the world"
candidate_labels = ['travel', 'cooking', 'dancing']
classifier(sequence_to_classify, candidate_labels)
如果多個候選標籤都可能正確,可以傳遞 multi_class=True
來獨立計算每個類別:
candidate_labels = ['travel', 'cooking', 'dancing', 'exploration']
classifier(sequence_to_classify, candidate_labels, multi_class=True)
手動使用PyTorch
該模型也可用於NLI任務,示例代碼如下:
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model_name = "mjwong/drama-large-xnli-anli"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
premise = "But I thought you'd sworn off coffee."
hypothesis = "I thought that you vowed to drink more coffee."
input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
output = model(input["input_ids"].to(device))
prediction = torch.softmax(output["logits"][0], -1).tolist()
label_names = ["entailment", "neutral", "contradiction"]
prediction = {name: round(float(pred) * 100, 2) for pred, name in zip(prediction, label_names)}
print(prediction)
📊 評估結果
多語言XNLI測試集評估
該模型使用XNLI測試集在15種語言上進行了評估,評估指標為準確率。
數據集 |
英語 (en) |
阿拉伯語 (ar) |
保加利亞語 (bg) |
德語 (de) |
希臘語 (el) |
西班牙語 (es) |
法語 (fr) |
印地語 (hi) |
俄語 (ru) |
斯瓦希里語 (sw) |
泰語 (th) |
土耳其語 (tr) |
烏爾都語 (ur) |
越南語 (vi) |
中文 (zh) |
drama-base-xnli-anli |
0.788 |
0.689 |
0.708 |
0.715 |
0.696 |
0.732 |
0.737 |
0.647 |
0.711 |
0.636 |
0.676 |
0.664 |
0.588 |
0.708 |
0.710 |
drama-large-xnli-anli |
0.799 |
0.698 |
0.730 |
0.721 |
0.717 |
0.754 |
0.754 |
0.649 |
0.718 |
0.652 |
0.678 |
0.656 |
0.594 |
0.719 |
0.719 |
MultiNLI開發集和ANLI測試集評估
該模型還使用MultiNLI開發集和ANLI測試集進行了評估,評估指標為準確率。
🔧 技術細節
訓練超參數
訓練期間使用了以下超參數:
- 學習率(learning_rate):2e - 05
- 訓練批次大小(train_batch_size):16
- 評估批次大小(eval_batch_size):16
- 隨機種子(seed):42
- 優化器(optimizer):Adam,其中betas = (0.9, 0.999),epsilon = 1e - 08
- 學習率調度器類型(lr_scheduler_type):線性
- 學習率調度器預熱比例(lr_scheduler_warmup_ratio):0.1
框架版本
- Transformers:4.49.0
- Pytorch:2.6.0 + cu124
- Datasets:3.2.0
- Tokenizers:0.21.0
📄 許可證
本模型使用CC - BY - NC - 4.0許可證。
📦 數據集
🛠️ 任務類型
零樣本分類(zero - shot - classification)
📋 模型信息
屬性 |
詳情 |
模型類型 |
drama - large - xnli - anli |
基礎模型 |
facebook/drama - large |
支持語言 |
多語言(英語、阿拉伯語、保加利亞語、德語、希臘語、西班牙語、法語、印地語、俄語、斯瓦希里語、泰語、土耳其語、烏爾都語、越南語、中文) |