/ Модель

Характеристики

Контекст
514 токенов
Параметры
81,2 млн
Лицензия
MIT
Архитектура
camembert · dense
Базовая модель
distilcamembert-base
Опубликована
2 мар 2022

distilcamembert-base-nli

Классификация текстаТекст → label5 профессий

Франкоязычная модель NLI для проверки текстового следования и классификации текстов по заданным меткам без дополнительного обучения.

1 664скачиваний за 30 дней14лайковвеса обновлены26 окт 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

DistilCamemBERT-NLI — франкоязычная модель компании CMarkea для распознавания текстового следования, противоречия и нейтрального отношения между посылкой и гипотезой, а также для классификации без обучения на заданных пользователем метках. Это дообученная для задачи NLI модель DistilCamemBERT с архитектурой CamemBERT и примерно 81,2 млн параметров; она принимает текстовые пары и выдаёт метки классов. Размер контекста — 514 токенов.

Модель обучена на XNLI из набора FLUE. Её можно применять для классификации отзывов по тональности или статей по темам с помощью формулировок гипотез и кандидатных меток на французском языке. По опубликованному сравнению, на указанном процессоре она выполняла вывод примерно вдвое быстрее CamemBERT-base-XNLI, но показывала более низкую точность на части тестов. Доступны форматы PyTorch, TensorFlow и ONNX. Лицензия — MIT.

Сценарии применения

  • проверка, следует ли гипотеза из текста
  • поиск противоречия между двумя предложениями
  • классификация французских отзывов по тональности без обучения
  • распределение французских статей по заданным темам
  • быстрая классификация текстов с пользовательскими метками

Ограничения

Модель предназначена для французского языка; её точность ниже, чем у некоторых сравниваемых моделей NLI, в частности на приведённом тесте XNLI. Качество zero-shot классификации зависит от формулировки гипотез и кандидатных меток.

Для каких профессий подходит5

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

DistilCamemBERT-NLI

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(premise=c\in{contradiction, entailment, neutral}\vert hypothesis)$$

Evaluation results

classprecision (%)f1-score (%)support
global77.7077.455,010
contradiction78.0079.541,670
entailment82.9078.871,670
neutral72.1874.041,670

Benchmark

We compare the DistilCamemBERT model to 2 other modelizations working on the french language. The first one BaptisteDoyen/camembert-base-xnli is based on well named CamemBERT, the french RoBERTa model and the second one MoritzLaurer/mDeBERTa-v3-base-mnli-xnli based on mDeBERTav3 a multilingual model. To compare the performances, the metrics of accuracy and MCC (Matthews Correlation Coefficient) were used. We used an AMD Ryzen 5 4500U @ 2.3GHz with 6 cores for mean inference time measure.

modeltime (ms)accuracy (%)MCC (x100)
cmarkea/distilcamembert-base-nli51.3577.4566.24
BaptisteDoyen/camembert-base-xnli105.081.7272.67
MoritzLaurer/mDeBERTa-v3-base-mnli-xnli299.1883.4375.15

Zero-shot classification

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(hypothesis=i\in\mathcal{C}|premise)=\frac{e^{P(premise=entailment\vert hypothesis=i)}}{\sum_{j\in\mathcal{C}}e^{P(premise=entailment\vert hypothesis=j)}}$$

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.

modeltime (ms)accuracy (%)MCC (x100)
cmarkea/distilcamembert-base-nli195.5480.5963.71
BaptisteDoyen/camembert-base-xnli378.3986.3773.74
MoritzLaurer/mDeBERTa-v3-base-mnli-xnli520.5884.9770.05

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".

modeltime (ms)accuracy (%)MCC (x100)
cmarkea/distilcamembert-base-nli217.7779.3070.55
BaptisteDoyen/camembert-base-xnli448.2770.764.10
MoritzLaurer/mDeBERTa-v3-base-mnli-xnli591.3464.4558.67

How to use DistilCamemBERT-NLI

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},
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · text-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
CamembertForSequenceClassification
Ревизия весов
e1b3671

0 моделей