olehmell commited on
Commit
a61d83a
·
verified ·
1 Parent(s): 761cab8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +135 -99
README.md CHANGED
@@ -18,107 +18,130 @@ pipeline_tag: text-classification
18
 
19
  ## Model Description
20
 
21
- This model detects propaganda and manipulation techniques in Ukrainian text. It's a fine-tuned version of [Goader/modern-liberta-large](https://huggingface.co/Goader/modern-liberta-large) trained on the UNLP 2025 Shared Task dataset for multi-label classification of manipulation techniques.
22
 
23
- ## Task Description
24
 
25
- The model identifies 5 major manipulation categories (consolidated from 10 original techniques):
26
 
27
- ### 1. **Emotional Manipulation** (`emotional_manipulation`)
28
 
29
- * Loaded language with strong emotional connotation
 
 
 
 
 
 
30
 
31
- * Euphoria and celebratory tone to boost morale
32
 
33
- ### 2. **Fear Appeals** (`fear_appeals`)
34
 
35
- * Appeal to fear through stereotypes or prejudices
 
 
 
36
 
37
- * FUD (Fear, Uncertainty, Doubt) tactics
38
 
39
- ### 3. **Bandwagon Effect** (`bandwagon_effect`)
40
-
41
- * Glittering generalities using abstract positive concepts
42
-
43
- * Appeal to people/masses ("everyone thinks this")
44
-
45
- ### 4. **Selective Truth** (`selective_truth`)
46
-
47
- * Cherry picking facts to support arguments
48
-
49
- * Whataboutism to deflect criticism
50
-
51
- * Straw man arguments distorting opponent's position
52
-
53
- ### 5. **Thought-Terminating Cliché** (`cliche`)
54
-
55
- * Phrases that block critical thinking
56
-
57
- * Examples: "Все не так однозначно", "Де ви були 8 років?"
58
-
59
- ## Dataset
60
-
61
- * **Training Data**: 2,147 Ukrainian texts from UNLP 2025 Shared Task
62
 
63
- * **Source**: [UNLP 2025 Techniques Classification](https://www.google.com/search?q=https://github.com/unlp-workshop/unlp-2025-shared-task/tree/main/data/techniques_classification)
64
 
65
- * **Language**: Ukrainian (filtered from multilingual dataset)
66
 
67
- * **Task Type**: Multi-label classification (texts can contain multiple techniques)
 
 
 
 
 
 
 
 
 
 
68
 
69
- Training Configuration
70
- Base Model: Goader/modern-liberta-large
71
- Learning Rate: 2e-5
72
- Batch Size: 16 (train), 32 (eval)
73
- Epochs: 10
74
- Max Sequence Length: 512
75
- Optimizer: AdamW
76
- Loss Function: BCEWithLogitsLoss with class weights
77
- Train/Val Split: 90/10
78
 
 
79
 
80
- Usage
81
- Installation
82
  pip install transformers torch
 
83
 
 
84
 
85
- Quick Start
 
 
86
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
87
  import torch
88
 
89
- # Load model
90
  model_name = "olehmell/ukr-manipulation-detector-modern-bert"
 
 
 
 
 
 
 
 
 
91
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
92
  tokenizer = AutoTokenizer.from_pretrained(model_name)
93
 
94
  # Prepare text
95
- text = "Всі експерти вже давно це підтвердили, тільки ви не розумієте"
96
 
97
  # Tokenize and predict
98
  inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
99
  with torch.no_grad():
100
  outputs = model(**inputs)
 
101
  predictions = torch.sigmoid(outputs.logits)
102
 
103
- # Get detected techniques (threshold = 0.5)
104
  threshold = 0.5
105
- labels = ['emotional_manipulation', 'fear_appeals', 'bandwagon_effect',
106
- 'selective_truth', 'cliche']
107
- detected = []
108
  for i, score in enumerate(predictions[0]):
109
  if score > threshold:
110
- detected.append(f"{labels[i]}: {score:.2f}")
 
 
 
 
 
 
 
 
111
 
112
- print(f"Detected techniques: {detected}")
113
 
 
114
 
115
- Batch Processing
116
  def detect_manipulation_batch(texts, batch_size=32):
 
117
  results = []
118
  for i in range(0, len(texts), batch_size):
119
  batch = texts[i:i+batch_size]
120
- inputs = tokenizer(batch, return_tensors="pt", padding=True,
121
- truncation=True, max_length=512)
 
 
 
 
 
122
 
123
  with torch.no_grad():
124
  outputs = model(**inputs)
@@ -127,48 +150,59 @@ def detect_manipulation_batch(texts, batch_size=32):
127
 
128
  return results
129
 
130
-
131
- Performance Metrics
132
- |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  | Metric | Value |
135
- | F1 Macro | TBD |
136
- | F1 Micro | TBD |
137
- | Hamming Loss | TBD |
138
-
139
- Note: Metrics to be updated after final evaluation
140
-
141
- Label Distribution in Training Data
142
- | Technique | Count | Percentage |
143
- | Emotional Manipulation | 1,094 | 50.9% |
144
- | Bandwagon Effect | 451 | 21.0% |
145
- | Thought-Terminating Cliché | 240 | 11.2% |
146
- | Fear Appeals | 198 | 9.2% |
147
- | Selective Truth | 187 | 8.7% |
148
-
149
- Limitations
150
- Language: Optimized for Ukrainian; may not perform well on other languages
151
 
152
- Domain: Trained primarily on political and social media discourse
153
 
154
- Context: Short texts (up to 512 tokens); longer documents need to be truncated
 
 
 
 
155
 
156
- Class Imbalance: Some techniques are underrepresented in training data
157
 
158
- Mixed Language: May have reduced accuracy on heavily code-mixed Ukrainian-Russian text
 
 
159
 
160
- Ethical Considerations
161
- This model is intended as a tool to support media literacy and critical thinking
162
 
163
- Results should be interpreted with human judgment and contextual understanding
164
-
165
- Should not be used as the sole arbiter of truth or to censor content
166
-
167
- May reflect biases present in the training data
168
-
169
- Citation
170
- If you use this model, please cite:
171
 
 
172
  @misc{ukrainian-manipulation-modernbert-2025,
173
  author = {Oleh Mell},
174
  title = {Ukrainian Manipulation Detector - ModernBERT},
@@ -176,7 +210,8 @@ If you use this model, please cite:
176
  publisher = {Hugging Face},
177
  url = {[https://huggingface.co/olehmell/ukr-manipulation-detector-modern-bert](https://huggingface.co/olehmell/ukr-manipulation-detector-modern-bert)}
178
  }
179
-
 
180
  @inproceedings{unlp2025shared,
181
  title={UNLP 2025 Shared Task on Techniques Classification},
182
  author={UNLP Workshop Organizers},
@@ -184,16 +219,17 @@ If you use this model, please cite:
184
  year={2025},
185
  url={[https://github.com/unlp-workshop/unlp-2025-shared-task](https://github.com/unlp-workshop/unlp-2025-shared-task)}
186
  }
 
187
 
 
188
 
189
- License
190
- MIT
191
 
192
- Contact
193
- For questions or feedback, please open an issue on the model repository.
194
 
195
- Acknowledgments
196
- UNLP 2025 Workshop organizers for providing the dataset
197
 
198
- Goader for the base ModernBERT Ukrainian model
199
 
 
 
 
18
 
19
  ## Model Description
20
 
21
+ This model detects propaganda and manipulation techniques in Ukrainian text. It is a fine-tuned version of [Goader/modern-liberta-large](https://huggingface.co/Goader/modern-liberta-large) trained on the UNLP 2025 Shared Task dataset for multi-label classification of manipulation techniques.
22
 
23
+ ## Task: Manipulation Technique Classification
24
 
25
+ The model performs multi-label text classification, identifying 5 major manipulation categories consolidated from 10 original techniques. A single text can contain multiple techniques.
26
 
27
+ ### Manipulation Categories
28
 
29
+ | Category | Label Name | Description & Consolidated Techniques |
30
+ | :--- | :--- | :--- |
31
+ | **Emotional Manipulation** | `emotional_manipulation` | Involves using loaded language with strong emotional connotations or a euphoric tone to boost morale and sway opinion. |
32
+ | **Fear Appeals** | `fear_appeals` | Preys on fears, stereotypes, or prejudices. Includes Fear, Uncertainty, and Doubt (FUD) tactics. |
33
+ | **Bandwagon Effect** | `bandwagon_effect` | Uses glittering generalities (abstract, positive concepts) or appeals to the masses ("everyone thinks this") to encourage agreement. |
34
+ | **Selective Truth** | `selective_truth` | Employs logical fallacies like cherry-picking facts, whataboutism to deflect criticism, or creating straw man arguments to distort an opponent's position. |
35
+ | **Thought-Terminating Cliché** | `cliche` | Uses formulaic phrases designed to shut down critical thinking and end a discussion. *Examples: "Все не так однозначно", "Де ви були 8 років?"* |
36
 
37
+ ## Training Data
38
 
39
+ The model was trained on the dataset from the UNLP 2025 Shared Task on manipulation technique classification.
40
 
41
+ * **Dataset:** [UNLP 2025 Techniques Classification](https://github.com/unlp-workshop/unlp-2025-shared-task/tree/main/data/techniques_classification)
42
+ * **Source Texts:** Ukrainian texts filtered from a larger multilingual dataset.
43
+ * **Size:** 2,147 training examples.
44
+ * **Task:** Multi-label classification.
45
 
46
+ ### Label Distribution in Training Data
47
 
48
+ | Technique | Count | Percentage |
49
+ | :--- | :--- | :--- |
50
+ | Emotional Manipulation | 1,094 | 50.9% |
51
+ | Bandwagon Effect | 451 | 21.0% |
52
+ | Thought-Terminating Cliché | 240 | 11.2% |
53
+ | Fear Appeals | 198 | 9.2% |
54
+ | Selective Truth | 187 | 8.7% |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ ## Training Configuration
57
 
58
+ The model was fine-tuned using the following hyperparameters:
59
 
60
+ | Parameter | Value |
61
+ | :--- | :--- |
62
+ | **Base Model** | `Goader/modern-liberta-large` |
63
+ | **Learning Rate** | `2e-5` |
64
+ | **Train Batch Size** | `16` |
65
+ | **Eval Batch Size**| `32` |
66
+ | **Epochs** | `10` |
67
+ | **Max Sequence Length** | `512` |
68
+ | **Optimizer** | AdamW |
69
+ | **Loss Function** | `BCEWithLogitsLoss` (with class weights) |
70
+ | **Train/Val Split** | 90% / 10% |
71
 
72
+ ## Usage
 
 
 
 
 
 
 
 
73
 
74
+ ### Installation
75
 
76
+ First, install the necessary libraries:
77
+ ```bash
78
  pip install transformers torch
79
+ ```
80
 
81
+ ### Quick Start
82
 
83
+ Here is how to use the model to classify a single piece of text:
84
+
85
+ ```python
86
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
87
  import torch
88
 
89
+ # Define model and label names
90
  model_name = "olehmell/ukr-manipulation-detector-modern-bert"
91
+ labels = [
92
+ 'emotional_manipulation',
93
+ 'fear_appeals',
94
+ 'bandwagon_effect',
95
+ 'selective_truth',
96
+ 'cliche'
97
+ ]
98
+
99
+ # Load pretrained model and tokenizer
100
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
101
  tokenizer = AutoTokenizer.from_pretrained(model_name)
102
 
103
  # Prepare text
104
+ text = "Всі експерти вже давно це підтвердили, тільки ви не розумієте, що відбувається насправді."
105
 
106
  # Tokenize and predict
107
  inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
108
  with torch.no_grad():
109
  outputs = model(**inputs)
110
+ # Apply sigmoid to convert logits to probabilities
111
  predictions = torch.sigmoid(outputs.logits)
112
 
113
+ # Get detected techniques (using a threshold of 0.5)
114
  threshold = 0.5
115
+ detected_techniques = {}
 
 
116
  for i, score in enumerate(predictions[0]):
117
  if score > threshold:
118
+ detected_techniques[labels[i]] = f"{score:.2f}"
119
+
120
+ if detected_techniques:
121
+ print("Detected techniques:")
122
+ for technique, score in detected_techniques.items():
123
+ print(f"- {technique} (Score: {score})")
124
+ else:
125
+ print("No manipulation techniques detected.")
126
+ ```
127
 
128
+ ### Batch Processing
129
 
130
+ For processing multiple texts efficiently, use batching:
131
 
132
+ ```python
133
  def detect_manipulation_batch(texts, batch_size=32):
134
+ """Processes a list of texts in batches."""
135
  results = []
136
  for i in range(0, len(texts), batch_size):
137
  batch = texts[i:i+batch_size]
138
+ inputs = tokenizer(
139
+ batch,
140
+ return_tensors="pt",
141
+ padding=True,
142
+ truncation=True,
143
+ max_length=512
144
+ )
145
 
146
  with torch.no_grad():
147
  outputs = model(**inputs)
 
150
 
151
  return results
152
 
153
+ # Example usage
154
+ corpus = [
155
+ "Це жахливо, вони хочуть нас усіх знищити!",
156
+ "Весь світ підтримує це рішення, і тільки зрадники проти.",
157
+ "Просто роби, що тобі кажуть, і не став зайвих питань."
158
+ ]
159
+
160
+ batch_results = detect_manipulation_batch(corpus)
161
+
162
+ # Print results for the batch
163
+ for i, text in enumerate(corpus):
164
+ print(f"\nText: \"{text}\"")
165
+ detected_batch = {}
166
+ for j, score in enumerate(batch_results[i]):
167
+ if score > threshold:
168
+ detected_batch[labels[j]] = f"{score:.2f}"
169
+
170
+ if detected_batch:
171
+ print("Detected techniques:")
172
+ for technique, score in detected_batch.items():
173
+ print(f"- {technique} (Score: {score})")
174
+ else:
175
+ print("No manipulation techniques detected.")
176
+ ```
177
+
178
+ ## Performance
179
+
180
+ *Note: Metrics will be updated after the final evaluation.*
181
 
182
  | Metric | Value |
183
+ | :--- | :--- |
184
+ | F1 Macro | 0.46 |
185
+ | F1 Micro | 0.68 |
 
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
+ ## Limitations
188
 
189
+ * **Language Specificity:** The model is optimized for Ukrainian and may not perform well on other languages.
190
+ * **Domain Sensitivity:** Trained primarily on political and social media discourse, its performance may vary on other text domains.
191
+ * **Context Length:** The model is limited to short texts (up to 512 tokens). Longer documents must be chunked or truncated.
192
+ * **Class Imbalance:** Some manipulation techniques are underrepresented in the training data, which may affect their detection accuracy.
193
+ * **Mixed Language:** Accuracy may be reduced on text with heavy code-mixing of Ukrainian and Russian.
194
 
195
+ ## Ethical Considerations
196
 
197
+ * **Purpose:** This model is intended as a tool to support media literacy and critical thinking, not as an arbiter of truth.
198
+ * **Human Oversight:** Model outputs should be interpreted with human judgment and a full understanding of the context. It should not be used to automatically censor content.
199
+ * **Potential Biases:** The model may reflect biases present in the training data.
200
 
201
+ ## Citation
 
202
 
203
+ If you use this model in your research, please cite the following:
 
 
 
 
 
 
 
204
 
205
+ ```bibtex
206
  @misc{ukrainian-manipulation-modernbert-2025,
207
  author = {Oleh Mell},
208
  title = {Ukrainian Manipulation Detector - ModernBERT},
 
210
  publisher = {Hugging Face},
211
  url = {[https://huggingface.co/olehmell/ukr-manipulation-detector-modern-bert](https://huggingface.co/olehmell/ukr-manipulation-detector-modern-bert)}
212
  }
213
+ ```
214
+ ```bibtex
215
  @inproceedings{unlp2025shared,
216
  title={UNLP 2025 Shared Task on Techniques Classification},
217
  author={UNLP Workshop Organizers},
 
219
  year={2025},
220
  url={[https://github.com/unlp-workshop/unlp-2025-shared-task](https://github.com/unlp-workshop/unlp-2025-shared-task)}
221
  }
222
+ ```
223
 
224
+ ## License
225
 
226
+ This model is licensed under the **Apache 2.0 License**.
 
227
 
228
+ ## Contact
 
229
 
230
+ For questions or feedback, please open an issue on the model's Hugging Face repository.
 
231
 
232
+ ## Acknowledgments
233
 
234
+ * The organizers of the UNLP 2025 Workshop for providing the dataset.
235
+ * Goader for creating and sharing the base `modern-liberta-large` model for Ukrainian.