/ Модель

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

Контекст
1 024 токена
Параметры
253 млн
Лицензия
Apache 2.0
Архитектура
bart · dense
Базовая модель
bart-large-mnli
Опубликована
2 мар 2022

bart-large-mnli-yahoo-answers

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

Дообученная на темах Yahoo Answers модель BART-large для классификации текстов по заданным пользователем меткам без отдельного обучения на этих классах.

457скачиваний за 30 дней14лайковвеса обновлены15 сен 2025

Бенчмарки

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

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

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

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

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

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

joeddav/bart-large-mnli-yahoo-answers — модель на архитектуре BART-large, разработанная на основе facebook/bart-large-mnli и дополнительно дообученная на классификации тем Yahoo Answers. Она сопоставляет текст с предложенными пользователем метками и подходит для классификации тем по меткам, которые могли не встречаться при обучении. Для лучшего результата автор рекомендует шаблон гипотезы «This text is about {}.»; модель обучалась на пяти из десяти тем Yahoo Answers.

В оценке на Yahoo Answers F1 составила 0,68 для невиденных при обучении меток и 0,72 для виденных; авторы корректировали оценки виденных меток на 30 процентных пунктов. Модель содержит 252,8 млн параметров, принимает текст с контекстом до 1024 токенов и рассчитана на английский язык. Распространяется по лицензии Apache-2.0.

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

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

Ограничения

Лучше всего работает для классификации тем; для хорошего результата рекомендуется шаблон «This text is about {}.». На Yahoo Answers F1 составила 0,68 для меток, не встречавшихся при обучении, и 0,72 для встречавшихся; при оценке авторы корректировали оценки известных меток на 30 процентных пунктов.

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

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

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

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

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

Открыть на Hugging Face

bart-lage-mnli-yahoo-answers

Model Description

This model takes facebook/bart-large-mnli and fine-tunes it on Yahoo Answers topic classification. It can be used to predict whether a topic label can be assigned to a given sequence, whether or not the label has been seen before.

You can play with an interactive demo of this zero-shot technique with this model, as well as the non-finetuned facebook/bart-large-mnli, here.

Intended Usage

This model was fine-tuned on topic classification and will perform best at zero-shot topic classification. Use hypothesis_template="This text is about {}." as this is the template used during fine-tuning.

For settings other than topic classification, you can use any model pre-trained on MNLI such as facebook/bart-large-mnli or roberta-large-mnli with the same code as written below.

With the zero-shot classification pipeline

The model can be used with the zero-shot-classification pipeline like so:

from transformers import pipeline
nlp = pipeline("zero-shot-classification", model="joeddav/bart-large-mnli-yahoo-answers")

sequence_to_classify = "Who are you voting for in 2020?"
candidate_labels = ["Europe", "public health", "politics", "elections"]
hypothesis_template = "This text is about {}."
nlp(sequence_to_classify, candidate_labels, multi_class=True, hypothesis_template=hypothesis_template)

With manual PyTorch

# pose sequence as a NLI premise and label as a hypothesis
from transformers import BartForSequenceClassification, BartTokenizer
nli_model = BartForSequenceClassification.from_pretrained('joeddav/bart-large-mnli-yahoo-answers')
tokenizer = BartTokenizer.from_pretrained('joeddav/bart-large-mnli-yahoo-answers')

premise = sequence
hypothesis = f'This text is about {label}.'

# run through model pre-trained on MNLI
x = tokenizer.encode(premise, hypothesis, return_tensors='pt',
                        max_length=tokenizer.max_len,
                        truncation_strategy='only_first')
logits = nli_model(x.to(device))[0]

# we throw away "neutral" (dim 1) and take the probability of
# "entailment" (2) as the probability of the label being true 
entail_contradiction_logits = logits[:,[0,2]]
probs = entail_contradiction_logits.softmax(dim=1)
prob_label_is_true = probs[:,1]

Training

The model is a pre-trained MNLI classifier further fine-tuned on Yahoo Answers topic classification in the manner originally described in Yin et al. 2019 and this blog post. That is, each sequence is fed to the pre-trained NLI model in place of the premise and each candidate label as the hypothesis, formatted like so: This text is about {class name}. For each example in the training set, a true and a randomly-selected false label hypothesis are fed to the model which must predict which labels are valid and which are false.

Since this method studies the ability to classify unseen labels after being trained on a different set of labels, the model is only trained on 5 out of the 10 labels in Yahoo Answers. These are "Society & Culture", "Health", "Computers & Internet", "Business & Finance", and "Family & Relationships".

Evaluation Results

This model was evaluated with the label-weighted F1 of the seen and unseen labels. That is, for each example the model must predict from one of the 10 corpus labels. The F1 is reported for the labels seen during training as well as the labels unseen during training. We found an F1 score of .68 and .72 for the unseen and seen labels, respectively. In order to adjust for the in-vs-out of distribution labels, we subtract a fixed amount of 30% from the normalized probabilities of the seen labels, as described in Yin et al. 2019 and our blog post.

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

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

GPU в ailist

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

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

Подбираем GPU…

Класс архитектуры
BartForSequenceClassification
Ревизия весов
53d5a96

0 моделей