Add SetFit model
Browse files- 1_Pooling/config.json +7 -0
- README.md +255 -0
- config.json +24 -0
- config_sentence_transformers.json +7 -0
- config_setfit.json +4 -0
- model_head.pkl +3 -0
- modules.json +20 -0
- pytorch_model.bin +3 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +15 -0
- tokenizer.json +0 -0
- tokenizer_config.json +16 -0
- vocab.txt +0 -0
1_Pooling/config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 768,
|
3 |
+
"pooling_mode_cls_token": false,
|
4 |
+
"pooling_mode_mean_tokens": true,
|
5 |
+
"pooling_mode_max_tokens": false,
|
6 |
+
"pooling_mode_mean_sqrt_len_tokens": false
|
7 |
+
}
|
README.md
ADDED
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: setfit
|
3 |
+
tags:
|
4 |
+
- setfit
|
5 |
+
- sentence-transformers
|
6 |
+
- text-classification
|
7 |
+
- generated_from_setfit_trainer
|
8 |
+
metrics:
|
9 |
+
- Precision_micro
|
10 |
+
- Precision_weighted
|
11 |
+
- Precision_samples
|
12 |
+
- Recall_micro
|
13 |
+
- Recall_weighted
|
14 |
+
- Recall_samples
|
15 |
+
- F1-Score
|
16 |
+
- accuracy
|
17 |
+
widget:
|
18 |
+
- text: Violence from intimate partners and male family members can escalate during
|
19 |
+
emergencies. This tends to increase as the crisis worsens, and men have lost their
|
20 |
+
jobs and status – particularly in communities with traditional gender roles, and
|
21 |
+
where family violence is normalised
|
22 |
+
- text: Expand livelihood protection policies that assist vulnerable, low-income individuals
|
23 |
+
to recover from damages associated with extreme weather events; provide support
|
24 |
+
and protection for internally displaced persons, persons displaced across borders
|
25 |
+
and host communities;. By 2026, draw up disaster recovery plans for all 22 municipalities
|
26 |
+
with resource inventories, first response measures and actions (including on logistics)
|
27 |
+
concerning humanitarian post-disaster needs.
|
28 |
+
- text: recurrent droughts, (decrease in amount of rainfall from 550 to 400mm in the
|
29 |
+
highlands), changes in seasonality that had resulted frequent crop failure, massive
|
30 |
+
death of livestock, genetic erosion, extinction of endemic species, degradation
|
31 |
+
of habitats and disequilibria in the ecosystem structure and function. The impact
|
32 |
+
of climate change is manifested in recurrent droughts, desertification, sea level
|
33 |
+
rise and increase in sea water temperature, depletion of ground water, widespread
|
34 |
+
land degradation, and emergence of climate sensitive diseases.
|
35 |
+
- text: They live in geographical regions and ecosystems that are the most vulnerable
|
36 |
+
to climate change. These include polar regions, humid tropical forests, high mountains,
|
37 |
+
small islands, coastal regions, and arid and semi-arid lands, among others. The
|
38 |
+
impacts of climate change in such regions have strong implications for the ecosystem-based
|
39 |
+
livelihoods on which many indigenous peoples depend. Moreover, in some regions
|
40 |
+
such as the Pacific, the very existence of many indigenous territories is under
|
41 |
+
threat from rising sea levels that not only pose a grave threat to indigenous
|
42 |
+
peoples’ livelihoods but also to their cultures and ways of life.
|
43 |
+
- text: Overcoming Poverty. Colombia, as a developing country, faces major socioeconomic
|
44 |
+
challenges. According to the official figures of DANE, by 2014, the percentage
|
45 |
+
of people in multidimensional poverty situation was 21.9% (this figure rises to
|
46 |
+
44.1% if we take into account only the rural population). For the same year, 28.5%
|
47 |
+
of the population was found in a situation of monetary poverty (41.4% of the population
|
48 |
+
in the case of the villages and rural centers scattered).
|
49 |
+
pipeline_tag: text-classification
|
50 |
+
inference: false
|
51 |
+
base_model: sentence-transformers/all-mpnet-base-v2
|
52 |
+
model-index:
|
53 |
+
- name: SetFit with sentence-transformers/all-mpnet-base-v2
|
54 |
+
results:
|
55 |
+
- task:
|
56 |
+
type: text-classification
|
57 |
+
name: Text Classification
|
58 |
+
dataset:
|
59 |
+
name: Unknown
|
60 |
+
type: unknown
|
61 |
+
split: test
|
62 |
+
metrics:
|
63 |
+
- type: Precision_micro
|
64 |
+
value: 0.7972027972027972
|
65 |
+
name: Precision_Micro
|
66 |
+
- type: Precision_weighted
|
67 |
+
value: 0.8053038510784989
|
68 |
+
name: Precision_Weighted
|
69 |
+
- type: Precision_samples
|
70 |
+
value: 0.7972027972027972
|
71 |
+
name: Precision_Samples
|
72 |
+
- type: Recall_micro
|
73 |
+
value: 0.7972027972027972
|
74 |
+
name: Recall_Micro
|
75 |
+
- type: Recall_weighted
|
76 |
+
value: 0.7972027972027972
|
77 |
+
name: Recall_Weighted
|
78 |
+
- type: Recall_samples
|
79 |
+
value: 0.7972027972027972
|
80 |
+
name: Recall_Samples
|
81 |
+
- type: F1-Score
|
82 |
+
value: 0.7972027972027972
|
83 |
+
name: F1-Score
|
84 |
+
- type: accuracy
|
85 |
+
value: 0.7972027972027972
|
86 |
+
name: Accuracy
|
87 |
+
---
|
88 |
+
|
89 |
+
# SetFit with sentence-transformers/all-mpnet-base-v2
|
90 |
+
|
91 |
+
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) as the Sentence Transformer embedding model. A OneVsRestClassifier instance is used for classification.
|
92 |
+
|
93 |
+
The model has been trained using an efficient few-shot learning technique that involves:
|
94 |
+
|
95 |
+
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
|
96 |
+
2. Training a classification head with features from the fine-tuned Sentence Transformer.
|
97 |
+
|
98 |
+
## Model Details
|
99 |
+
|
100 |
+
### Model Description
|
101 |
+
- **Model Type:** SetFit
|
102 |
+
- **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
|
103 |
+
- **Classification head:** a OneVsRestClassifier instance
|
104 |
+
- **Maximum Sequence Length:** 384 tokens
|
105 |
+
<!-- - **Number of Classes:** Unknown -->
|
106 |
+
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
|
107 |
+
<!-- - **Language:** Unknown -->
|
108 |
+
<!-- - **License:** Unknown -->
|
109 |
+
|
110 |
+
### Model Sources
|
111 |
+
|
112 |
+
- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
|
113 |
+
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
|
114 |
+
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
115 |
+
|
116 |
+
## Evaluation
|
117 |
+
|
118 |
+
### Metrics
|
119 |
+
| Label | Precision_Micro | Precision_Weighted | Precision_Samples | Recall_Micro | Recall_Weighted | Recall_Samples | F1-Score | Accuracy |
|
120 |
+
|:--------|:----------------|:-------------------|:------------------|:-------------|:----------------|:---------------|:---------|:---------|
|
121 |
+
| **all** | 0.7972 | 0.8053 | 0.7972 | 0.7972 | 0.7972 | 0.7972 | 0.7972 | 0.7972 |
|
122 |
+
|
123 |
+
## Uses
|
124 |
+
|
125 |
+
### Direct Use for Inference
|
126 |
+
|
127 |
+
First install the SetFit library:
|
128 |
+
|
129 |
+
```bash
|
130 |
+
pip install setfit
|
131 |
+
```
|
132 |
+
|
133 |
+
Then you can load this model and run inference.
|
134 |
+
|
135 |
+
```python
|
136 |
+
from setfit import SetFitModel
|
137 |
+
|
138 |
+
# Download from the 🤗 Hub
|
139 |
+
model = SetFitModel.from_pretrained("leavoigt/vulnerability_target")
|
140 |
+
# Run inference
|
141 |
+
preds = model("Violence from intimate partners and male family members can escalate during emergencies. This tends to increase as the crisis worsens, and men have lost their jobs and status – particularly in communities with traditional gender roles, and where family violence is normalised")
|
142 |
+
```
|
143 |
+
|
144 |
+
<!--
|
145 |
+
### Downstream Use
|
146 |
+
|
147 |
+
*List how someone could finetune this model on their own dataset.*
|
148 |
+
-->
|
149 |
+
|
150 |
+
<!--
|
151 |
+
### Out-of-Scope Use
|
152 |
+
|
153 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
154 |
+
-->
|
155 |
+
|
156 |
+
<!--
|
157 |
+
## Bias, Risks and Limitations
|
158 |
+
|
159 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
160 |
+
-->
|
161 |
+
|
162 |
+
<!--
|
163 |
+
### Recommendations
|
164 |
+
|
165 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
166 |
+
-->
|
167 |
+
|
168 |
+
## Training Details
|
169 |
+
|
170 |
+
### Training Set Metrics
|
171 |
+
| Training set | Min | Median | Max |
|
172 |
+
|:-------------|:----|:--------|:----|
|
173 |
+
| Word count | 15 | 71.9518 | 238 |
|
174 |
+
|
175 |
+
### Training Hyperparameters
|
176 |
+
- batch_size: (16, 16)
|
177 |
+
- num_epochs: (1, 1)
|
178 |
+
- max_steps: -1
|
179 |
+
- sampling_strategy: oversampling
|
180 |
+
- num_iterations: 20
|
181 |
+
- body_learning_rate: (2e-05, 2e-05)
|
182 |
+
- head_learning_rate: 2e-05
|
183 |
+
- loss: CosineSimilarityLoss
|
184 |
+
- distance_metric: cosine_distance
|
185 |
+
- margin: 0.25
|
186 |
+
- end_to_end: False
|
187 |
+
- use_amp: False
|
188 |
+
- warmup_proportion: 0.1
|
189 |
+
- seed: 42
|
190 |
+
- eval_max_steps: -1
|
191 |
+
- load_best_model_at_end: False
|
192 |
+
|
193 |
+
### Training Results
|
194 |
+
| Epoch | Step | Training Loss | Validation Loss |
|
195 |
+
|:------:|:----:|:-------------:|:---------------:|
|
196 |
+
| 0.0012 | 1 | 0.2559 | - |
|
197 |
+
| 0.0602 | 50 | 0.2509 | - |
|
198 |
+
| 0.1205 | 100 | 0.2595 | - |
|
199 |
+
| 0.1807 | 150 | 0.0868 | - |
|
200 |
+
| 0.2410 | 200 | 0.0302 | - |
|
201 |
+
| 0.3012 | 250 | 0.0024 | - |
|
202 |
+
| 0.3614 | 300 | 0.0225 | - |
|
203 |
+
| 0.4217 | 350 | 0.0007 | - |
|
204 |
+
| 0.4819 | 400 | 0.0004 | - |
|
205 |
+
| 0.5422 | 450 | 0.0003 | - |
|
206 |
+
| 0.6024 | 500 | 0.0002 | - |
|
207 |
+
| 0.6627 | 550 | 0.0005 | - |
|
208 |
+
| 0.7229 | 600 | 0.0319 | - |
|
209 |
+
| 0.7831 | 650 | 0.0001 | - |
|
210 |
+
| 0.8434 | 700 | 0.0104 | - |
|
211 |
+
| 0.9036 | 750 | 0.0003 | - |
|
212 |
+
| 0.9639 | 800 | 0.0009 | - |
|
213 |
+
|
214 |
+
### Framework Versions
|
215 |
+
- Python: 3.10.12
|
216 |
+
- SetFit: 1.0.1
|
217 |
+
- Sentence Transformers: 2.2.2
|
218 |
+
- Transformers: 4.25.1
|
219 |
+
- PyTorch: 2.1.0+cu121
|
220 |
+
- Datasets: 2.16.1
|
221 |
+
- Tokenizers: 0.13.3
|
222 |
+
|
223 |
+
## Citation
|
224 |
+
|
225 |
+
### BibTeX
|
226 |
+
```bibtex
|
227 |
+
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
228 |
+
doi = {10.48550/ARXIV.2209.11055},
|
229 |
+
url = {https://arxiv.org/abs/2209.11055},
|
230 |
+
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
231 |
+
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
232 |
+
title = {Efficient Few-Shot Learning Without Prompts},
|
233 |
+
publisher = {arXiv},
|
234 |
+
year = {2022},
|
235 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
236 |
+
}
|
237 |
+
```
|
238 |
+
|
239 |
+
<!--
|
240 |
+
## Glossary
|
241 |
+
|
242 |
+
*Clearly define terms in order to be accessible across audiences.*
|
243 |
+
-->
|
244 |
+
|
245 |
+
<!--
|
246 |
+
## Model Card Authors
|
247 |
+
|
248 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
249 |
+
-->
|
250 |
+
|
251 |
+
<!--
|
252 |
+
## Model Card Contact
|
253 |
+
|
254 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
255 |
+
-->
|
config.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_all-mpnet-base-v2/",
|
3 |
+
"architectures": [
|
4 |
+
"MPNetModel"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"bos_token_id": 0,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 768,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 3072,
|
14 |
+
"layer_norm_eps": 1e-05,
|
15 |
+
"max_position_embeddings": 514,
|
16 |
+
"model_type": "mpnet",
|
17 |
+
"num_attention_heads": 12,
|
18 |
+
"num_hidden_layers": 12,
|
19 |
+
"pad_token_id": 1,
|
20 |
+
"relative_attention_num_buckets": 32,
|
21 |
+
"torch_dtype": "float32",
|
22 |
+
"transformers_version": "4.25.1",
|
23 |
+
"vocab_size": 30527
|
24 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.0.0",
|
4 |
+
"transformers": "4.6.1",
|
5 |
+
"pytorch": "1.8.1"
|
6 |
+
}
|
7 |
+
}
|
config_setfit.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"labels": null,
|
3 |
+
"normalize_embeddings": false
|
4 |
+
}
|
model_head.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:21a68d4e0e07be270d3269ec0649d0450f5c2f5aacb912bb4381821794f08f6c
|
3 |
+
size 13956
|
modules.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"idx": 0,
|
4 |
+
"name": "0",
|
5 |
+
"path": "",
|
6 |
+
"type": "sentence_transformers.models.Transformer"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"idx": 1,
|
10 |
+
"name": "1",
|
11 |
+
"path": "1_Pooling",
|
12 |
+
"type": "sentence_transformers.models.Pooling"
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"idx": 2,
|
16 |
+
"name": "2",
|
17 |
+
"path": "2_Normalize",
|
18 |
+
"type": "sentence_transformers.models.Normalize"
|
19 |
+
}
|
20 |
+
]
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c76b3427c76aa76bb48187a1b4a7f125229943b9887e4c2bae30dbed7753011e
|
3 |
+
size 438016938
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 384,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "<mask>",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "</s>",
|
14 |
+
"unk_token": "[UNK]"
|
15 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"do_lower_case": true,
|
5 |
+
"eos_token": "</s>",
|
6 |
+
"mask_token": "<mask>",
|
7 |
+
"model_max_length": 512,
|
8 |
+
"name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_all-mpnet-base-v2/",
|
9 |
+
"pad_token": "<pad>",
|
10 |
+
"sep_token": "</s>",
|
11 |
+
"special_tokens_map_file": null,
|
12 |
+
"strip_accents": null,
|
13 |
+
"tokenize_chinese_chars": true,
|
14 |
+
"tokenizer_class": "MPNetTokenizer",
|
15 |
+
"unk_token": "[UNK]"
|
16 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|