Downloads · 30 days
8.5K
27% of all-time downloads
mtheo/camembert-base-xnli
camembert-base-xnli is a zero-shot classification model from mtheo. Use it when you need labels you did not train the model on. It is set up for transformers. The card lists the license as mit.
This is a copy of the original BaptisteDoyen/camembert-base-xnli model as it gives a 404 error right now.\ Here is the model card as it was on BaptisteDoyen/camembert-base-xnli page.
Downloads · 30 days
8.5K
27% of all-time downloads
All-time downloads
31.7K
Public
Parameters
111M
885 MB on disk
Likes
8
Public
Click a slice to open those files.
.bin443 MB · 50%
How the weights are stored.
F32111M · 100%
From the Hugging Face model README
This is a copy of the original BaptisteDoyen/camembert-base-xnli model as it gives a 404 error right now.
Here is the model card as it was on BaptisteDoyen/camembert-base-xnli page.
Camembert-base model fine-tuned on french part of XNLI dataset. One of the few Zero-Shot classification model working on French 🇫🇷
Two different usages :
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)
# outputs :
# {'sequence': "L'équipe de France joue aujourd'hui au Parc des Princes",
# 'labels': ['sport', 'politique', 'science'],
# 'scores': [0.8595073223114014, 0.10821866989135742, 0.0322740375995636]}
# load model and tokenizer
nli_model = AutoModelForSequenceClassification.from_pretrained("BaptisteDoyen/camembert-base-xnli")
tokenizer = AutoTokenizer.from_pretrained("BaptisteDoyen/camembert-base-xnli")
# sequences
premise = "le score pour les bleus est élevé"
hypothesis = "L'équipe de France a fait un bon match"
# tokenize and run through model
x = tokenizer.encode(premise, hypothesis, return_tensors='pt')
logits = nli_model(x)[0]
# we throw away "neutral" (dim 1) and take the probability of
# "entailment" (0) as the probability of the label being true
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
# outputs
# 86.40775084495544
Training data is the french fold of the XNLI dataset released in 2018 by Facebook. Available with great ease using the datasets library :
from datasets import load_dataset
dataset = load_dataset('xnli', 'fr')
Training procedure is here pretty basic and was performed on the cloud using a single GPU. Main training parameters :
lr = 2e-5 with lr_scheduler_type = "linear"num_train_epochs = 4batch_size = 12 (limited by GPU-memory)weight_decay = 0.01metric_for_best_model = "eval_accuracy"We obtain the following results on validation and test sets:
| Set | Accuracy |
|---|---|
| validation | 81.4 |
| test | 81.7 |