gefero commited on
Commit
6c8ca5a
·
verified ·
1 Parent(s): 3ec979c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +235 -100
README.md CHANGED
@@ -1,199 +1,334 @@
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
  library_name: transformers
3
+ tags:
4
+ - text-classification
5
+ - spanish
6
+ - conflict-detection
7
+ - xlm-roberta
8
+ language:
9
+ - es
10
  ---
11
 
12
+ # Model Card for XLM-RoBERTa Spanish Conflict Detection Classifier
 
 
13
 
14
+ <!-- Quick summary of what the model is/does. -->
15
 
16
+ A fine-tuned XLM-RoBERTa model for detecting social conflict mentions in Spanish news articles. The model is trained on the "Conflicto Social en Noticias" dataset and achieves 91.07% macro-F1 score on test data, making it suitable for automated content classification and conflict-related news filtering.
17
 
18
  ## Model Details
19
 
20
  ### Model Description
21
 
22
+ <!-- Longer summary of what this model is. -->
23
 
24
+ This is a binary text classification model based on **FacebookAI/xlm-roberta-base** fine-tuned to detect whether Spanish news articles discuss social conflict or not. The model was trained using a rigorous multi-seed approach (10 random seeds) to ensure robustness and generalization.
25
 
26
+ The classification task is binary:
27
+ - **CONFLICTO** (1): News articles that discuss social conflict
28
+ - **NO_CONFLICTO** (0): News articles that do not discuss social conflict
 
 
 
 
29
 
30
+ The model achieved strong performance across multiple evaluation runs, with consistent metrics indicating reliable predictions on unseen test data.
31
 
32
+ ### Model Details
33
 
34
+ - **Developed by:** Germán Rosati (Factor~Data, SICSS-Buenos Aires)
35
+ - **Model type:** Transformer-based text classification
36
+ - **Language(s) (NLP):** Spanish (es)
37
+ - **License:** MIT
38
+ - **Finetuned from model:** [FacebookAI/xlm-roberta-base](https://huggingface.co/FacebookAI/xlm-roberta-base)
39
 
40
+ ### Model Sources
41
 
42
+ - **Repository:** https://github.com/gefero/factor_data_tuto_NLP_SICSS
43
+ - **Dataset:** [agusnieto77/conflicto-social-noticias-4034](https://huggingface.co/datasets/agusnieto77/conflicto-social-noticias-4034)
44
+
45
+ ## Uses
46
 
47
  ### Direct Use
48
 
49
+ This model can be used for:
50
 
51
+ - **Automated news classification:** Identify news articles discussing social conflict in Spanish-language sources
52
+ - **Content moderation:** Flag conflict-related content for review or categorization
53
+ - **News aggregation:** Filter and organize news by conflict relevance
54
+ - **Research and analytics:** Systematic analysis of conflict coverage in news media
55
+ - **Social media monitoring:** Detect posts discussing social conflict
56
 
57
  ### Downstream Use [optional]
58
 
59
+ This model can be integrated into:
60
 
61
+ - News recommendation systems to provide conflict-focused news feeds
62
+ - Content management systems for automated news categorization
63
+ - Data pipelines for media analysis research
64
+ - Misinformation detection systems (as a conflict-detection component)
65
 
66
  ### Out-of-Scope Use
67
 
68
+ This model is **not suitable for:**
69
 
70
+ - Languages other than Spanish (though XLM-RoBERTa is multilingual, the model was fine-tuned only on Spanish data)
71
+ - Content moderation decisions without human review (should be used as a scoring/filtering tool, not final arbiter)
72
+ - Real-time moderation of live content streams without performance testing in your specific domain
73
+ - Classification of informal text, social media, or user-generated content not resembling news articles (model trained on news)
74
 
75
  ## Bias, Risks, and Limitations
76
 
77
+ ### Limitations
78
 
79
+ 1. **Language:** Model trained exclusively on Spanish news articles. Performance on other languages or dialects is unknown.
80
 
81
+ 2. **Domain:** Model trained on news articles. Performance on other text types (social media, academic text, etc.) may be degraded.
82
 
83
+ 3. **Temporal bias:** Dataset represents a specific time period. Linguistic evolution and emerging conflict narratives may not be captured.
84
 
85
+ 4. **Class balance:** Dataset contains both conflict and non-conflict examples. Performance may vary based on class distribution in your specific use case.
86
 
87
+ 5. **Truncation:** Text is truncated to 256 tokens (matching model's training setup). Very long articles may lose important context.
88
 
89
+ 6. **Context sensitivity:** "Conflict" detection is based on textual patterns. Sarcasm, irony, or indirect references may be misclassified.
90
 
91
+ ### Risks and Biases
92
 
93
+ - **Labeling bias:** Model inherits any biases present in the original dataset annotation process
94
+ - **Geographic bias:** News sources and conflict types in training data may not represent all Spanish-speaking regions equally
95
+ - **Media bias:** Model trained on news articles, which may have their own coverage biases
96
+ - **Potential overreach:** Model might flag articles mentioning conflict in non-concerning contexts (e.g., historical analysis, conflict resolution discussion)
97
 
98
+ ### Recommendations
99
 
100
+ 1. **Always validate:** Test the model on your specific data before production deployment
101
+ 2. **Human review:** Use model predictions as a starting point for human review, not as final decisions
102
+ 3. **Monitor performance:** Track model performance over time and across different domains
103
+ 4. **Document decisions:** Keep clear records of how the model is being used and any adjustments made
104
+ 5. **Consider context:** Combine model predictions with other signals for robust classification decisions
105
 
106
+ ## How to Get Started with the Model
107
 
108
+ ### Installation
109
+
110
+ ```bash
111
+ pip install transformers torch
112
+ ```
113
+
114
+ ### Quickstart - Using the Pipeline API
115
+
116
+ ```python
117
+ from transformers import pipeline
118
+
119
+ # Initialize the model
120
+ classifier = pipeline(
121
+ "text-classification",
122
+ model="gefero/conflict_detection_ROBERTA_based"
123
+ )
124
+
125
+ # Classify text
126
+ texts = [
127
+ "El gobierno anunció nuevas políticas de seguridad social",
128
+ "Miles de personas protestaron en las calles contra las medidas económicas"
129
+ ]
130
+
131
+ results = classifier(texts)
132
+ for text, result in zip(texts, results):
133
+ print(f"Text: {text[:50]}...")
134
+ print(f"Label: {result['label']} (score: {result['score']:.4f})\n")
135
+ ```
136
+
137
+ ### Quickstart - Using the Model Directly
138
+
139
+ ```python
140
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
141
+ import torch
142
+
143
+ model_name = "gefero/conflict_detection_ROBERTA_based"
144
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
145
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
146
+
147
+ # Prepare input
148
+ text = "Manifestantes se enfrentan con la policía"
149
+ inputs = tokenizer(
150
+ text,
151
+ truncation=True,
152
+ padding="max_length",
153
+ max_length=256,
154
+ return_tensors="pt"
155
+ )
156
+
157
+ # Get predictions
158
+ with torch.no_grad():
159
+ outputs = model(**inputs)
160
+ logits = outputs.logits
161
+ predictions = torch.argmax(logits, dim=-1)
162
+ confidence = torch.softmax(logits, dim=-1).max().item()
163
+
164
+ labels = {0: "NO_CONFLICTO", 1: "CONFLICTO"}
165
+ print(f"Prediction: {labels[predictions.item()]} (confidence: {confidence:.4f})")
166
+ ```
167
 
168
+ ## Training Details
169
 
170
+ ### Training Data
171
 
172
+ - **Dataset:** [agusnieto77/conflicto-social-noticias-4034](https://huggingface.co/datasets/agusnieto77/conflicto-social-noticias-4034)
173
+ - **Language:** Spanish (es)
174
+ - **Domain:** News articles
175
+ - **Splits used:**
176
+ - Training set: 70% (~2,823 examples)
177
+ - Development set: 10% (~403 examples)
178
+ - Test set: 20% (~806 examples)
179
 
180
+ ### Training Procedure
181
 
182
+ #### Preprocessing
183
 
184
+ - **Tokenization:** XLM-RoBERTa tokenizer
185
+ - **Max length:** 256 tokens (increased from default 128 to capture longer articles)
186
+ - **Truncation:** Long articles truncated to max_length
187
+ - **Padding:** Padded to max_length for batch processing
188
 
189
+ #### Training Hyperparameters
190
 
191
+ - **Base model:** FacebookAI/xlm-roberta-base
192
+ - **Learning rate:** 2e-5
193
+ - **Batch size:** 16 (training), 64 (evaluation)
194
+ - **Epochs:** 5
195
+ - **Weight decay:** 0.01
196
+ - **Warmup steps:** 0.1 (proportion of total training steps)
197
+ - **Evaluation strategy:** Evaluate at the end of each epoch
198
+ - **Best model selection:** Based on macro-F1 on development set
199
+ - **Hardware:** GPU with FP16 (mixed precision) when available
200
+ - **Random seeds:** 10 seeds [0, 1, 7, 13, 42, 100, 123, 2024, 31337, 65535] for robust evaluation
201
 
202
+ #### Training Details
203
 
204
+ - **Framework:** Hugging Face Transformers
205
+ - **Optimizer:** AdamW (default)
206
+ - **Metric for best model:** macro-F1 (average of precision and recall across both classes)
207
+ - **Multi-seed training:** Model was trained 10 times with different random seeds to ensure robustness and to provide confidence intervals on performance metrics
208
 
209
+ ## Evaluation
210
 
211
  ### Testing Data, Factors & Metrics
212
 
213
  #### Testing Data
214
 
215
+ - **Split:** Test set (20% of original data, stratified split)
216
+ - **Size:** ~806 examples
217
+ - **Language:** Spanish
218
+ - **Domain:** News articles from the original dataset
 
 
 
 
 
219
 
220
  #### Metrics
221
 
222
+ - **Macro-F1** (primary metric): Average F1-score across both classes
223
+ - Used for model selection during training
224
+ - Balances precision and recall
225
+ - Better for imbalanced or binary classification tasks
226
+
227
+ - **Accuracy:** Overall correctness of predictions
228
+ - **F1-CONFLICTO:** F1-score specifically for the CONFLICTO class (conflict-related news)
229
+ - **Precision:** True positives / (true positives + false positives)
230
+ - **Recall:** True positives / (true positives + false negatives)
231
 
232
  ### Results
233
 
234
+ #### Official Test Results (10 runs with different seeds)
235
+
236
+ | Metric | Mean | Std Dev | Min | Max |
237
+ |--------|------|---------|-----|-----|
238
+ | **Test Macro-F1** | 0.9107 | 0.0071 | 0.8999 | 0.9204 |
239
+ | **Test Accuracy** | 0.9394 | 0.0053 | 0.9319 | 0.9468 |
240
+ | **Test F1-CONFLICTO** | 0.8602 | 0.0108 | 0.8433 | 0.8746 |
241
+ | **Test Precision** | 0.8807 | 0.0296 | 0.8307 | 0.9182 |
242
+ | **Test Recall** | 0.8419 | 0.0247 | 0.8156 | 0.8883 |
243
+
244
+ #### Per-Seed Results
245
+
246
+ | Seed | Dev Macro-F1 | Test Macro-F1 | Test Accuracy | Test F1-CONFLICTO | Test Precision | Test Recall |
247
+ |------|--------------|---------------|---------------|-------------------|----------------|-------------|
248
+ | 0 | 0.9113 | 0.9007 | 0.9332 | 0.8439 | 0.8743 | 0.8156 |
249
+ | 1 | 0.9116 | 0.8999 | 0.9319 | 0.8433 | 0.8605 | 0.8268 |
250
+ | 7 | 0.8975 | 0.9092 | 0.9381 | 0.8580 | 0.8728 | 0.8436 |
251
+ | 13 | 0.9187 | 0.9140 | 0.9431 | 0.8639 | 0.9182 | 0.8156 |
252
+ | 42 | 0.9154 | 0.9127 | 0.9418 | 0.8622 | 0.9074 | 0.8212 |
253
+ | 100 | 0.9219 | 0.9136 | 0.9394 | 0.8665 | 0.8457 | 0.8883 |
254
+ | 123 | 0.9146 | 0.9194 | 0.9455 | 0.8736 | 0.8994 | 0.8492 |
255
+ | 2024 | 0.9098 | 0.9125 | 0.9406 | 0.8629 | 0.8830 | 0.8436 |
256
+ | 31337 | 0.9180 | 0.9204 | 0.9468 | 0.8746 | 0.9146 | 0.8380 |
257
+ | 65535 | 0.9168 | 0.9050 | 0.9332 | 0.8533 | 0.8307 | 0.8771 |
258
 
259
  #### Summary
260
 
261
+ The model demonstrates **excellent performance** with:
262
+ - **High macro-F1 (0.91):** Balanced and strong predictions on both classes
263
+ - **High accuracy (0.94):** Correct classification in 94% of cases
264
+ - **Robust across seeds:** Low standard deviation indicates consistent generalization
265
+ - **Strong conflict detection (F1-CONFLICTO: 0.86):** Reliably identifies conflict-related news
266
 
267
+ ## Environmental Impact
268
 
269
+ ### Compute Infrastructure
 
 
270
 
271
+ #### Hardware
272
 
273
+ - **GPU:** NVIDIA GPU (exact model unspecified, but typical for Colab)
274
+ - **CPU:** Supporting processors on Colab infrastructure
275
+ - **RAM:** Standard Colab allocation
276
 
277
+ #### Training Time
278
 
279
+ - **Per seed:** ~5-10 minutes (5 epochs per training run)
280
+ - **Total:** ~50-100 minutes for 10 complete runs
281
+ - **Cloud Platform:** Google Colaboratory (free tier)
282
 
283
+ #### Carbon Emissions
 
 
 
 
284
 
285
+ Estimated CO2 emissions for multi-seed training approach: **Low to minimal** (Colab's data centers use renewable energy sources). Individual training runs are short (~10 min each) and performed on highly optimized infrastructure.
286
 
287
+ For detailed calculations, see [ML Impact Calculator](https://mlco2.github.io/impact#compute).
288
 
289
+ ## Technical Specifications
290
 
291
+ ### Model Architecture and Objective
292
 
293
+ - **Architecture:** Transformer-based sequence classification
294
+ - Base: XLM-RoBERTa (12 layers, 768 hidden dimensions, 110M parameters)
295
+ - Task-specific layer: Linear classification head for 2 classes
296
+
297
+ - **Objective:** Binary cross-entropy loss (standard for text classification)
298
 
299
+ - **Multilingual base:** XLM-RoBERTa trained on 100+ languages, fine-tuned here for Spanish-specific conflict detection
300
 
301
+ ### Input/Output
302
 
303
+ - **Input:** Spanish text (news articles)
304
+ - **Max length:** 256 tokens
305
+ - **Output:** Class probabilities for [NO_CONFLICTO, CONFLICTO]
306
 
307
  ## Citation [optional]
308
 
309
+ If you use this model in research, please cite:
310
 
311
  **BibTeX:**
312
 
313
+ ```bibtex
314
+ @software{rosati2024conflictdetection,
315
+ author = {Rosati, Germán},
316
+ title = {XLM-RoBERTa Spanish Conflict Detection Classifier},
317
+ year = {2024},
318
+ publisher = {Hugging Face Hub},
319
+ url = {https://huggingface.co/gefero/conflict_detection_ROBERTA_based}
320
+ }
321
+ ```
322
 
323
  **APA:**
324
 
325
+ Rosati, G. (2024). XLM-RoBERTa Spanish Conflict Detection Classifier [Machine learning model]. Hugging Face Hub. Retrieved from https://huggingface.co/gefero/conflict_detection_ROBERTA_based
 
 
 
 
 
 
 
 
 
 
326
 
327
+ ## Model Card Authors
328
 
329
+ - **Germán Rosati** (Factor~Data, SICSS-Buenos Aires)
330
 
331
  ## Model Card Contact
332
 
333
+ - **Email:** german.rosati@gmail.com
334
+ - **GitHub:** https://github.com/gefero