We present DistilCamemBERT-NLI, which is
DistilCamemBERT
fine-tuned for the Natural Language Inference (NLI) task for the french language, also known as recognizing textual entailment (RTE). This model is constructed on the XNLI dataset, which determines whether a premise entails, contradicts or neither entails or contradicts a hypothesis.
This modelization is close to
BaptisteDoyen/camembert-base-xnli
based on
CamemBERT
model. The problem of the modelizations based on CamemBERT is at the scaling moment, for the production phase, for example. Indeed, inference cost can be a technological issue especially in the context of cross-encoding like this task. To counteract this effect, we propose this modelization which divides the inference time by 2 with the same consumption power, thanks to DistilCamemBERT.
Dataset
The dataset XNLI from
FLUE
comprises 392,702 premises with their hypothesis for the train and 5,010 couples for the test. The goal is to predict textual entailment (does sentence A imply/contradict/neither sentence B?) and is a classification task (given two sentences, predict one of three labels). Sentence A is called
premise
, and sentence B is called
hypothesis
, then the goal of modelization is determined as follows:
P
(
p
re
mi
se
=
c
∈
{
co
n
t
r
a
d
i
c
t
i
o
n
,
e
n
t
ai
l
m
e
n
t
,
n
e
u
t
r
a
l
}
∣
h
y
p
o
t
h
es
i
s
)
The main advantage of such modelization is to create a zero-shot classifier allowing text classification without training. This task can be summarized by:
P
(
h
y
p
o
t
h
es
i
s
=
i
∈
C
∣
p
re
mi
se
)
=
∑
j
∈
C
e
P
(
p
re
mi
se
=
e
n
t
ai
l
m
e
n
t
∣
h
y
p
o
t
h
es
i
s
=
j
)
e
P
(
p
re
mi
se
=
e
n
t
ai
l
m
e
n
t
∣
h
y
p
o
t
h
es
i
s
=
i
)
For this part, we use two datasets, the first one:
allocine
used to train the sentiment analysis models. The dataset comprises two classes: "positif" and "négatif" appreciation of movie reviews. Here we use "Ce commentaire est {}." as the hypothesis template and "positif" and "négatif" as candidate labels.
The second one:
mlsum
used to train the summarization models. In this aim, we aggregate sub-topics and select a few of them. We use the articles summary part to predict their topics. In this case, the hypothesis template used is "C'est un article traitant de {}." and the candidate labels are: "économie", "politique", "sport" and "science".
from transformers import pipeline
classifier = pipeline(
task='zero-shot-classification',
model="cmarkea/distilcamembert-base-nli",
tokenizer="cmarkea/distilcamembert-base-nli"
)
result = classifier (
sequences="Le style très cinéphile de Quentin Tarantino ""se reconnaît entre autres par sa narration postmoderne ""et non linéaire, ses dialogues travaillés souvent ""émaillés de références à la culture populaire, et ses ""scènes hautement esthétiques mais d'une violence ""extrême, inspirées de films d'exploitation, d'arts ""martiaux ou de western spaghetti.",
candidate_labels="cinéma, technologie, littérature, politique",
hypothesis_template="Ce texte parle de {}."
)
result
{"labels": ["cinéma",
"littérature",
"technologie",
"politique"],
"scores": [0.7164115309715271,
0.12878799438476562,
0.1092301607131958,
0.0455702543258667]}
Optimum + ONNX
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer, pipeline
HUB_MODEL = "cmarkea/distilcamembert-base-nli"
tokenizer = AutoTokenizer.from_pretrained(HUB_MODEL)
model = ORTModelForSequenceClassification.from_pretrained(HUB_MODEL)
onnx_qa = pipeline("zero-shot-classification", model=model, tokenizer=tokenizer)
# Quantized onnx model
quantized_model = ORTModelForSequenceClassification.from_pretrained(
HUB_MODEL, file_name="model_quantized.onnx"
)
Citation
@inproceedings{delestre:hal-03674695,
TITLE = {{DistilCamemBERT : une distillation du mod{\`e}le fran{\c c}ais CamemBERT}},
AUTHOR = {Delestre, Cyrile and Amar, Abibatou},
URL = {https://hal.archives-ouvertes.fr/hal-03674695},
BOOKTITLE = {{CAp (Conf{\'e}rence sur l'Apprentissage automatique)}},
ADDRESS = {Vannes, France},
YEAR = {2022},
MONTH = Jul,
KEYWORDS = {NLP ; Transformers ; CamemBERT ; Distillation},
PDF = {https://hal.archives-ouvertes.fr/hal-03674695/file/cap2022.pdf},
HAL_ID = {hal-03674695},
HAL_VERSION = {v1},
}
Runs of cmarkea distilcamembert-base-nli on huggingface.co
749
Total runs
-2
24-hour runs
-5
3-day runs
-6
7-day runs
128
30-day runs
More Information About distilcamembert-base-nli huggingface.co Model
distilcamembert-base-nli huggingface.co is an AI model on huggingface.co that provides distilcamembert-base-nli's model effect (), which can be used instantly with this cmarkea distilcamembert-base-nli model. huggingface.co supports a free trial of the distilcamembert-base-nli model, and also provides paid use of the distilcamembert-base-nli. Support call distilcamembert-base-nli model through api, including Node.js, Python, http.
distilcamembert-base-nli huggingface.co is an online trial and call api platform, which integrates distilcamembert-base-nli's modeling effects, including api services, and provides a free online trial of distilcamembert-base-nli, you can try distilcamembert-base-nli online for free by clicking the link below.
cmarkea distilcamembert-base-nli online free url in huggingface.co:
distilcamembert-base-nli is an open source model from GitHub that offers a free installation service, and any user can find distilcamembert-base-nli on GitHub to install. At the same time, huggingface.co provides the effect of distilcamembert-base-nli install, users can directly use distilcamembert-base-nli installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
distilcamembert-base-nli install url in huggingface.co: