Views
No views yet
Maerz, Seraphine F., Dean G. Schafer, and Carsten Q. Schneider. Listening to Leaders: Illiberal Speech as a Symptom of Democratic Decline. (2026)
| Model | Dimension | Task |
|---|---|---|
| illiberal-speech-ei-relevance | Exclusive–Inclusive | Relevance filter |
| illiberal-speech-ei-scorer | Exclusive–Inclusive | 0–10 scorer |
| illiberal-speech-cd-relevance | Concentration–Dispersion | Relevance filter (this model) |
| illiberal-speech-cd-scorer | Concentration–Dispersion | 0–10 scorer |
microsoft/deberta-v3-base encoder with LoRA adapters (r=16, α=32, dropout=0.1, target modules: query_proj, key_proj, value_proj), mean pooling over the last hidden state, and a linear 2-class classification head. Max sequence length 512..pth file contains the full model state dict (LoRA weights and the classification head). The lora_adapters/ folder holds the PEFT adapters for the encoder only — it does not include the classification head, so use the .pth for working predictions:1import torch
2import torch.nn as nn
3from huggingface_hub import hf_hub_download
4from transformers import DebertaV2Tokenizer, DebertaV2Model
5from peft import LoraConfig, get_peft_model
6
7REPO = "d-schafer/illiberal-speech-cd-relevance"
8THRESHOLD = 0.80 # recommended decision threshold
9
10class DebertaForClassification(nn.Module):
11 def __init__(self):
12 super().__init__()
13 self.deberta = DebertaV2Model.from_pretrained("microsoft/deberta-v3-base")
14 hidden_size = self.deberta.config.hidden_size
15 lora_config = LoraConfig(
16 r=16, lora_alpha=32, lora_dropout=0.1,
17 target_modules=["query_proj", "key_proj", "value_proj"],
18 bias="none", task_type="FEATURE_EXTRACTION",
19 )
20 self.deberta = get_peft_model(self.deberta, lora_config)
21 self.classifier = nn.Linear(hidden_size, 2)
22 self.dropout = nn.Dropout(0.1)
23
24 def forward(self, input_ids, attention_mask):
25 h = self.deberta(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state
26 m = attention_mask.unsqueeze(-1).expand(h.size()).float()
27 pooled = (h * m).sum(1) / m.sum(1).clamp(min=1e-9)
28 return self.classifier(self.dropout(pooled))
29
30model_path = hf_hub_download(REPO, "illiberal-speech-cd-relevance.pth")
31model = DebertaForClassification()
32model.load_state_dict(torch.load(model_path, map_location="cpu", weights_only=True))
33model.eval()
34
35tokenizer = DebertaV2Tokenizer.from_pretrained(REPO, subfolder="tokenizer")
36
37texts = ["The courts should not be allowed to stand in the way of the people's will."]
38enc = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt")
39with torch.no_grad():
40 probs = torch.softmax(model(enc["input_ids"], enc["attention_mask"]), dim=1)[:, 1]
41relevant = probs >= THRESHOLD
42print(probs.tolist(), relevant.tolist())torch, transformers, peft, and sentencepiece.| File | Description |
|---|---|
illiberal-speech-cd-relevance.pth | Full state dict (encoder + LoRA + classification head) — use this |
lora_adapters/ | PEFT adapter weights for the encoder (no classification head) |
tokenizer/ | DeBERTa-v3 tokenizer files (offline-reproducible copy) |
1@unpublished{maerz2026listening,
2 title = {Listening to Leaders: Illiberal Speech as a Symptom of Democratic Decline},
3 author = {Maerz, Seraphine F. and Schafer, Dean G. and Schneider, Carsten Q.},
4 year = {2026},
5 note = {Working paper}
6}