CoolFace
Modelpublic

niksmer/ManiBERT

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes53downloads
Model Card

ManiBERT

This model is a fine-tuned version of roberta-base on data from the Manifesto Project.

Model description

This model was trained on 115,943 manually annotated sentences to classify text into one of 56 political categories:

Intended uses & limitations

The model output 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.

python
from transformers import pipeline
import pandas as pd
classifier = pipeline(
    task="text-classification",
    model="niksmer/ManiBERT")
# Load text data you want to classify
text = pd.read_csv("example.csv")["text_you_want_to_classify"].to_list()
# Inference
output = classifier(text)
# Print output
pd.DataFrame(output).head()

Train Data

ManiBERT was trained on the English-speaking subset of the Manifesto Project Dataset (MPDS2021a). The model was trained on 115,943 sentences from 163 political manifestos in 7 English-speaking countries (Australia, Canada, Ireland, New Zealand, South Africa, United Kingdom, United States). The manifestos were published between 1992 - 2020.

CountryCount manifestosCount sentencesTime span
Australia1814,8872010-2016
Ireland2324,9662007-2016
Canada1412,3442004-2008 & 2015
New Zealand4635,0791993-2017
South Africa2913,3341994-2019
USA913,1881992 & 2004-2020
United Kingdom3430,9361997-2019

Canadian manifestos between 2004 and 2008 are used as test data.

The resulting Datasets are higly (!) imbalanced. See Evaluation.

Evaluation

DescriptionLabelCount Train DataCount Validation DataCount Test DataValidation F1-ScoreTest F1-Score
Foreign Special Relationships: Positive054596600.430.45
Foreign Special Relationships: Negative16614220.220.09
Anti-Imperialism2931610.160.00
Military: Positive31,9693561590.690.63
Military: Negative448989520.590.63
Peace541880490.570.64
Internationalism: Positive62,4014174040.600.54
European Community/Union or Latin America Integration: Positive7930156200.580.32
Internationalism: Negative820940570.280.05
European Community/Union or Latin America Integration: Negative95208100.39-
Freedom and Human Rights102,196389760.500.34
Democracy113,0455342060.530.51
Constitutionalism: Positive1225948120.340.22
Constitutionalism: Negative133807220.340.00
Decentralisation: Positive142,7914813310.490.45
Centralisation: Positive1515033710.110.00
Governmental and Administrative Efficiency163,9057111050.500.32
Political Corruption179001862340.590.55
Political Authority183,4886273000.510.39
Free Market Economy191,768309530.400.16
Incentives: Positive203,100544810.520.28
Market Regulation213,5626162100.500.36
Economic Planning2253393670.310.12
Corporatism/ Mixed Economy2319332230.280.33
Protectionism: Positive246331031800.440.22
Protectionism: Negative257231181490.520.40
Economic Goals268171391480.050.00
Keynesian Demand Management271602590.000.00
Economic Growth: Positive283,1426073740.530.30
Technology and Infrastructure: Positive298,6431,5293390.710.56
Controlled Economy3056796940.470.16
Nationalisation31832157270.560.16
Economic Orthodoxy321,7212871840.550.48
Marxist Analysis: Positive331483300.20-
Anti-Growth Economy and Sustainability342,6764522500.430.33
Environmental Protection356,7311,1639340.700.67
Culture: Positive362,082358920.690.56
Equality: Positive376,6301,1263610.570.43
Welfare State Expansion3813,4862,4059900.720.61
Welfare State Limitation3992615120.450.00
Education Expansion407,1911,3242740.780.63
Education Limitation411542710.170.00
National Way of Life: Positive422,1053853950.480.34
National Way of Life: Negative4374314720.270.00
Traditional Morality: Positive441,375234190.550.14
Traditional Morality: Negative4529154380.300.23
Law and Order465,5829493810.720.71
Civic Mindedness: Positive471,348229270.450.28
Multiculturalism: Positive482,006355710.610.35
Multiculturalism: Negative491443170.330.00
Labour Groups: Positive503,856707570.640.14
Labour Groups: Negative512083500.44-
Agriculture and Farmers522,9964901300.670.56
Middle Class and Professional Groups5327138120.380.40
Underprivileged Minority Groups541,417252820.340.33
Non-economic Demographic Groups552,4294351060.420.24

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

training_args = TrainingArguments(
    warmup_ratio=0.05,
    weight_decay=0.1, 
    learning_rate=5e-05,
    fp16 = True,
    evaluation_strategy="epoch",
    num_train_epochs=5,
    per_device_train_batch_size=16,
    overwrite_output_dir=True,
    per_device_eval_batch_size=16,
    save_strategy="no",
    logging_dir='logs',   
    logging_strategy= 'steps',     
    logging_steps=10,
    push_to_hub=True,
    hub_strategy="end")

Training results

Training LossEpochStepValidation LossAccuracyF1-microF1-macroF1-weightedPrecisionRecall
1.76381.018121.64710.55310.55310.33540.53680.55310.5531
1.45012.036241.51670.58070.58070.39210.56550.58070.5807
1.06383.054361.50170.58930.58930.42400.57890.58930.5893
0.92634.072481.51730.59750.59750.44990.59010.59750.5975
0.78595.090601.55740.59780.59780.45640.59030.59780.5978

Overall evaluation

TypeMicro F1-ScoreMacro F1-ScoreWeighted F1-Score
Validation0.600.460.59
Test0.480.300.47

Evaluation based on saliency theory

Saliency theory is a theory to analyse politial text data. In sum, parties tend to write about policies in which they think that they are seen as competent. Voters tend to assign advantages in policy competence in line to the assumed ideology of parties. Therefore you can analyze the share of policies parties tend to write about in their manifestos to analyze the party ideology.

The Manifesto Project presented for such an analysis the rile-index. For a quick overview, check this.

In the following plot, the predicted and original rile-indices are shown per manifesto in the test dataset. Overall the pearson correlation between the predicted and original rile-indices is 0.95. As alternative, you can use RoBERTa-RILE.

[image]

Framework versions

  • —Transformers 4.16.2
  • —Pytorch 1.9.0+cu102
  • —Datasets 1.8.0
  • —Tokenizers 0.10.3