/ Модель

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

Контекст
512 токенов
Архитектура
distilbert · dense

policy-distilbert-7d

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

Модель классифицирует английские предложения из политических текстов по семи тематическим категориям Manifesto Project.

50скачиваний за 30 дней5лайковвеса обновлены4 янв 2021

Бенчмарки

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

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

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

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

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

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

Policy-DistilBERT-7d — модель классификации предложений, разработанная Moritz Laurer. Она относит английский текст к одной из семи политических категорий: экономика, внешние отношения, общественные ценности, свобода и демократия, политическая система, благосостояние и качество жизни, социальные группы.

Модель построена на DistilBERT и дообучена на 129 669 вручную размеченных предложениях из партийных манифестов на английском языке. Данные охватывают 164 манифеста 55 партий из восьми англоязычных стран, опубликованных в 1992–2019 годах. Максимальная длина контекста — 512 токенов.

Модель подходит для тематической разметки политических манифестов и анализа политических приоритетов. На тестовой выборке указаны сбалансированная точность 0,745 и взвешенная F1-мера 0,773. Качество может снижаться на других жанрах, странах и периодах; результаты также наследуют ограничения категорий и возможные смещения разметки Manifesto Project. Условия лицензии в предоставленных данных не описаны.

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

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

Ограничения

Обучение охватывает манифесты восьми англоязычных стран за 1992–2019 годы; на других типах текстов, в других странах и периодах качество может снизиться. Модель наследует ограничения категорий датасета и возможные смещения разметчиков.

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

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

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

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

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

Открыть на Hugging Face

Policy-DistilBERT-7d

Model description

This model was trained on 129.669 manually annotated sentences to classify text into one of seven political categories: 'Economy', 'External Relations', 'Fabric of Society', 'Freedom and Democracy', 'Political System', 'Welfare and Quality of Life' or 'Social Groups'.

Intended uses & limitations

How to use the model

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_name = "MoritzLaurer/policy-distilbert-7d"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

text = "The new variant first detected in southern England in September is blamed for sharp rises in levels of positive tests in recent weeks in London, south-east England and the east of England"

input = tokenizer(text, truncation=True, return_tensors="pt")
output = model(input["input_ids"])
# the output corresponds to the following labels:
# 0: external relations, 1: freedom and democracy, 2: political system, 3: economy, 4: welfare and quality of life, 5: fabric of society, 6: social groups

# output to dictionary
prediction = torch.softmax(output["logits"][0], -1).tolist()
label_names = ["external relations", "freedom and democracy", "political system", "economy", "welfare and quality of life", "fabric of society", "social groups"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)
#{'external relations': 0.0, 'freedom and democracy': 0.0, 'political system': 0.9, 'economy': 0.4, 
# 'welfare and quality of life': 98.3, 'fabric of society': 0.3, 'social groups': 0.0}

Training data

Policy-DistilBERT-7d was trained on the English-speaking subset of the Manifesto Project Dataset (MPDS2020a). The model was trained on 129.669 sentences from 164 political manifestos from 55 political parties in 8 English-speaking countries (Australia, Canada, Ireland, Israel, New Zealand, South Africa, United Kingdom, United States). The manifestos were published between 1992 - 2019.

The Manifesto Project mannually annotates individual sentences from political party manifestos in 7 main political domains: 'Economy', 'External Relations', 'Fabric of Society', 'Freedom and Democracy', 'Political System', 'Welfare and Quality of Life' or 'Social Groups' - see the codebook for the exact definitions of each domain.

Training procedure

distilbert-base-uncased was trained using the Hugging Face trainer with the following hyperparameters. The hyperparameters were determined using a hyperparameter search on a 15% validation set.

training_args = TrainingArguments(
    num_train_epochs=5,              # total number of training epochs
    learning_rate=4e-05,
    per_device_train_batch_size=4,   # batch size per device during training
    per_device_eval_batch_size=4,    # batch size for evaluation
    warmup_steps=500,                # number of warmup steps for learning rate scheduler
    weight_decay=0.02,               # strength of weight decay
    fp16=True                        # mixed precision training
)

Eval results

The model was evaluated using 15% of the sentences (85-15 train-test split).

accuracy (balanced)F1 (weighted)precisionrecallaccuracy (not balanced)
0.7450.7730.7720.7710.771

Please note that the label distribution in the dataset is imbalanced:

Welfare and Quality of Life    0.327225
Economy                        0.259191
Fabric of Society              0.111800
Political System               0.095081
Social Groups                  0.094371
External Relations             0.063724
Freedom and Democracy          0.048608

Balanced accuracy and weighted F1 were therefore used to evaluate model performance.

Limitations and bias

The model was trained on sentences in political manifestos from parties in the 8 countries mentioned above between 1992-2019, manually annotated by the Manifesto Project. The model output therefore reproduces the limitations of the dataset in terms of country coverage, time span, domain definitions and potential biases of the annotators - as any supervised machine learning model would. Applying the model to other types of data (other types of texts, countries etc.) will reduce performance.

BibTeX entry and citation info

@unpublished{
  title={Policy-DistilBERT},
  author={Moritz Laurer},
  year={2020},
  note={Unpublished paper}
}

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

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

GPU в ailist

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

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

Подбираем GPU…

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

0 моделей