/ Модель

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

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

distilcamembert-base-sentiment

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

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

37 981скачиваний за 30 дней40лайковвеса обновлены26 окт 2024

Бенчмарки

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

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

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

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

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

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

DistilCamemBERT-Sentiment — модель cmarkea для анализа тональности франкоязычных отзывов. Она дообучена на базе cmarkea/distilcamembert-base и использует архитектуру CamemBERT для классификации текста по пяти оценкам: от одной звезды (крайне негативная оценка) до пяти звёзд (крайне положительная). При обучении использовались отзывы Amazon и рецензии Allociné, сочетание коротких и длинных текстов.

Модель предназначена для анализа отзывов о товарах и фильмах, включая присвоение рейтинга и выделение негативных, нейтральных и позитивных оценок. В README заявлено сокращение времени инференса примерно вдвое по сравнению с некоторыми моделями на CamemBERT и приведены результаты оценки на тестовых данных. Модель содержит 81,2 млн параметров, поддерживает контекст до 514 токенов и доступна в форматах PyTorch, TensorFlow, ONNX и safetensors.

Модель рассчитана на французский язык. В тестах точность точного совпадения составила 61,01%, а точность попадания верной оценки в две наиболее вероятные — 88,80%; результаты зависят от данных и постановки задачи. Лицензия — MIT.

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

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

Ограничения

Модель ориентирована на французские отзывы и шкалу из пяти оценок; перенос на другие языки и типы текстов не подтверждён. Точная точность на приведённом тесте составляет 61,01%, поэтому предсказанный рейтинг может отличаться от исходной оценки.

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

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

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

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

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

Открыть на Hugging Face

DistilCamemBERT-Sentiment

We present DistilCamemBERT-Sentiment, which is DistilCamemBERT fine-tuned for the sentiment analysis task for the French language. This model is built using two datasets: Amazon Reviews and Allociné.fr to minimize the bias. Indeed, Amazon reviews are similar in messages and relatively shorts, contrary to Allociné critics, who are long and rich texts.

This modelization is close to tblard/tf-allocine 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. To counteract this effect, we propose this modelization which divides the inference time by two with the same consumption power thanks to DistilCamemBERT.

Dataset

The dataset comprises 204,993 reviews for training and 4,999 reviews for the test from Amazon, and 235,516 and 4,729 critics from Allocine website. The dataset is labeled into five categories:

  • 1 star: represents a terrible appreciation,
  • 2 stars: bad appreciation,
  • 3 stars: neutral appreciation,
  • 4 stars: good appreciation,
  • 5 stars: excellent appreciation.

Evaluation results

In addition of accuracy (called here exact accuracy) in order to be robust to +/-1 star estimation errors, we will take the following definition as a performance measure:

$$\mathrm{top!-!2; acc}=\frac{1}{|\mathcal{O}|}\sum_{i\in\mathcal{O}}\sum_{0\leq l < 2}\mathbb{1}(\hat{f}_{i,l}=y_i)$$

where \(\hat{f}_l\) is the l-th largest predicted label, \(y\) the true label, \(\mathcal{O}\) is the test set of the observations and \(\mathbb{1}\) is the indicator function.

classexact accuracy (%)top-2 acc (%)support
global61.0188.809,698
1 star87.2177.171,905
2 stars79.1984.751,935
3 stars77.8578.981,974
4 stars78.6190.221,952
5 stars85.9682.921,932

Benchmark

This model is compared to 3 reference models (see below). As each model doesn't have the exact definition of targets, we detail the performance measure used for each. An AMD Ryzen 5 4500U @ 2.3GHz with 6 cores was used for the mean inference time measure.

bert-base-multilingual-uncased-sentiment

nlptown/bert-base-multilingual-uncased-sentiment is based on BERT model in the multilingual and uncased version. This sentiment analyzer is trained on Amazon reviews, similar to our model. Hence the targets and their definitions are the same.

modeltime (ms)exact accuracy (%)top-2 acc (%)
cmarkea/distilcamembert-base-sentiment95.5661.0188.80
nlptown/bert-base-multilingual-uncased-sentiment187.7054.4182.82

tf-allociné and barthez-sentiment-classification

tblard/tf-allocine based on CamemBERT model and moussaKam/barthez-sentiment-classification based on BARThez use the same bi-class definition between them. To bring this back to a two-class problem, we will only consider the "1 star" and "2 stars" labels for the negative sentiments and "4 stars" and "5 stars" for positive sentiments. We exclude the "3 stars" which can be interpreted as a neutral class. In this context, the problem of +/-1 star estimation errors disappears. Then we use only the classical accuracy definition.

modeltime (ms)exact accuracy (%)
cmarkea/distilcamembert-base-sentiment95.5697.52
tblard/tf-allocine329.7495.69
moussaKam/barthez-sentiment-classification197.9594.29

How to use DistilCamemBERT-Sentiment

from transformers import pipeline

analyzer = pipeline(
    task='text-classification',
    model="cmarkea/distilcamembert-base-sentiment",
    tokenizer="cmarkea/distilcamembert-base-sentiment"
)
result = analyzer(
    "J'aime me promener en forêt même si ça me donne mal aux pieds.",
    return_all_scores=True
)

result
[{'label': '1 star',
  'score': 0.047529436647892},
 {'label': '2 stars',
  'score': 0.14150355756282806},
 {'label': '3 stars',
  'score': 0.3586442470550537},
 {'label': '4 stars',
  'score': 0.3181498646736145},
 {'label': '5 stars',
  'score': 0.13417290151119232}]

Optimum + ONNX

from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer, pipeline

HUB_MODEL = "cmarkea/distilcamembert-base-sentiment"

tokenizer = AutoTokenizer.from_pretrained(HUB_MODEL)
model = ORTModelForSequenceClassification.from_pretrained(HUB_MODEL)
onnx_qa = pipeline("text-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
Ревизия весов
5716940

0 моделей