anismahmahi commited on
Commit
73535a9
·
1 Parent(s): e181d84

Add SetFit model

Browse files
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,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ metrics:
9
+ - accuracy
10
+ widget:
11
+ - text: 'It was a jihad training camp.
12
+
13
+ '
14
+ - text: 'Batten echoed that sentiment saying, “Tommy Robinson is a political prisoner."
15
+
16
+ '
17
+ - text: 'Failing to answer, Ellison tried to move from person to person, allowing
18
+ his minions to try and provide cover for him, similar to that of Maxine Waters,
19
+ but there was no "member''s only" elevator to flee into.
20
+
21
+ '
22
+ - text: 'More details about the horrid compound could be revealed Wednesday when the
23
+ five adults arrested from the site make their first court appearances.
24
+
25
+ '
26
+ - text: 'Black Death Warning: The Plague Is Impossible To Eradicate
27
+
28
+ '
29
+ pipeline_tag: text-classification
30
+ inference: false
31
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
32
+ model-index:
33
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
34
+ results:
35
+ - task:
36
+ type: text-classification
37
+ name: Text Classification
38
+ dataset:
39
+ name: Unknown
40
+ type: unknown
41
+ split: test
42
+ metrics:
43
+ - type: accuracy
44
+ value: 0.5849056603773585
45
+ name: Accuracy
46
+ ---
47
+
48
+ # SetFit with sentence-transformers/paraphrase-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-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2) as the Sentence Transformer embedding model. A OneVsRestClassifier 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-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
62
+ - **Classification head:** a OneVsRestClassifier instance
63
+ - **Maximum Sequence Length:** 512 tokens
64
+ <!-- - **Number of Classes:** Unknown -->
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
+ ## Evaluation
76
+
77
+ ### Metrics
78
+ | Label | Accuracy |
79
+ |:--------|:---------|
80
+ | **all** | 0.5849 |
81
+
82
+ ## Uses
83
+
84
+ ### Direct Use for Inference
85
+
86
+ First install the SetFit library:
87
+
88
+ ```bash
89
+ pip install setfit
90
+ ```
91
+
92
+ Then you can load this model and run inference.
93
+
94
+ ```python
95
+ from setfit import SetFitModel
96
+
97
+ # Download from the 🤗 Hub
98
+ model = SetFitModel.from_pretrained("anismahmahi/G2-multilabel-setfit-model")
99
+ # Run inference
100
+ preds = model("It was a jihad training camp.
101
+ ")
102
+ ```
103
+
104
+ <!--
105
+ ### Downstream Use
106
+
107
+ *List how someone could finetune this model on their own dataset.*
108
+ -->
109
+
110
+ <!--
111
+ ### Out-of-Scope Use
112
+
113
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
114
+ -->
115
+
116
+ <!--
117
+ ## Bias, Risks and Limitations
118
+
119
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
120
+ -->
121
+
122
+ <!--
123
+ ### Recommendations
124
+
125
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
126
+ -->
127
+
128
+ ## Training Details
129
+
130
+ ### Training Set Metrics
131
+ | Training set | Min | Median | Max |
132
+ |:-------------|:----|:--------|:----|
133
+ | Word count | 1 | 26.6518 | 129 |
134
+
135
+ ### Training Hyperparameters
136
+ - batch_size: (16, 16)
137
+ - num_epochs: (2, 2)
138
+ - max_steps: -1
139
+ - sampling_strategy: oversampling
140
+ - num_iterations: 10
141
+ - body_learning_rate: (2e-05, 1e-05)
142
+ - head_learning_rate: 0.01
143
+ - loss: CosineSimilarityLoss
144
+ - distance_metric: cosine_distance
145
+ - margin: 0.25
146
+ - end_to_end: False
147
+ - use_amp: False
148
+ - warmup_proportion: 0.1
149
+ - seed: 42
150
+ - eval_max_steps: -1
151
+ - load_best_model_at_end: True
152
+
153
+ ### Training Results
154
+ | Epoch | Step | Training Loss | Validation Loss |
155
+ |:-------:|:--------:|:-------------:|:---------------:|
156
+ | 0.0006 | 1 | 0.3905 | - |
157
+ | 0.0275 | 50 | 0.2239 | - |
158
+ | 0.0550 | 100 | 0.2359 | - |
159
+ | 0.0826 | 150 | 0.2443 | - |
160
+ | 0.1101 | 200 | 0.2495 | - |
161
+ | 0.1376 | 250 | 0.2498 | - |
162
+ | 0.1651 | 300 | 0.116 | - |
163
+ | 0.1926 | 350 | 0.1672 | - |
164
+ | 0.2201 | 400 | 0.1281 | - |
165
+ | 0.2477 | 450 | 0.139 | - |
166
+ | 0.2752 | 500 | 0.0615 | - |
167
+ | 0.3027 | 550 | 0.0972 | - |
168
+ | 0.3302 | 600 | 0.0851 | - |
169
+ | 0.3577 | 650 | 0.1769 | - |
170
+ | 0.3853 | 700 | 0.1673 | - |
171
+ | 0.4128 | 750 | 0.0615 | - |
172
+ | 0.4403 | 800 | 0.1232 | - |
173
+ | 0.4678 | 850 | 0.0094 | - |
174
+ | 0.4953 | 900 | 0.0135 | - |
175
+ | 0.5228 | 950 | 0.0107 | - |
176
+ | 0.5504 | 1000 | 0.1137 | - |
177
+ | 0.5779 | 1050 | 0.0173 | - |
178
+ | 0.6054 | 1100 | 0.0573 | - |
179
+ | 0.6329 | 1150 | 0.0115 | - |
180
+ | 0.6604 | 1200 | 0.0374 | - |
181
+ | 0.6879 | 1250 | 0.0231 | - |
182
+ | 0.7155 | 1300 | 0.0392 | - |
183
+ | 0.7430 | 1350 | 0.0754 | - |
184
+ | 0.7705 | 1400 | 0.007 | - |
185
+ | 0.7980 | 1450 | 0.0138 | - |
186
+ | 0.8255 | 1500 | 0.0569 | - |
187
+ | 0.8531 | 1550 | 0.0971 | - |
188
+ | 0.8806 | 1600 | 0.1052 | - |
189
+ | 0.9081 | 1650 | 0.0084 | - |
190
+ | 0.9356 | 1700 | 0.0859 | - |
191
+ | 0.9631 | 1750 | 0.0081 | - |
192
+ | 0.9906 | 1800 | 0.0362 | - |
193
+ | 1.0 | 1817 | - | 0.2354 |
194
+ | 1.0182 | 1850 | 0.0429 | - |
195
+ | 1.0457 | 1900 | 0.056 | - |
196
+ | 1.0732 | 1950 | 0.0098 | - |
197
+ | 1.1007 | 2000 | 0.002 | - |
198
+ | 1.1282 | 2050 | 0.0892 | - |
199
+ | 1.1558 | 2100 | 0.0557 | - |
200
+ | 1.1833 | 2150 | 0.001 | - |
201
+ | 1.2108 | 2200 | 0.0125 | - |
202
+ | 1.2383 | 2250 | 0.0152 | - |
203
+ | 1.2658 | 2300 | 0.0202 | - |
204
+ | 1.2933 | 2350 | 0.0593 | - |
205
+ | 1.3209 | 2400 | 0.007 | - |
206
+ | 1.3484 | 2450 | 0.014 | - |
207
+ | 1.3759 | 2500 | 0.003 | - |
208
+ | 1.4034 | 2550 | 0.0012 | - |
209
+ | 1.4309 | 2600 | 0.0139 | - |
210
+ | 1.4584 | 2650 | 0.0149 | - |
211
+ | 1.4860 | 2700 | 0.002 | - |
212
+ | 1.5135 | 2750 | 0.009 | - |
213
+ | 1.5410 | 2800 | 0.0066 | - |
214
+ | 1.5685 | 2850 | 0.0173 | - |
215
+ | 1.5960 | 2900 | 0.0052 | - |
216
+ | 1.6236 | 2950 | 0.0039 | - |
217
+ | 1.6511 | 3000 | 0.0042 | - |
218
+ | 1.6786 | 3050 | 0.0339 | - |
219
+ | 1.7061 | 3100 | 0.001 | - |
220
+ | 1.7336 | 3150 | 0.0005 | - |
221
+ | 1.7611 | 3200 | 0.0049 | - |
222
+ | 1.7887 | 3250 | 0.01 | - |
223
+ | 1.8162 | 3300 | 0.0815 | - |
224
+ | 1.8437 | 3350 | 0.0227 | - |
225
+ | 1.8712 | 3400 | 0.005 | - |
226
+ | 1.8987 | 3450 | 0.0053 | - |
227
+ | 1.9263 | 3500 | 0.0152 | - |
228
+ | 1.9538 | 3550 | 0.0155 | - |
229
+ | 1.9813 | 3600 | 0.0182 | - |
230
+ | **2.0** | **3634** | **-** | **0.2266** |
231
+
232
+ * The bold row denotes the saved checkpoint.
233
+ ### Framework Versions
234
+ - Python: 3.10.12
235
+ - SetFit: 1.0.1
236
+ - Sentence Transformers: 2.2.2
237
+ - Transformers: 4.35.2
238
+ - PyTorch: 2.1.0+cu121
239
+ - Datasets: 2.16.1
240
+ - Tokenizers: 0.15.0
241
+
242
+ ## Citation
243
+
244
+ ### BibTeX
245
+ ```bibtex
246
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
247
+ doi = {10.48550/ARXIV.2209.11055},
248
+ url = {https://arxiv.org/abs/2209.11055},
249
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
250
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
251
+ title = {Efficient Few-Shot Learning Without Prompts},
252
+ publisher = {arXiv},
253
+ year = {2022},
254
+ copyright = {Creative Commons Attribution 4.0 International}
255
+ }
256
+ ```
257
+
258
+ <!--
259
+ ## Glossary
260
+
261
+ *Clearly define terms in order to be accessible across audiences.*
262
+ -->
263
+
264
+ <!--
265
+ ## Model Card Authors
266
+
267
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
268
+ -->
269
+
270
+ <!--
271
+ ## Model Card Contact
272
+
273
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
274
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "checkpoints/step_3634/",
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.35.2",
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.7.0",
5
+ "pytorch": "1.9.0+cu102"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": null
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80373903682af993db094960f50d8bcb3de978e341c7f759a8137ccc4d6c1651
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b649a30dc0040d068305581bb5fc7140dc387d55f179bf9cdc824f0e1f1166ee
3
+ size 39876
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": 512,
3
+ "do_lower_case": false
4
+ }
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
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "104": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "30526": {
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
+ "do_basic_tokenize": true,
48
+ "do_lower_case": true,
49
+ "eos_token": "</s>",
50
+ "mask_token": "<mask>",
51
+ "max_length": 512,
52
+ "model_max_length": 512,
53
+ "never_split": null,
54
+ "pad_to_multiple_of": null,
55
+ "pad_token": "<pad>",
56
+ "pad_token_type_id": 0,
57
+ "padding_side": "right",
58
+ "sep_token": "</s>",
59
+ "stride": 0,
60
+ "strip_accents": null,
61
+ "tokenize_chinese_chars": true,
62
+ "tokenizer_class": "MPNetTokenizer",
63
+ "truncation_side": "right",
64
+ "truncation_strategy": "longest_first",
65
+ "unk_token": "[UNK]"
66
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff