🚀 camembert-base-xnli
這是原始的BaptisteDoyen/camembert-base-xnli模型的副本,因為該模型當前顯示404錯誤。以下是BaptisteDoyen/camembert-base-xnli頁面上的模型卡片內容。本模型是在XNLI數據集的法語部分上微調的Camembert-base模型,是少數適用於法語的零樣本分類模型之一 🇫🇷。
🚀 快速開始
此模型有兩種不同的使用方式:
作為零樣本序列分類器
classifier = pipeline("zero-shot-classification",
model="BaptisteDoyen/camembert-base-xnli")
sequence = "L'équipe de France joue aujourd'hui au Parc des Princes"
candidate_labels = ["sport","politique","science"]
hypothesis_template = "Ce texte parle de {}."
classifier(sequence, candidate_labels, hypothesis_template=hypothesis_template)
作為前提/假設檢查器
這裡的思路是計算形式為 $P(premise|hypothesis)$ 的概率。
nli_model = AutoModelForSequenceClassification.from_pretrained("BaptisteDoyen/camembert-base-xnli")
tokenizer = AutoTokenizer.from_pretrained("BaptisteDoyen/camembert-base-xnli")
premise = "le score pour les bleus est élevé"
hypothesis = "L'équipe de France a fait un bon match"
x = tokenizer.encode(premise, hypothesis, return_tensors='pt')
logits = nli_model(x)[0]
entail_contradiction_logits = logits[:,::2]
probs = entail_contradiction_logits.softmax(dim=1)
prob_label_is_true = probs[:,0]
prob_label_is_true[0].tolist() * 100
✨ 主要特性
- 基於Camembert-base模型,在XNLI數據集的法語部分上進行了微調。
- 是少數適用於法語的零樣本分類模型之一。
📦 安裝指南
使用以下命令加載訓練數據:
from datasets import load_dataset
dataset = load_dataset('xnli', 'fr')
📚 詳細文檔
模型描述
Camembert-base模型在XNLI數據集的法語部分上進行了微調,是少數適用於法語的零樣本分類模型之一 🇫🇷。
預期用途和限制
如何使用
有兩種不同的使用方式:
- 作為零樣本序列分類器:使用
pipeline
進行零樣本序列分類。
- 作為前提/假設檢查器:計算前提和假設之間的概率。
訓練數據
訓練數據是Facebook在2018年發佈的XNLI數據集的法語部分。可以使用datasets
庫輕鬆加載。
訓練/微調過程
訓練過程相當基礎,是在雲端使用單個GPU進行的。主要訓練參數如下:
lr = 2e-5 with lr_scheduler_type = "linear"
num_train_epochs = 4
batch_size = 12 (受GPU內存限制)
weight_decay = 0.01
metric_for_best_model = "eval_accuracy"
評估結果
在驗證集和測試集上獲得了以下結果:
數據集 |
準確率 |
驗證集 |
81.4 |
測試集 |
81.7 |
🔧 技術細節
該模型基於Camembert-base架構,在XNLI數據集的法語部分上進行了微調。訓練過程中使用了單個GPU,設置了特定的學習率、訓練輪數、批次大小等參數。
📄 許可證
本模型使用MIT許可證。
屬性 |
詳情 |
模型類型 |
零樣本分類模型 |
訓練數據 |
Facebook在2018年發佈的XNLI數據集的法語部分 |