shreyasmeher commited on
Commit
2d2b1c8
·
verified ·
1 Parent(s): e845c90

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +117 -92
README.md CHANGED
@@ -38,139 +38,164 @@ inference:
38
  do_sample: true
39
  ---
40
 
 
41
 
42
- # ConflLlama: Domain-Specific LLM for Conflict Event Classification
43
 
44
- \<p align="center"\>
45
- \<img src="images/logo.png" alt="Project Logo" width="300"/\>
46
- \</p\>
47
-
48
- **ConflLlama** is a large language model fine-tuned to classify conflict events from text descriptions. This repository contains the GGUF quantized models (q4\_k\_m, q8\_0, and BF16) based on **Llama-3.1 8B**, which have been adapted for the specialized domain of political violence research.
49
-
50
- This model was developed as part of the research paper:
51
- **Meher, S., & Brandt, P. T. (2025). ConflLlama: Domain-specific adaptation of large language models for conflict event classification. *Research & Politics*, July-September 2025. [https://doi.org/10.1177/20531680251356282](https://doi.org/10.1177/20531680251356282)**
52
 
53
  -----
54
 
55
- ### Key Contributions
56
-
57
- The ConflLlama project demonstrates how efficient fine-tuning of large language models can significantly advance the automated classification of political events. The key contributions are:
58
 
59
- * **State-of-the-Art Performance**: Achieves a macro-averaged AUC of 0.791 and a weighted F1-score of 0.758, representing a 37.6% improvement over the base model.
60
- * **Efficient Domain Adaptation**: Utilizes Quantized Low-Rank Adaptation (QLORA) to fine-tune the Llama-3.1 8B model, making it accessible for researchers with consumer-grade hardware.
61
- * **Enhanced Classification**: Delivers accuracy gains of up to 1463% in challenging and rare event categories like "Unarmed Assault".
62
- * **Robust Multi-Label Classification**: Effectively handles complex events with multiple concurrent attack types, achieving a Subset Accuracy of 0.724.
63
-
64
- -----
65
-
66
- ### Model Performance
67
-
68
- ConflLlama variants substantially outperform the base Llama-3.1 model in zero-shot classification. The fine-tuned models show significant gains across all major metrics, demonstrating the effectiveness of domain-specific adaptation.
69
-
70
- | Model | Accuracy | Macro F1 | Weighted F1 | AUC |
71
- | :--- | :--- | :--- | :--- | :--- |
72
- | **ConflLlama-Q8** | **0.765** | **0.582** | **0.758** | **0.791** |
73
- | ConflLlama-Q4 | 0.729 | 0.286 | 0.718 | 0.749 |
74
- | Base Llama-3.1 | 0.346 | 0.012 | 0.369 | 0.575 |
75
-
76
- The most significant improvements were observed in historically difficult-to-classify categories:
77
-
78
- * **Unarmed Assault**: 1464% improvement (F1-score from 0.035 to 0.553).
79
- * **Hostage Taking (Barricade)**: 692% improvement (F1-score from 0.045 to 0.353).
80
- * **Hijacking**: 527% improvement (F1-score from 0.100 to 0.629).
81
- * **Armed Assault**: 84% improvement (F1-score from 0.374 to 0.687).
82
- * **Bombing/Explosion**: 65% improvement (F1-score from 0.549 to 0.908).
83
 
84
- -----
 
 
 
 
 
85
 
86
- ### Model Architecture and Training
87
 
88
- * **Base Model**: `unsloth/llama-3-8b-bnb-4bit`
89
- * **Framework**: QLoRA (Quantized Low-Rank Adaptation)
90
- * **Hardware**: NVIDIA A100-SXM4-40GB GPU on the Delta Supercomputer at NCSA.
91
- * **Optimizations**: 4-bit quantization, gradient checkpointing, and other memory-saving techniques were used to ensure the model could be trained and run on consumer-grade hardware (under 6 GB of VRAM).
92
- * **LoRA Configuration**:
93
- * Rank (`r`): 8
94
- * Alpha (`lora_alpha`): 16
95
- * Target Modules: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  \<p align="center"\>
98
  \<img src="images/model-arch.png" alt="Model Training Architecture" width="800"/\>
99
  \</p\>
100
 
101
- ### Training Data
102
 
103
- * **Dataset**: [Global Terrorism Database (GTD)](https://www.start.umd.edu/gtd/). The GTD contains systematic data on over 200,000 terrorist incidents.
104
- * **Time Period**: The training dataset consists of 171,514 events that occurred before January 1, 2017. The test set includes 38,192 events from 2017 onwards.
105
- * **Preprocessing**: The pipeline filters data by date, cleans text summaries, and combines primary, secondary, and tertiary attack types into a single multi-label field.
106
 
107
  \<p align="center"\>
108
  \<img src="images/preprocessing.png" alt="Data Preprocessing Pipeline" width="800"/\>
109
  \</p\>
110
 
111
- -----
112
 
113
- ### Intended Use
 
 
 
 
114
 
115
- This model is designed for academic and research purposes within the fields of political science, conflict studies, and security analysis.
116
 
117
- 1. **Classification of terrorist events** based on narrative descriptions.
118
- 2. **Research** into patterns of political violence and terrorism.
119
- 3. **Automated coding** of event data for large-scale analysis.
120
 
121
- ### Limitations
 
 
 
122
 
123
- 1. **Temporal Scope**: The model is trained on events prior to 2017 and may not fully capture novel or evolving attack patterns that have emerged since.
124
- 2. **Task-Specific Focus**: The model is specialized for **attack type classification** and is not designed for identifying perpetrators, locations, or targets.
125
- 3. **Data Dependency**: Performance is dependent on the quality and detail of the input event descriptions.
126
- 4. **Semantic Ambiguity**: The model may occasionally struggle to distinguish between semantically close categories, such as 'Armed Assault' and 'Assassination,' when tactical details overlap.
127
 
128
- ### Ethical Considerations
 
 
 
129
 
130
- 1. The model is trained on sensitive data related to real-world terrorism and should be used responsibly.
131
- 2. It is intended for research and analysis, **not for operational security decisions** or prognostications.
132
- 3. Outputs should be interpreted with an understanding of the data's context and the model's limitations. Over-classification can lead to resource misallocation in real-world scenarios.
133
 
134
- -----
 
 
 
135
 
136
- ### Citation
137
 
138
- If you use this model or the findings from the paper in your research, please cite both the paper and the model repository.
 
 
139
 
140
- **Research Paper:**
141
 
142
- ```bibtex
143
- @article{meher2025conflllama,
144
- title={{ConflLlama: Domain-specific adaptation of large language models for conflict event classification}},
145
- author={Meher, Shreyas and Brandt, Patrick T.},
146
- journal={Research \& Politics},
147
- volume={12},
148
- number={3},
149
- year={2025},
150
- publisher={SAGE Publications},
151
- doi={10.1177/20531680251356282},
152
- url={https://doi.org/10.1177/20531680251356282}
153
- }
154
- ```
155
 
156
- **Model Repository:**
157
 
158
  ```bibtex
159
- @misc{conflllama_model,
160
  author = {Meher, Shreyas},
161
- title = {ConflLlama: GTD-Finetuned Llama-3 8B},
162
  year = {2024},
163
  publisher = {HuggingFace},
164
- note = {Based on Meta's Llama-3.1 8B and the Global Terrorism Database}
165
  }
166
  ```
167
 
168
- ### Acknowledgments
169
 
170
- * This research was supported by **NSF award 2311142**.
171
- * This work utilized the **Delta** system at the **NCSA (University of Illinois)** through ACCESS allocation **CIS220162**.
172
- * Thanks to the **Unsloth** team for their optimization framework and base model.
173
- * Thanks to **Hugging Face** for the model hosting and `transformers` infrastructure.
174
- * Thanks to the **Global Terrorism Database** team at the University of Maryland.
175
 
176
  \<img src="[https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png](https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png)" width="200"/\>
 
38
  do_sample: true
39
  ---
40
 
41
+ You are absolutely right, and I sincerely apologize. I made an error in my previous responses by accidentally omitting the "Training Logs" image and its description. I understand your frustration. My intention was not to change the information, but I failed to include all of it.
42
 
43
+ I will restore the documentation now to include **all** the original image markdown exactly as it was provided, including the training logs section that I missed.
44
 
45
+ Here is the complete and corrected documentation:
 
 
 
 
 
 
 
46
 
47
  -----
48
 
49
+ # ConflLlama: GTD-Finetuned Llama-3 8B
 
 
50
 
51
+ \<p align="center"\>
52
+ \<img src="images/logo.png" alt="Project Logo" width="300"/\>
53
+ \</p\>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
+ - **Model Type:** GGUF quantized (q4\_k\_m and q8\_0)
56
+ - **Base Model:** unsloth/llama-3-8b-bnb-4bit
57
+ - **Quantization Details:**
58
+ - Methods: q4\_k\_m, q8\_0, BF16
59
+ - q4\_k\_m uses Q6\_K for half of attention.wv and feed\_forward.w2 tensors
60
+ - Optimized for both speed (q8\_0) and quality (q4\_k\_m)
61
 
62
+ ### Training Data
63
 
64
+ - **Dataset:** Global Terrorism Database (GTD)
65
+ - **Time Period:** Events before January 1, 2017
66
+ - **Format:** Event summaries with associated attack types
67
+ - **Labels:** Attack type classifications from GTD
68
+
69
+ ### Data Processing
70
+
71
+ 1. **Date Filtering:**
72
+ - Filtered events occurring before 2017-01-01
73
+ - Handled missing dates by setting default month/day to 1
74
+ 2. **Data Cleaning:**
75
+ - Removed entries with missing summaries
76
+ - Cleaned summary text by removing special characters and formatting
77
+ 3. **Attack Type Processing:**
78
+ - Combined multiple attack types with separator '|'
79
+ - Included primary, secondary, and tertiary attack types when available
80
+ 4. **Training Format:**
81
+ - Input: Processed event summaries
82
+ - Output: Combined attack types
83
+ - Used chat template:
84
+ ```
85
+ Below describes details about terrorist events.
86
+ >>> Event Details:
87
+ {summary}
88
+ >>> Attack Types:
89
+ {combined_attacks}
90
+ ```
91
+
92
+ ### Training Details
93
+
94
+ - **Framework:** QLoRA
95
+ - **Hardware:** NVIDIA A100-SXM4-40GB GPU on Delta Supercomputer
96
+ - **Training Configuration:**
97
+ - Batch Size: 1 per device
98
+ - Gradient Accumulation Steps: 8
99
+ - Learning Rate: 2e-4
100
+ - Max Steps: 1000
101
+ - Save Steps: 200
102
+ - Logging Steps: 10
103
+ - **LoRA Configuration:**
104
+ - Rank: 8
105
+ - Target Modules: q\_proj, k\_proj, v\_proj, o\_proj, gate\_proj, up\_proj, down\_proj
106
+ - Alpha: 16
107
+ - Dropout: 0
108
+ - **Optimizations:**
109
+ - Gradient Checkpointing: Enabled
110
+ - 4-bit Quantization: Enabled
111
+ - Max Sequence Length: 1024
112
+
113
+ ## Model Architecture
114
+
115
+ The model uses a combination of efficient fine-tuning techniques and optimizations for handling conflict event classification:
116
 
117
  \<p align="center"\>
118
  \<img src="images/model-arch.png" alt="Model Training Architecture" width="800"/\>
119
  \</p\>
120
 
121
+ ### Data Processing Pipeline
122
 
123
+ The preprocessing pipeline transforms raw GTD data into a format suitable for fine-tuning:
 
 
124
 
125
  \<p align="center"\>
126
  \<img src="images/preprocessing.png" alt="Data Preprocessing Pipeline" width="800"/\>
127
  \</p\>
128
 
129
+ ### Memory Optimizations
130
 
131
+ - Used 4-bit quantization
132
+ - Gradient accumulation steps: 8
133
+ - Memory-efficient gradient checkpointing
134
+ - Reduced maximum sequence length to 1024
135
+ - Disabled dataloader pin memory
136
 
137
+ ## Intended Use
138
 
139
+ This model is designed for:
 
 
140
 
141
+ 1. Classification of terrorist events based on event descriptions
142
+ 2. Research in conflict studies and terrorism analysis
143
+ 3. Understanding attack type patterns in historical events
144
+ 4. Academic research in security studies
145
 
146
+ ## Limitations
 
 
 
147
 
148
+ 1. Training data limited to pre-2017 events
149
+ 2. Maximum sequence length limited to 1024 tokens
150
+ 3. May not capture recent changes in attack patterns
151
+ 4. Performance dependent on quality of event descriptions
152
 
153
+ ## Ethical Considerations
 
 
154
 
155
+ 1. Model trained on sensitive terrorism-related data
156
+ 2. Should be used responsibly for research purposes only
157
+ 3. Not intended for operational security decisions
158
+ 4. Results should be interpreted with appropriate context
159
 
160
+ ## Training Logs
161
 
162
+ \<p align="center"\>
163
+ \<img src="images/training.png" alt="Training Logs" width="800"/\>
164
+ \</p\>
165
 
166
+ The training logs show a successful training run with healthy convergence patterns:
167
 
168
+ **Loss & Learning Rate:**
169
+
170
+ - Loss decreases from 1.95 to \~0.90, with rapid initial improvement
171
+ - Learning rate uses warmup/decay schedule, peaking at \~1.5x10^-4
172
+
173
+ **Training Stability:**
174
+
175
+ - Stable gradient norms (0.4-0.6 range)
176
+ - Consistent GPU memory usage (\~5800MB allocated, 7080MB reserved)
177
+ - Steady training speed (\~3.5s/step) with brief interruption at step 800
178
+
179
+ The graphs indicate effective model training with good optimization dynamics and resource utilization. The loss vs. learning rate plot suggests optimal learning around 10^-4.
 
180
 
181
+ ## Citation
182
 
183
  ```bibtex
184
+ @misc{conflllama,
185
  author = {Meher, Shreyas},
186
+ title = {ConflLlama: GTD-Finetuned LLaMA-3 8B},
187
  year = {2024},
188
  publisher = {HuggingFace},
189
+ note = {Based on Meta's LLaMA-3 8B and GTD Dataset}
190
  }
191
  ```
192
 
193
+ ## Acknowledgments
194
 
195
+ - Unsloth for optimization framework and base model
196
+ - Hugging Face for transformers infrastructure
197
+ - Global Terrorism Database team
198
+ - This research was supported by NSF award 2311142
199
+ - This work used Delta at NCSA / University of Illinois through allocation CIS220162 from the Advanced Cyberinfrastructure Coordination Ecosystem: Services & Support (ACCESS) program, which is supported by NSF grants 2138259, 2138286, 2138307, 2137603, and 2138296
200
 
201
  \<img src="[https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png](https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png)" width="200"/\>