Views
No views yet
1) or is it Neutral (label 0)?jhu-clsp/mmBERT-base on hand-annotated parliamentary speeches
from AUS, CZE, DEU, DNK, ESP, GBR, NLD, and SWE.0 — Neutral1 — SupportNeutral,
Support, or Opposition.Neutral ∪ Support) and binarised as Support vs Neutral.Stance_Retrain_undersampled.csv (undersampled to address class imbalance).StratifiedGroupKFold (n_splits=10) on
country × speech_ID, so no speech appears in more than one fold.
Realised allocation: 8 folds train / 1 fold val / 1 fold test
(~80/10/10). Shares the same underlying stance split as the
Opposition detector for consistent cascade evaluation.jhu-clsp/mmBERT-basef1_positive on val)compute_class_weight)f1_positive (minority-class F1)1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tok = AutoTokenizer.from_pretrained("LBenoit/support-detector-mmbert")
5mdl = AutoModelForSequenceClassification.from_pretrained("LBenoit/support-detector-mmbert")
6
7text = "European cooperation has brought decades of peace and prosperity."
8enc = tok(text, truncation=True, max_length=320, return_tensors="pt")
9with torch.no_grad():
10 prob_support = torch.softmax(mdl(**enc).logits, dim=-1)[0, 1].item()
11print("P(Support | Non-Opposition) =", prob_support)1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4OPP_REPO = "LBenoit/opposition-detector-mmbert"
5SUP_REPO = "LBenoit/support-detector-mmbert"
6
7tok_o = AutoTokenizer.from_pretrained(OPP_REPO)
8mdl_o = AutoModelForSequenceClassification.from_pretrained(OPP_REPO)
9tok_s = AutoTokenizer.from_pretrained(SUP_REPO)
10mdl_s = AutoModelForSequenceClassification.from_pretrained(SUP_REPO)
11
12def predict_stance(text, thresh=0.5):
13 enc = tok_o(text, truncation=True, max_length=320, return_tensors="pt")
14 p_opp = torch.softmax(mdl_o(**enc).logits, dim=-1)[0, 1].item()
15 if p_opp >= thresh:
16 return "Opposition"
17 enc = tok_s(text, truncation=True, max_length=320, return_tensors="pt")
18 p_sup = torch.softmax(mdl_s(**enc).logits, dim=-1)[0, 1].item()
19 return "Support" if p_sup >= thresh else "Neutral"