leavoigt commited on
Commit
67c2be1
1 Parent(s): 7b909d3

Add SetFit model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
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
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2
3
+ library_name: setfit
4
+ metrics:
5
+ - accuracy
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - setfit
9
+ - sentence-transformers
10
+ - text-classification
11
+ - generated_from_setfit_trainer
12
+ widget:
13
+ - text: Dominica is striving for multi-sectoral and multi-level adaptation across
14
+ all segments of society, giving particular consideration to vulnerable groups
15
+ - the poor, disabled, elderly and Kalinago community; as well as gender disparities.
16
+ Recognising the threats posed by climate change, Dominica has over the last two
17
+ decades, undertaken a number of initiatives to respond to this threat. The adaptation
18
+ component has been revised to incorporate updated information on regional climate
19
+ change projections and impacts on Caribbean SIDS.
20
+ - text: They live in geographical regions and ecosystems that are the most vulnerable
21
+ to climate change. These include polar regions, humid tropical forests, high mountains,
22
+ small islands, coastal regions, and arid and semi-arid lands, among others. The
23
+ impacts of climate change in such regions have strong implications for the ecosystem-based
24
+ livelihoods on which many indigenous peoples depend. Moreover, in some regions
25
+ such as the Pacific, the very existence of many indigenous territories is under
26
+ threat from rising sea levels that not only pose a grave threat to indigenous
27
+ peoples’ livelihoods but also to their cultures and ways of life.
28
+ - text: Seek to increase urban resilience by developing master plans for rainwater
29
+ drainage, improving and extending drainage infrastructure, and implementing flood
30
+ management systems in vulnerable areas. Adaptive capacity of agro- silvo- pastoral
31
+ production and promotion of blue economy.
32
+ - text: As the average annual precipitation across the country is expected to decline
33
+ 2.6-3.4% by 2025 and 5.9-6.3% by 2050 this will result direct yield response.
34
+ As described by PACE experiment59 on the Pastures and Climate Extremes using a
35
+ factorial combination of elevated temperature (ambient +3°C) and winter/spring
36
+ extreme drought (60% rainfall reduction) resulted in productivity declines of
37
+ up to 73%. Functional group identity was not an important predictor of yield response
38
+ to drought.
39
+ - text: Poor rural households in marginal territories that have a low productive potential
40
+ and/or that are far from markets and infrastructure are highly vulnerable to climate-change
41
+ impacts and could easily fall into poverty-environment traps 9. This means that
42
+ communities that are already struggling economically and geographically isolated
43
+ are at greater risk of experiencing the negative impacts of climate change on
44
+ their agricultural livelihoods.
45
+ inference: false
46
+ ---
47
+
48
+ # SetFit with sentence-transformers/paraphrase-multilingual-mpnet-base-v2
49
+
50
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2) as the Sentence Transformer embedding model. A [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance is used for classification.
51
+
52
+ The model has been trained using an efficient few-shot learning technique that involves:
53
+
54
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
55
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
56
+
57
+ ## Model Details
58
+
59
+ ### Model Description
60
+ - **Model Type:** SetFit
61
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2)
62
+ - **Classification head:** a [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance
63
+ - **Maximum Sequence Length:** 128 tokens
64
+ - **Number of Classes:** 18 classes
65
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
66
+ <!-- - **Language:** Unknown -->
67
+ <!-- - **License:** Unknown -->
68
+
69
+ ### Model Sources
70
+
71
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
72
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
73
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
74
+
75
+ ## Uses
76
+
77
+ ### Direct Use for Inference
78
+
79
+ First install the SetFit library:
80
+
81
+ ```bash
82
+ pip install setfit
83
+ ```
84
+
85
+ Then you can load this model and run inference.
86
+
87
+ ```python
88
+ from setfit import SetFitModel
89
+
90
+ # Download from the 🤗 Hub
91
+ model = SetFitModel.from_pretrained("leavoigt/vulnerability_multilabel_v2")
92
+ # Run inference
93
+ preds = model("Seek to increase urban resilience by developing master plans for rainwater drainage, improving and extending drainage infrastructure, and implementing flood management systems in vulnerable areas. Adaptive capacity of agro- silvo- pastoral production and promotion of blue economy.")
94
+ ```
95
+
96
+ <!--
97
+ ### Downstream Use
98
+
99
+ *List how someone could finetune this model on their own dataset.*
100
+ -->
101
+
102
+ <!--
103
+ ### Out-of-Scope Use
104
+
105
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
106
+ -->
107
+
108
+ <!--
109
+ ## Bias, Risks and Limitations
110
+
111
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
112
+ -->
113
+
114
+ <!--
115
+ ### Recommendations
116
+
117
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
118
+ -->
119
+
120
+ ## Training Details
121
+
122
+ ### Training Set Metrics
123
+ | Training set | Min | Median | Max |
124
+ |:-------------|:----|:--------|:----|
125
+ | Word count | 1 | 61.3809 | 164 |
126
+
127
+ ### Training Hyperparameters
128
+ - batch_size: (16, 2)
129
+ - num_epochs: (1, 0)
130
+ - max_steps: -1
131
+ - sampling_strategy: undersampling
132
+ - body_learning_rate: (2e-05, 1e-05)
133
+ - head_learning_rate: 0.01
134
+ - loss: CosineSimilarityLoss
135
+ - distance_metric: cosine_distance
136
+ - margin: 0.25
137
+ - end_to_end: False
138
+ - use_amp: False
139
+ - warmup_proportion: 0.01
140
+ - seed: 42
141
+ - eval_max_steps: -1
142
+ - load_best_model_at_end: False
143
+
144
+ ### Training Results
145
+ | Epoch | Step | Training Loss | Validation Loss |
146
+ |:------:|:----:|:-------------:|:---------------:|
147
+ | 0.0002 | 1 | 0.25 | - |
148
+ | 0.2084 | 1000 | 0.0461 | 0.1223 |
149
+ | 0.4168 | 2000 | 0.0169 | 0.1294 |
150
+ | 0.6251 | 3000 | 0.032 | 0.121 |
151
+ | 0.8335 | 4000 | 0.023 | 0.1172 |
152
+
153
+ ### Framework Versions
154
+ - Python: 3.10.12
155
+ - SetFit: 1.0.3
156
+ - Sentence Transformers: 3.0.1
157
+ - Transformers: 4.36.2
158
+ - PyTorch: 2.4.0+cu121
159
+ - Datasets: 2.10.0
160
+ - Tokenizers: 0.15.2
161
+
162
+ ## Citation
163
+
164
+ ### BibTeX
165
+ ```bibtex
166
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
167
+ doi = {10.48550/ARXIV.2209.11055},
168
+ url = {https://arxiv.org/abs/2209.11055},
169
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
170
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
171
+ title = {Efficient Few-Shot Learning Without Prompts},
172
+ publisher = {arXiv},
173
+ year = {2022},
174
+ copyright = {Creative Commons Attribution 4.0 International}
175
+ }
176
+ ```
177
+
178
+ <!--
179
+ ## Glossary
180
+
181
+ *Clearly define terms in order to be accessible across audiences.*
182
+ -->
183
+
184
+ <!--
185
+ ## Model Card Authors
186
+
187
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
188
+ -->
189
+
190
+ <!--
191
+ ## Model Card Contact
192
+
193
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
194
+ -->
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "sentence-transformers/paraphrase-multilingual-mpnet-base-v2",
3
+ "architectures": [
4
+ "XLMRobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 514,
18
+ "model_type": "xlm-roberta",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 12,
21
+ "output_past": true,
22
+ "pad_token_id": 1,
23
+ "position_embedding_type": "absolute",
24
+ "torch_dtype": "float32",
25
+ "transformers_version": "4.36.2",
26
+ "type_vocab_size": 1,
27
+ "use_cache": true,
28
+ "vocab_size": 250002
29
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.0.1",
4
+ "transformers": "4.36.2",
5
+ "pytorch": "2.4.0+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": true,
3
+ "labels": [
4
+ "Agricultural communities",
5
+ "Children",
6
+ "Coastal communities",
7
+ "Ethnic, racial or other minorities",
8
+ "Fishery communities",
9
+ "Informal sector workers",
10
+ "Members of indigenous and local communities",
11
+ "Migrants and displaced persons",
12
+ "Older persons",
13
+ "Other",
14
+ "Persons living in poverty",
15
+ "Persons with disabilities",
16
+ "Persons with pre-existing health conditions",
17
+ "Residents of drought-prone regions",
18
+ "Rural populations",
19
+ "Sexual minorities (LGBTQI+)",
20
+ "Urban populations",
21
+ "Women and other genders"
22
+ ]
23
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fedf70398830dab9bbe99c14cf7f13f1c864d24fdca91be5d3bdb127bb6dcc18
3
+ size 1112197096
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbdac5450027969068723fdeebd15a4a44b0ebb7c87da7eca0682df3536800ba
3
+ size 56922
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 128,
3
+ "do_lower_case": false
4
+ }
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa685fc160bbdbab64058d4fc91b60e62d207e8dc60b9af5c002c5ab946ded00
3
+ size 17083009
tokenizer_config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "max_length": 128,
50
+ "model_max_length": 128,
51
+ "pad_to_multiple_of": null,
52
+ "pad_token": "<pad>",
53
+ "pad_token_type_id": 0,
54
+ "padding_side": "right",
55
+ "sep_token": "</s>",
56
+ "stride": 0,
57
+ "tokenizer_class": "XLMRobertaTokenizer",
58
+ "truncation_side": "right",
59
+ "truncation_strategy": "longest_first",
60
+ "unk_token": "<unk>"
61
+ }