Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,200 +1,65 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
- setfit
|
| 4 |
- sentence-transformers
|
| 5 |
- text-classification
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
- text: Katibat Tulkarm (PIJ) and Al Aqsa Martyrs Brigade militants exchanged fire
|
| 9 |
-
with Israeli border police forces that raided Tulkarm (Tulkarm, West Bank). Militants
|
| 10 |
-
also targeted Israeli forces with explosives. In conjunction with the shooting,
|
| 11 |
-
Palestinian rioters clashed with the Israeli forces. Israeli forces fired live
|
| 12 |
-
and rubber-coated bullets, tear gas canisters, and stun grenades to disperse the
|
| 13 |
-
rioters. Israeli forces shot 3 Katibat Tulkarm militants during the clashes, injuring
|
| 14 |
-
them. All 3 later succumbed to their injuries, another 4 were also injured.
|
| 15 |
-
- text: close to Barretos, Guanajuato, an armed individual shot and killed three other
|
| 16 |
-
men inside a parked vehicle on a dirt road. The armed individual then boarded
|
| 17 |
-
another vehicle driven by a second individual. 3 fatalities.
|
| 18 |
-
- text: Russian forces fired 122mm artillery at Yastrubyne, Sumy. Casualties unknown.
|
| 19 |
-
- text: Pro-Hadi forces manage to take a water project
|
| 20 |
-
- text: Injuries are reported during protests to demand potable water, food, and energy
|
| 21 |
-
in Lara state, Venezuela
|
| 22 |
metrics:
|
|
|
|
| 23 |
- accuracy
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
inference: false
|
| 27 |
-
base_model: BAAI/bge-small-en-v1.5
|
| 28 |
---
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5) as the Sentence Transformer embedding model. A OneVsRestClassifier instance is used for classification.
|
| 33 |
-
|
| 34 |
-
The model has been trained using an efficient few-shot learning technique that involves:
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
## Model Details
|
| 40 |
|
| 41 |
-
|
| 42 |
-
- **
|
| 43 |
-
- **
|
| 44 |
-
- **
|
| 45 |
-
- **
|
| 46 |
-
- **Number of Classes:** 3 classes
|
| 47 |
-
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
|
| 48 |
-
<!-- - **Language:** Unknown -->
|
| 49 |
-
<!-- - **License:** Unknown -->
|
| 50 |
-
|
| 51 |
-
### Model Sources
|
| 52 |
-
|
| 53 |
-
- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
|
| 54 |
-
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
|
| 55 |
-
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
| 56 |
-
|
| 57 |
-
## Uses
|
| 58 |
|
| 59 |
-
##
|
| 60 |
-
|
| 61 |
-
First install the SetFit library:
|
| 62 |
-
|
| 63 |
-
```bash
|
| 64 |
-
pip install setfit
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
Then you can load this model and run inference.
|
| 68 |
|
| 69 |
```python
|
| 70 |
from setfit import SetFitModel
|
| 71 |
|
| 72 |
-
# Download from the 🤗 Hub
|
| 73 |
model = SetFitModel.from_pretrained("baobabtech/water-conflict-classifier")
|
| 74 |
-
# Run inference
|
| 75 |
-
preds = model("Pro-Hadi forces manage to take a water project")
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
<!--
|
| 79 |
-
### Downstream Use
|
| 80 |
-
|
| 81 |
-
*List how someone could finetune this model on their own dataset.*
|
| 82 |
-
-->
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
<!--
|
| 91 |
-
## Bias, Risks and Limitations
|
| 92 |
-
|
| 93 |
-
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 94 |
-
-->
|
| 95 |
-
|
| 96 |
-
<!--
|
| 97 |
-
### Recommendations
|
| 98 |
-
|
| 99 |
-
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 100 |
-
-->
|
| 101 |
-
|
| 102 |
-
## Training Details
|
| 103 |
-
|
| 104 |
-
### Training Set Metrics
|
| 105 |
-
| Training set | Min | Median | Max |
|
| 106 |
-
|:-------------|:----|:--------|:----|
|
| 107 |
-
| Word count | 4 | 26.1843 | 167 |
|
| 108 |
-
|
| 109 |
-
### Training Hyperparameters
|
| 110 |
-
- batch_size: (32, 32)
|
| 111 |
-
- num_epochs: (1, 1)
|
| 112 |
-
- max_steps: -1
|
| 113 |
-
- sampling_strategy: undersampling
|
| 114 |
-
- body_learning_rate: (2e-05, 1e-05)
|
| 115 |
-
- head_learning_rate: 0.01
|
| 116 |
-
- loss: CosineSimilarityLoss
|
| 117 |
-
- distance_metric: cosine_distance
|
| 118 |
-
- margin: 0.25
|
| 119 |
-
- end_to_end: False
|
| 120 |
-
- use_amp: False
|
| 121 |
-
- warmup_proportion: 0.1
|
| 122 |
-
- l2_weight: 0.01
|
| 123 |
-
- seed: 42
|
| 124 |
-
- eval_max_steps: -1
|
| 125 |
-
- load_best_model_at_end: True
|
| 126 |
-
|
| 127 |
-
### Training Results
|
| 128 |
-
| Epoch | Step | Training Loss | Validation Loss |
|
| 129 |
-
|:------:|:----:|:-------------:|:---------------:|
|
| 130 |
-
| 0.0008 | 1 | 0.2363 | - |
|
| 131 |
-
| 0.0377 | 50 | 0.212 | - |
|
| 132 |
-
| 0.0754 | 100 | 0.1063 | - |
|
| 133 |
-
| 0.1131 | 150 | 0.0875 | - |
|
| 134 |
-
| 0.1508 | 200 | 0.0637 | - |
|
| 135 |
-
| 0.1885 | 250 | 0.0487 | - |
|
| 136 |
-
| 0.2262 | 300 | 0.0391 | - |
|
| 137 |
-
| 0.2640 | 350 | 0.0335 | - |
|
| 138 |
-
| 0.3017 | 400 | 0.0307 | - |
|
| 139 |
-
| 0.3394 | 450 | 0.027 | - |
|
| 140 |
-
| 0.3771 | 500 | 0.0274 | - |
|
| 141 |
-
| 0.4148 | 550 | 0.0273 | - |
|
| 142 |
-
| 0.4525 | 600 | 0.0298 | - |
|
| 143 |
-
| 0.4902 | 650 | 0.0267 | - |
|
| 144 |
-
| 0.5279 | 700 | 0.0242 | - |
|
| 145 |
-
| 0.5656 | 750 | 0.027 | - |
|
| 146 |
-
| 0.6033 | 800 | 0.0233 | - |
|
| 147 |
-
| 0.6410 | 850 | 0.027 | - |
|
| 148 |
-
| 0.6787 | 900 | 0.0225 | - |
|
| 149 |
-
| 0.7164 | 950 | 0.0237 | - |
|
| 150 |
-
| 0.7541 | 1000 | 0.0203 | - |
|
| 151 |
-
| 0.7919 | 1050 | 0.0193 | - |
|
| 152 |
-
| 0.8296 | 1100 | 0.0202 | - |
|
| 153 |
-
| 0.8673 | 1150 | 0.0202 | - |
|
| 154 |
-
| 0.9050 | 1200 | 0.0213 | - |
|
| 155 |
-
| 0.9427 | 1250 | 0.0216 | - |
|
| 156 |
-
| 0.9804 | 1300 | 0.019 | - |
|
| 157 |
-
| 1.0 | 1326 | - | 0.0649 |
|
| 158 |
-
|
| 159 |
-
### Framework Versions
|
| 160 |
-
- Python: 3.12.12
|
| 161 |
-
- SetFit: 1.1.3
|
| 162 |
-
- Sentence Transformers: 5.1.2
|
| 163 |
-
- Transformers: 4.57.3
|
| 164 |
-
- PyTorch: 2.9.1+cu128
|
| 165 |
-
- Datasets: 4.4.1
|
| 166 |
-
- Tokenizers: 0.22.1
|
| 167 |
-
|
| 168 |
-
## Citation
|
| 169 |
-
|
| 170 |
-
### BibTeX
|
| 171 |
-
```bibtex
|
| 172 |
-
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
| 173 |
-
doi = {10.48550/ARXIV.2209.11055},
|
| 174 |
-
url = {https://arxiv.org/abs/2209.11055},
|
| 175 |
-
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
| 176 |
-
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
| 177 |
-
title = {Efficient Few-Shot Learning Without Prompts},
|
| 178 |
-
publisher = {arXiv},
|
| 179 |
-
year = {2022},
|
| 180 |
-
copyright = {Creative Commons Attribution 4.0 International}
|
| 181 |
-
}
|
| 182 |
```
|
| 183 |
|
| 184 |
-
|
| 185 |
-
## Glossary
|
| 186 |
|
| 187 |
-
|
| 188 |
-
-
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
|
| 191 |
-
## Model Card Authors
|
| 192 |
|
| 193 |
-
|
| 194 |
-
--
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
|
| 199 |
-
|
| 200 |
-
-->
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: setfit
|
| 4 |
tags:
|
| 5 |
- setfit
|
| 6 |
- sentence-transformers
|
| 7 |
- text-classification
|
| 8 |
+
- multi-label
|
| 9 |
+
- water-conflict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
metrics:
|
| 11 |
+
- f1
|
| 12 |
- accuracy
|
| 13 |
+
language:
|
| 14 |
+
- en
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# Water Conflict Multi-Label Classifier
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
This model classifies news headlines about water-related conflicts into three categories:
|
| 20 |
+
- **Trigger**: Water resource as a conflict trigger
|
| 21 |
+
- **Casualty**: Water infrastructure as a casualty/target
|
| 22 |
+
- **Weapon**: Water used as a weapon/tool
|
| 23 |
|
| 24 |
## Model Details
|
| 25 |
|
| 26 |
+
- **Base Model**: BAAI/bge-small-en-v1.5
|
| 27 |
+
- **Architecture**: SetFit with One-vs-Rest multi-label strategy
|
| 28 |
+
- **Training Approach**: Few-shot learning optimized (SetFit reaches peak performance with small samples)
|
| 29 |
+
- **Training Data**: 510 examples (sampled from ~5,000 labeled headlines)
|
| 30 |
+
- **Performance**: F1 (micro) = 0.8319, Accuracy = 0.8333
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
```python
|
| 35 |
from setfit import SetFitModel
|
| 36 |
|
|
|
|
| 37 |
model = SetFitModel.from_pretrained("baobabtech/water-conflict-classifier")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
headlines = [
|
| 40 |
+
"Taliban attack workers at the Kajaki Dam in Afghanistan",
|
| 41 |
+
"New water treatment plant opens in California"
|
| 42 |
+
]
|
| 43 |
|
| 44 |
+
predictions = model.predict(headlines)
|
| 45 |
+
print(predictions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
```
|
| 47 |
|
| 48 |
+
## Training Metrics
|
|
|
|
| 49 |
|
| 50 |
+
- Accuracy (exact match): 0.8333
|
| 51 |
+
- F1 (micro): 0.8319
|
| 52 |
+
- F1 (macro): 0.6755
|
| 53 |
+
- Hamming Loss: 0.0704
|
| 54 |
|
| 55 |
+
## Label Distribution
|
|
|
|
| 56 |
|
| 57 |
+
| Label | F1 Score | Support |
|
| 58 |
+
|-------|----------|---------|
|
| 59 |
+
| Trigger | 0.8837 | 21 |
|
| 60 |
+
| Casualty | 0.8571 | 30 |
|
| 61 |
+
| Weapon | 0.2857 | 5 |
|
| 62 |
|
| 63 |
+
## Citation
|
|
|
|
| 64 |
|
| 65 |
+
Based on ACLED (Armed Conflict Location & Event Data Project) data.
|
|
|