m2im commited on
Commit
5acf86e
verified
1 Parent(s): 7cb3119

initial commit

Browse files
Files changed (1) hide show
  1. README.md +189 -0
README.md ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - multilabel-classification
5
+ - multilingual
6
+ - twitter
7
+ - violence-prediction
8
+ datasets:
9
+ - m2im/multilingual-twitter-collective-violence-dataset
10
+ language:
11
+ - multilingual
12
+ ---
13
+
14
+ # Model Card for m2im/smaller_labse_finetuned_twitter
15
+
16
+ This model is a fine-tuned version of smaller-LaBSE (a distilled variant of LaBSE), specifically adapted to detect collective violence signals in multilingual Twitter discourse. It was developed as part of a research project focused on early-warning systems for conflict prediction.
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+
22
+ - **Developed by:** Dr. Milton Mendieta and Dr. Timothy Warren
23
+ - **Funded by:** Coalition for Open-Source Defense Analysis (CODA) Lab, Department of Defense Analysis, Naval Postgraduate School (NPS)
24
+ - **Shared by:** Dr. Milton Mendieta and Dr. Timothy Warren
25
+ - **Model type:** Transformer-based sentence encoder fine-tuned for multilabel classification
26
+ - **Language(s):** The smaller Language-agnostic BERT Sentence Encoder (smaller-LaBSE) is a distilled version of the original LaBSE model, initially trained on 15 languages. It was subsequently fine-tuned on multilingual social media data from X (formerly Twitter), covering 68 languages from 2014 onward, including the undefined `und` language category.
27
+ - **License:** MIT
28
+ - **Finetuned from model:** [setu4993/smaller-LaBSE](https://huggingface.co/setu4993/smaller-LaBSE)
29
+
30
+ ### Model Sources
31
+
32
+ - **Repository:** [https://github.com/m2im/violence_prediction](https://github.com/m2im/violence_prediction)
33
+ - **Paper:** TBD
34
+
35
+ ## Uses
36
+
37
+ ### Direct Use
38
+
39
+ This model is intended to classify tweets in multiple languages into predefined categories related to proximity to collective violence events.
40
+
41
+ ### Downstream Use
42
+
43
+ The model may be embedded into conflict early-warning systems, government monitoring platforms, or research pipelines analyzing social unrest.
44
+
45
+ ### Out-of-Scope Use
46
+
47
+ - General-purpose sentiment analysis
48
+ - Legal, health, or financial decision-making
49
+ - Use in low-resource languages not covered by training data
50
+
51
+ ## Bias, Risks, and Limitations
52
+
53
+ - **Geographic bias**: The model was primarily trained on short-duration violent events around the world, which limits its applicability to long-running conflicts (e.g., Russia-Ukraine) or high-noise environments (e.g., Washington, D.C.).
54
+ - **Temporal bias**: Performance degrades in pre-violence scenarios, especially at larger spatial scales (50 km), where signals are weaker and often masked by noise.
55
+ - **Sample size sensitivity**: The model underperforms when fewer than 5,000 observations are available per label, reducing reliability in low-data settings.
56
+ - **Spatial ambiguity**: Frequent misclassification between `pre7geo50` and `post7geo50` labels highlights the model鈥檚 challenge in distinguishing temporal contexts at broader spatial radii.
57
+ - **Language coverage limitations**: While fine-tuned on 67 languages, performance may vary for underrepresented or informal language variants.
58
+
59
+ ## Recommendations
60
+
61
+ - **Use with short-term events**: For best results, apply the model to short-term events with geographically concentrated discourse, aligning with the training data distribution.
62
+ - **Avoid low-sample inference**: Do not deploy the model in scenarios where fewer than 5,000 labeled observations are available per class.
63
+ - **Limit reliance on large-radius labels**: Exercise caution when interpreting predictions at 50 km radii, which tend to capture noisy or irrelevant information.
64
+ - **Contextual validation**: Evaluate model performance on local data before broader deployment, especially in unfamiliar regions or languages.
65
+ - **Consider post-processing**: Incorporate ensemble methods or threshold adjustments to improve label differentiation in ambiguous cases.
66
+ - **Batch predictions**: Avoid use in isolated tweets; batch predictions are more reliable
67
+
68
+ ## How to Get Started with the Model
69
+
70
+ ```python
71
+ from transformers import pipeline
72
+ import html, re
73
+
74
+ def clean_tweet(example):
75
+ tweet = example['text']
76
+ tweet = tweet.replace("\n", " ")
77
+ tweet = html.unescape(tweet)
78
+ tweet = re.sub("@[A-Za-z0-9_:]+", "", tweet)
79
+ tweet = re.sub(r'http\S+', '', tweet)
80
+ tweet = re.sub('RT ', '', tweet)
81
+ return {'text': tweet.strip()}
82
+
83
+ pipe = pipeline("text-classification", model="m2im/smaller_labse_finetuned_twitter", tokenizer="m2im/smaller_labse_finetuned_twitter", top_k=None)
84
+
85
+ example = {"text": "Protesta en Quito por medidas econ贸micas."}
86
+ cleaned = clean_tweet(example)
87
+ print(pipe(cleaned["text"]))
88
+ ```
89
+
90
+ ## Training Details
91
+
92
+ ### Training Data
93
+
94
+ - Dataset: [m2im/multilingual-twitter-collective-violence-dataset](https://huggingface.co/datasets/m2im/multilingual-twitter-collective-violence-dataset)
95
+ - Labels: 6 of the most informative out of 40 available:
96
+ - `pre7geo10`, `pre7geo30`, `pre7geo50`
97
+ - `post7geo10`, `post7geo30`, `post7geo50`
98
+
99
+ ### Training Procedure
100
+
101
+ - Text preprocessing using tweet normalization (removal of mentions, URLs, etc.)
102
+ - Tokenization with smaller-LaBSE tokenizer
103
+ - Multi-label head using `BCEWithLogitsLoss`
104
+
105
+ #### Training Hyperparameters
106
+
107
+ - Model checkpoints: `setu4993/smaller-LaBSE`
108
+ - Head class: `AutoModelForSequenceClassification`
109
+ - Optimizer: AdamW
110
+ - Batch size (train/validation): 1024
111
+ - Epochs: 20
112
+ - Learning rate: 5e-5
113
+ - Learning rate scheduler: Cosine
114
+ - Weight decay: 0.1
115
+ - Max sequence length: 32
116
+ - Precision: Mixed fp16
117
+ - Random seed: 42
118
+ - Saving strategy: Save the best model only when the ROC-AUC score improves on the validation set
119
+
120
+ ## Evaluation
121
+
122
+ ### Testing Data, Factors & Metrics
123
+
124
+ - **Dataset**: Held-out portion of the multilingual Twitter collective violence dataset, including over 275,000 tweets labeled across six spatio-temporal categories (`pre7geo10`, `pre7geo30`, `pre7geo50`, `post7geo10`, `post7geo30`, `post7geo50`).
125
+ - **Metrics**:
126
+ - **ROC-AUC** (Receiver Operating Characteristic - Area Under Curve): Evaluates the model鈥檚 ability to distinguish between classes across all thresholds.
127
+ - **Macro F1**: Harmonic mean of precision and recall, averaged equally across all classes.
128
+ - **Micro F1**: Harmonic mean of precision and recall, aggregated globally across all predictions.
129
+ - **Precision** and **Recall**: Standard classification metrics to assess false positive and false negative trade-offs.
130
+
131
+ ### Results
132
+
133
+ - Classical ML models (Random Forest, SVM, Bagging, Boosting, and Decision Trees) were trained on smaller-LaBSE-generated sentence embeddings. The best performing classical model—Random Forest—achieved a **macro F1 score of approximately 0.61**, indicating that embeddings alone provide meaningful but limited discrimination for the multilabel classification task.
134
+ - In contrast, the **fine-tuned smaller-LaBSE model**, trained end-to-end with a classification head, outperformed all baseline classical models by achieving a **ROC-AUC score of 0.7246** on the validation set.
135
+ - These results demonstrate the value of supervised fine-tuning over using frozen embeddings with classical classifiers, particularly in tasks involving subtle multilingual and spatio-temporal signal detection.
136
+
137
+ ## Model Examination
138
+
139
+ - Embedding analysis was conducted using a two-stage dimensionality reduction process: Principal Component Analysis (PCA) reduced the 768-dimensional smaller-LaBSE sentence embeddings to 50 dimensions, followed by Uniform Manifold Approximation and Projection (UMAP) to reduce to 2 dimensions for visualization.
140
+ - The resulting 2D projections revealed coherent clustering of sentence embeddings by label, particularly in post-violence scenarios and at smaller spatial scales (10 km), indicating that the model effectively captures latent structure related to spatio-temporal patterns of collective violence.
141
+ - Examination of classification performance across labels further confirmed that the model is most reliable when predicting post-violence instances near the epicenter of an event, while its ability to detect pre-violence signals—especially at broader spatial radii (50 km)—is weaker and more prone to noise.
142
+
143
+ ## Environmental Impact
144
+
145
+ - **Hardware Type:** 16 NVIDIA Tesla V100 GPUs
146
+ - **Hours used:** ~10 hours
147
+ - **Cloud Provider:** University research computing cluster
148
+ - **Compute Region:** North America
149
+ - **Carbon Emitted:** Not formally calculated
150
+
151
+ ## Technical Specifications
152
+
153
+ ### Model Architecture and Objective
154
+
155
+ - Transformer encoder (BERT-based)
156
+ - Objective: Multilabel binary classification with sentence embeddings
157
+
158
+ ### Compute Infrastructure
159
+
160
+ - **Hardware:** One server with 16 脳 V100 GPUs and one server with 3 TB of RAM, both available at the CODA Lab.
161
+ - **Software:** PyTorch 2.0, Hugging Face Transformers 4.x, KV-Swarm (an in-memory database also hosted at the CODA Lab), Weight and Biases for experiment tracking and model management
162
+
163
+ ## Citation
164
+
165
+ **BibTeX:**
166
+
167
+ ```bibtex
168
+ @misc{mendieta2025labseviolence,
169
+ author = {Milton Mendieta, Timothy Warren},
170
+ title = {Fine-Tuning Multilingual Language Models to Predict Collective Violence Using Twitter Data},
171
+ year = {2025},
172
+ publisher = {Hugging Face},
173
+ howpublished = {\url{https://huggingface.co/m2im/smaller_labse_finetuned_twitter}},
174
+ note = {Research on multilingual NLP and conflict prediction}
175
+ }
176
+ ```
177
+
178
+ ## Citation
179
+
180
+ **APA:**
181
+ Mendieta, M., & Warren, T. (2025). *Fine-tuning multilingual language models to predict collective violence using Twitter data* [Model]. Hugging Face. https://huggingface.co/m2im/smaller_labse_finetuned_twitter
182
+
183
+ ## Model Card Authors
184
+
185
+ Dr. Milton Mendieta and Dr. Timothy Warren
186
+
187
+ ## Model Card Contact
188
+
189
+ mvmendie@espol.edu.ec