armaniii commited on
Commit
d475460
·
verified ·
1 Parent(s): 4ca61a6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +243 -162
README.md CHANGED
@@ -1,199 +1,280 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
 
 
 
11
 
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
 
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
- ## Environmental Impact
 
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
 
 
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
 
 
 
152
 
153
- ## Technical Specifications [optional]
 
 
 
 
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
 
 
 
158
 
159
- ### Compute Infrastructure
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
 
 
 
 
164
 
165
- [More Information Needed]
 
 
 
166
 
167
- #### Software
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
 
 
 
 
 
 
 
 
 
 
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
178
 
179
- **APA:**
 
 
 
180
 
181
- [More Information Needed]
 
 
 
 
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
1
  ---
2
+ language: en
3
+ license: apache-2.0
4
+ tags:
5
+ - populism
6
+ - political-discourse
7
+ - text-classification
8
+ - qwen3
9
+ - lora
10
+ - fine-tuned
11
+ datasets:
12
+ - coastalcph/populism-trump-2016
13
+ metrics:
14
+ - accuracy
15
+ - f1
16
+ - precision
17
+ - recall
18
+ base_model: Qwen/Qwen3-4B
19
+ pipeline_tag: text-classification
20
  ---
21
 
22
+ # Qwen3-4B Fine-tuned for Populism Detection
23
 
24
+ ## Model Description
25
 
26
+ This model is a fine-tuned version of [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) trained to identify fine-grained forms of populism in political discourse. The model performs 4-way classification to detect:
27
 
28
+ - **(a) No populism** - Sentences without populist rhetoric
29
+ - **(b) Anti-elitism** - Negative invocations of "elites"
30
+ - **(c) People-centrism** - Positive invocations of the "people"
31
+ - **(d) Both** - Sentences combining anti-elitism and people-centrism
32
 
33
+ The model was fine-tuned using **LoRA (Low-Rank Adaptation)** for parameter-efficient training on political speeches from Donald Trump's 2016 presidential campaign.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ ## Model Details
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ ### Model Type
38
+ - **Base Model:** Qwen/Qwen3-4B (4B parameters)
39
+ - **Fine-tuning Method:** LoRA (Low-Rank Adaptation)
40
+ - **Task:** Multi-class Text Classification (4 categories)
41
+ - **Language:** English
42
+ - **Domain:** Political discourse
43
+
44
+ ### Training Details
45
+
46
+ **LoRA Configuration:**
47
+ - **Rank (r):** 16
48
+ - **Alpha:** 32
49
+ - **Dropout:** 0.05
50
+ - **Target Modules:** `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
51
+ - **Bias:** None
52
+ - **Task Type:** CAUSAL_LM
53
+
54
+ **Training Hyperparameters:**
55
+ - **Epochs:** 3
56
+ - **Batch Size:** 8 (per device)
57
+ - **Gradient Accumulation Steps:** 4
58
+ - **Learning Rate:** 2e-4
59
+ - **Learning Rate Scheduler:** Cosine with 0.1 warmup ratio
60
+ - **Optimizer:** paged_adamw_32bit
61
+ - **Weight Decay:** 0.001
62
+ - **Max Gradient Norm:** 1.0
63
+ - **Max Sequence Length:** 300 tokens
64
+ - **Quantization:** 4-bit (NF4) with double quantization
65
+ - **Mixed Precision:** FP16/BF16
66
+ - **Total Training Steps:** 1,476
67
+
68
+ **Training Loss Progression:**
69
+ - Step 1: 4.9333
70
+ - Step 100: 0.4583
71
+ - Step 500: 0.0098
72
+ - Step 1000: 0.003
73
+ - Step 1476: ~0.001
74
+
75
+ ## Training Data
76
+
77
+ **Dataset:** [coastalcph/populism-trump-2016](https://huggingface.co/datasets/coastalcph/populism-trump-2016)
78
+
79
+ **Data Source:** Sentence-level annotations from Donald Trump's 2016 presidential campaign speeches.
80
+
81
+ **Label Distribution (Original):**
82
+ - **(a) No populism:** 92%
83
+ - **(b) Anti-elitism:** 4%
84
+ - **(c) People-centrism:** 2%
85
+ - **(d) Both:** 2%
86
+
87
+ **Data Preprocessing:**
88
+ - Sentences truncated to maximum 48 words
89
+ - **5x upsampling** applied to minority classes (b, c, d) to address class imbalance
90
+ - Tokenized with max_length=300
91
+ - Shuffled with seed=42
92
+
93
+ **Populism Definition:**
94
+ Following political science literature, populism is defined as an anti-elite discourse in the name of "the people", characterized by:
95
+ 1. **Anti-elitism:** Negative references to elite groups
96
+ 2. **People-centrism:** Positive references to ordinary citizens or "the people"
97
+
98
+ ## How to Use
99
+
100
+ ### Option 1: Load Merged Model (Recommended)
101
+
102
+ ```python
103
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
104
+
105
+ # Load model and tokenizer
106
+ model_name = "armaniii/Qwen3-4B-populism"
107
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
108
+ model = AutoModelForCausalLM.from_pretrained(
109
+ model_name,
110
+ device_map="auto",
111
+ torch_dtype="auto"
112
+ )
113
+
114
+ # Create pipeline
115
+ pipe = pipeline(
116
+ "text-generation",
117
+ model=model,
118
+ tokenizer=tokenizer
119
+ )
120
+ ```
121
+
122
+ ### Inference Example
123
+
124
+ ```python
125
+ # System prompt
126
+ SYSTEM_PROMPT = """You are a helpful AI assistant with expertise in identifying populism in public discourse.
127
+
128
+ Populism can be defined as an anti-elite discourse in the name of the "people". In other words, populism emphasizes the idea of the common "people" and often positions this group in opposition to a perceived elite group.
129
+
130
+ There are two core elements in identifying populism: (i) anti-elitism, i.e., negative invocations of "elites", and (ii) people-centrism, i.e., positive invocations of the "people".
131
+ """
132
+
133
+ # Instruction template
134
+ INSTRUCTION = """You must classify each sentence in one of the following categories:
135
+
136
+ (a) No populism.
137
+ (b) Anti-elitism, i.e., negative invocations of "elites".
138
+ (c) People-centrism, i.e., positive invocations of the "People".
139
+ (d) Both people-centrism and anti-elitism populism.
140
+ """
141
+
142
+ # Example sentence
143
+ sentence = "We need to stand up against the corrupt establishment that has betrayed the American people."
144
+
145
+ # Build prompt
146
+ conversation = [
147
+ {"role": "system", "content": SYSTEM_PROMPT},
148
+ {"role": "user", "content": INSTRUCTION + f'\n\nWhich is the most relevant category for the sentence: "{sentence}"?'}
149
+ ]
150
+
151
+ # Apply chat template
152
+ prompt = tokenizer.apply_chat_template(
153
+ conversation=conversation,
154
+ tokenize=False,
155
+ add_generation_prompt=True
156
+ )
157
+
158
+ # Generate response
159
+ response = pipe(
160
+ prompt,
161
+ do_sample=False,
162
+ max_new_tokens=256,
163
+ eos_token_id=tokenizer.eos_token_id,
164
+ pad_token_id=tokenizer.eos_token_id,
165
+ )
166
 
167
+ print(response[0]['generated_text'])
168
+ # Expected output: "I would categorize this sentence as (d)..."
169
+ ```
170
 
171
+ ### Expected Output Format
172
 
173
+ The model responds in the following format:
174
+ ```
175
+ I would categorize this sentence as (X)
176
 
177
+ [Explanation of the classification decision]
178
+ ```
179
+
180
+ Where `X` is one of: `a`, `b`, `c`, or `d`.
181
+
182
+ ## Performance
183
+
184
+ Detailed performance metrics and comparisons are available in the original paper (see Citation section below).
185
 
186
+ **Key Findings:**
187
+ - Fine-tuned models significantly outperform zero-shot instruction-tuned LLMs
188
+ - The model shows strong performance on in-domain political discourse
189
+ - Cross-context evaluation demonstrates reasonable generalization to European political speeches
190
+ - LoRA fine-tuning provides efficient adaptation with minimal trainable parameters
191
 
192
+ ## Limitations and Bias
193
 
194
+ **Training Data Limitations:**
195
+ - Trained primarily on Donald Trump's 2016 campaign speeches
196
+ - May not generalize equally well to other political contexts, time periods, or speakers
197
+ - Performance may vary on non-US political discourse
198
 
199
+ **Class Imbalance:**
200
+ - Original data is highly imbalanced (92% "No populism")
201
+ - Upsampling (5x) applied to minority classes during training
202
+ - Model may still show bias toward the majority class
203
+
204
+ **Domain Specificity:**
205
+ - Optimized for sentence-level classification
206
+ - Performance on longer texts may require sentence segmentation
207
+ - Best suited for political discourse and campaign rhetoric
208
+
209
+ **Ethical Considerations:**
210
+ - This model provides automated analysis and should not be the sole basis for political judgments
211
+ - Results should be interpreted by domain experts
212
+ - May reflect biases present in the training data
213
 
214
+ ## Intended Use
215
 
216
+ **Primary Use Cases:**
217
+ - Research in political science and computational social science
218
+ - Analysis of populist rhetoric in political campaigns
219
+ - Educational purposes in understanding populist discourse
220
+ - Automated annotation of political speech datasets
221
 
222
+ **Out-of-Scope Use:**
223
+ - Making definitive political judgments about individuals or parties
224
+ - Real-time moderation or censorship of political speech
225
+ - Use without human oversight in sensitive political contexts
226
 
227
+ ## Citation
228
 
229
+ If you use this model, please cite the original paper:
230
 
231
+ ```bibtex
232
+ @misc{chalkidis2025populism,
233
+ title={Identifying Fine-grained Forms of Populism in Political Discourse: A Case Study on Donald Trump's Presidential Campaigns},
234
+ author={Chalkidis, Ilias and Brandl, Stephanie and Aslanidis, Paris},
235
+ year={2025},
236
+ archivePrefix={arXiv},
237
+ primaryClass={cs.CL},
238
+ url={https://arxiv.org/abs/2507.19303},
239
+ doi={10.48550/arXiv.2507.19303}
240
+ }
241
+ ```
242
 
243
+ **Paper:** [Identifying Fine-grained Forms of Populism in Political Discourse](https://arxiv.org/abs/2507.19303)
244
 
245
+ **Dataset:** [coastalcph/populism-trump-2016](https://huggingface.co/datasets/coastalcph/populism-trump-2016)
246
 
247
+ ## Acknowledgments
248
 
249
+ This model was developed based on the research by:
250
+ - **Ilias Chalkidis** (University of Copenhagen)
251
+ - **Stephanie Brandl** (University of Copenhagen)
252
+ - **Paris Aslanidis** (Aristotle University of Thessaloniki)
253
 
254
+ The fine-tuning was performed using:
255
+ - **Base Model:** [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) by Alibaba Cloud
256
+ - **Dataset:** [coastalcph/populism-trump-2016](https://huggingface.co/datasets/coastalcph/populism-trump-2016)
257
+ - **PEFT Library:** Hugging Face PEFT for LoRA implementation
258
+ - **Training Framework:** Hugging Face Transformers and TRL
259
 
260
+ ## Model Card Authors
261
 
262
+ [Your Name/Organization]
263
 
264
+ ## Model Card Contact
265
 
266
+ [Your Contact Information]
267
 
268
+ ## License
269
 
270
+ This model is released under the Apache 2.0 License, consistent with the Qwen3-4B base model.
271
 
272
+ **Responsible Use:** This model is intended for research and educational purposes. Users should be aware of the limitations and biases described above and use the model responsibly with appropriate human oversight.
273
 
274
+ ---
275
 
276
+ **Related Resources:**
277
+ - 📄 [Paper](https://arxiv.org/abs/2507.19303)
278
+ - 🤗 [Dataset](https://huggingface.co/datasets/coastalcph/populism-trump-2016)
279
+ - 💻 [GitHub Repository](https://github.com/armaniii)
280
+ - 🎯 [Demo Space](https://huggingface.co/spaces/armaniii/populism-detector)