xlm-roberta-large-english-cap-v5
Model description
An xlm-roberta-large model fine-tuned on english training data labeled with major topic codes from the Comparative Agendas Project.
We follow the master codebook of the Comparative Agendas Project, and all of our models use the same major topic codes.
How to use the model
from transformers import AutoTokenizer, pipeline
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-large")
pipe = pipeline(
model="poltextlab/xlm-roberta-large-english-cap-v5",
task="text-classification",
tokenizer=tokenizer,
use_fast=False,
token="<your_hf_read_only_token>"
)
text = "<text_to_classify>"
pipe(text)
Classification Report
Overall Performance:
- Accuracy: 83%
- Macro Avg: Precision: 0.81, Recall: 0.79, F1-score: 0.80
- Weighted Avg: Precision: 0.83, Recall: 0.83, F1-score: 0.83
Per-Class Metrics:
| Label | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| (1) Macroeconomics | 0.8 | 0.73 | 0.77 | 11742 |
| (2) Civil Rights | 0.72 | 0.74 | 0.73 | 5667 |
| (3) Health | 0.88 | 0.9 | 0.89 | 14325 |
| (4) Agriculture | 0.88 | 0.85 | 0.87 | 6514 |
| (5) Labor | 0.81 | 0.76 | 0.78 | 7160 |
| (6) Education | 0.89 | 0.87 | 0.88 | 10011 |
| (7) Environment | 0.8 | 0.86 | 0.83 | 7385 |
| (8) Energy | 0.86 | 0.86 | 0.86 | 6301 |
| (9) Immigration | 0.84 | 0.81 | 0.83 | 2364 |
| (10) Transportation | 0.85 | 0.89 | 0.87 | 10769 |
| (12) Law and Crime | 0.86 | 0.81 | 0.84 | 16263 |
| (13) Social Welfare | 0.81 | 0.81 | 0.81 | 7420 |
| (14) Housing | 0.75 | 0.8 | 0.77 | 4982 |
| (15) Banking, Finance, and Domestic Commerce | 0.83 | 0.79 | 0.81 | 13510 |
| (16) Defense | 0.78 | 0.83 | 0.81 | 16369 |
| (17) Technology | 0.79 | 0.81 | 0.8 | 3952 |
| (18) Foreign Trade | 0.9 | 0.82 | 0.86 | 6172 |
| (19) International Affairs | 0.76 | 0.8 | 0.78 | 14200 |
| (20) Government Operations | 0.81 | 0.84 | 0.82 | 26950 |
| (21) Public Lands | 0.87 | 0.85 | 0.86 | 12076 |
| (23) Culture | 0.35 | 0.11 | 0.16 | 893 |
| (999) No Policy Content | 0.89 | 0.9 | 0.9 | 24532 |
Inference platform
This model is used by the CAP Babel Machine, an open-source and free natural language processing tool, designed to simplify and speed up projects for comparative research.
Cooperation
Model performance can be significantly improved by extending our training sets. We appreciate every submission of CAP-coded corpora (of any domain and language) at poltextlab{at}poltextlab{dot}com or by using the CAP Babel Machine.
Debugging and issues
This architecture uses the sentencepiece tokenizer. In order to run the model before transformers==4.27 you need to install it manually.