🚀 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数据集的法语部分 |