richie-ghost commited on
Commit
c94ac11
1 Parent(s): e24df2e

Add SetFit model

Browse files
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,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ base_model: mental/mental-bert-base-uncased
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: I am going through a divorce. He is extremely angry. He refuses to physically
13
+ assist me with our teenager daughter. I have no extended family support. Often
14
+ times, I feel overwhelmed, tired, and joyless. I feel out of control, sad and
15
+ depressed on a daily basis. I am just going through the motions of life every
16
+ day. I am in my mid-50s. I have almost 29 years on my job. How can I handle this?
17
+ - text: Every winter I find myself getting sad because of the weather. How can I fight
18
+ this?
19
+ - text: Adjusting to life after significant life changes
20
+ - text: "I have so many issues to address. I have a history of sexual abuse, I’m a\
21
+ \ breast cancer survivor and I am a lifetime insomniac. I have a long history\
22
+ \ of depression and I’m beginning to have anxiety. I have low self esteem but\
23
+ \ I’ve been happily married for almost 35 years.\n I’ve never had counseling\
24
+ \ about any of this. Do I have too many issues to address in counseling?"
25
+ - text: Planning a DIY home renovation project.
26
+ pipeline_tag: text-classification
27
+ inference: true
28
+ model-index:
29
+ - name: SetFit with mental/mental-bert-base-uncased
30
+ results:
31
+ - task:
32
+ type: text-classification
33
+ name: Text Classification
34
+ dataset:
35
+ name: Unknown
36
+ type: unknown
37
+ split: test
38
+ metrics:
39
+ - type: accuracy
40
+ value: 0.9882352941176471
41
+ name: Accuracy
42
+ ---
43
+
44
+ # SetFit with mental/mental-bert-base-uncased
45
+
46
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [mental/mental-bert-base-uncased](https://huggingface.co/mental/mental-bert-base-uncased) as the Sentence Transformer embedding model. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
47
+
48
+ The model has been trained using an efficient few-shot learning technique that involves:
49
+
50
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
51
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
52
+
53
+ ## Model Details
54
+
55
+ ### Model Description
56
+ - **Model Type:** SetFit
57
+ - **Sentence Transformer body:** [mental/mental-bert-base-uncased](https://huggingface.co/mental/mental-bert-base-uncased)
58
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
59
+ - **Maximum Sequence Length:** 512 tokens
60
+ - **Number of Classes:** 2 classes
61
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
62
+ <!-- - **Language:** Unknown -->
63
+ <!-- - **License:** Unknown -->
64
+
65
+ ### Model Sources
66
+
67
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
68
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
69
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
70
+
71
+ ### Model Labels
72
+ | Label | Examples |
73
+ |:------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
74
+ | True | <ul><li>'I have so many issues to address. I have a history of sexual abuse, I’m a breast cancer survivor and I am a lifetime insomniac. I have a long history of depression and I’m beginning to have anxiety. I have low self esteem but I’ve been happily married for almost 35 years.\n I’ve never had counseling about any of this. Do I have too many issues to address in counseling?'</li><li>'I have so many issues to address. I have a history of sexual abuse, I’m a breast cancer survivor and I am a lifetime insomniac. I have a long history of depression and I’m beginning to have anxiety. I have low self esteem but I’ve been happily married for almost 35 years.\n I’ve never had counseling about any of this. Do I have too many issues to address in counseling?'</li><li>'Experiencing extreme mood swings not related to external circumstances.'</li></ul> |
75
+ | False | <ul><li>'Guide to learning a new language'</li><li>'Learning about the historical significance of the Silk Road.'</li><li>'Exploring historical landmarks in Europe'</li></ul> |
76
+
77
+ ## Evaluation
78
+
79
+ ### Metrics
80
+ | Label | Accuracy |
81
+ |:--------|:---------|
82
+ | **all** | 0.9882 |
83
+
84
+ ## Uses
85
+
86
+ ### Direct Use for Inference
87
+
88
+ First install the SetFit library:
89
+
90
+ ```bash
91
+ pip install setfit
92
+ ```
93
+
94
+ Then you can load this model and run inference.
95
+
96
+ ```python
97
+ from setfit import SetFitModel
98
+
99
+ # Download from the 🤗 Hub
100
+ model = SetFitModel.from_pretrained("richie-ghost/setfit-mental-bert-base-uncased-MH-Topic-Check")
101
+ # Run inference
102
+ preds = model("Planning a DIY home renovation project.")
103
+ ```
104
+
105
+ <!--
106
+ ### Downstream Use
107
+
108
+ *List how someone could finetune this model on their own dataset.*
109
+ -->
110
+
111
+ <!--
112
+ ### Out-of-Scope Use
113
+
114
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
115
+ -->
116
+
117
+ <!--
118
+ ## Bias, Risks and Limitations
119
+
120
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
121
+ -->
122
+
123
+ <!--
124
+ ### Recommendations
125
+
126
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
127
+ -->
128
+
129
+ ## Training Details
130
+
131
+ ### Training Set Metrics
132
+ | Training set | Min | Median | Max |
133
+ |:-------------|:----|:--------|:----|
134
+ | Word count | 4 | 33.7092 | 111 |
135
+
136
+ | Label | Training Sample Count |
137
+ |:------|:----------------------|
138
+ | True | 138 |
139
+ | False | 58 |
140
+
141
+ ### Training Hyperparameters
142
+ - batch_size: (16, 16)
143
+ - num_epochs: (3, 3)
144
+ - max_steps: -1
145
+ - sampling_strategy: oversampling
146
+ - body_learning_rate: (2e-05, 1e-05)
147
+ - head_learning_rate: 0.01
148
+ - loss: CosineSimilarityLoss
149
+ - distance_metric: cosine_distance
150
+ - margin: 0.25
151
+ - end_to_end: False
152
+ - use_amp: False
153
+ - warmup_proportion: 0.1
154
+ - seed: 42
155
+ - eval_max_steps: -1
156
+ - load_best_model_at_end: True
157
+
158
+ ### Training Results
159
+ | Epoch | Step | Training Loss | Validation Loss |
160
+ |:-------:|:--------:|:-------------:|:---------------:|
161
+ | 0.0007 | 1 | 0.2132 | - |
162
+ | 0.0354 | 50 | 0.1508 | - |
163
+ | 0.0708 | 100 | 0.0193 | - |
164
+ | 0.1062 | 150 | 0.0075 | - |
165
+ | 0.1415 | 200 | 0.0025 | - |
166
+ | 0.1769 | 250 | 0.0009 | - |
167
+ | 0.2123 | 300 | 0.0003 | - |
168
+ | 0.2477 | 350 | 0.0005 | - |
169
+ | 0.2831 | 400 | 0.0004 | - |
170
+ | 0.3185 | 450 | 0.0004 | - |
171
+ | 0.3539 | 500 | 0.0002 | - |
172
+ | 0.3892 | 550 | 0.0004 | - |
173
+ | 0.4246 | 600 | 0.0001 | - |
174
+ | 0.4600 | 650 | 0.0003 | - |
175
+ | 0.4954 | 700 | 0.0001 | - |
176
+ | 0.5308 | 750 | 0.0001 | - |
177
+ | 0.5662 | 800 | 0.0001 | - |
178
+ | 0.6016 | 850 | 0.0002 | - |
179
+ | 0.6369 | 900 | 0.0001 | - |
180
+ | 0.6723 | 950 | 0.0001 | - |
181
+ | 0.7077 | 1000 | 0.0001 | - |
182
+ | 0.7431 | 1050 | 0.0 | - |
183
+ | 0.7785 | 1100 | 0.0001 | - |
184
+ | 0.8139 | 1150 | 0.0001 | - |
185
+ | 0.8493 | 1200 | 0.0001 | - |
186
+ | 0.8846 | 1250 | 0.0001 | - |
187
+ | 0.9200 | 1300 | 0.0001 | - |
188
+ | 0.9554 | 1350 | 0.0001 | - |
189
+ | 0.9908 | 1400 | 0.0001 | - |
190
+ | **1.0** | **1413** | **-** | **0.017** |
191
+ | 1.0262 | 1450 | 0.0001 | - |
192
+ | 1.0616 | 1500 | 0.0001 | - |
193
+ | 1.0970 | 1550 | 0.0 | - |
194
+ | 1.1323 | 1600 | 0.0001 | - |
195
+ | 1.1677 | 1650 | 0.0001 | - |
196
+ | 1.2031 | 1700 | 0.0001 | - |
197
+ | 1.2385 | 1750 | 0.0 | - |
198
+ | 1.2739 | 1800 | 0.0001 | - |
199
+ | 1.3093 | 1850 | 0.0 | - |
200
+ | 1.3447 | 1900 | 0.0 | - |
201
+ | 1.3800 | 1950 | 0.0 | - |
202
+ | 1.4154 | 2000 | 0.0 | - |
203
+ | 1.4508 | 2050 | 0.0 | - |
204
+ | 1.4862 | 2100 | 0.0 | - |
205
+ | 1.5216 | 2150 | 0.0 | - |
206
+ | 1.5570 | 2200 | 0.0 | - |
207
+ | 1.5924 | 2250 | 0.0 | - |
208
+ | 1.6277 | 2300 | 0.0 | - |
209
+ | 1.6631 | 2350 | 0.0 | - |
210
+ | 1.6985 | 2400 | 0.0 | - |
211
+ | 1.7339 | 2450 | 0.0 | - |
212
+ | 1.7693 | 2500 | 0.0 | - |
213
+ | 1.8047 | 2550 | 0.0 | - |
214
+ | 1.8401 | 2600 | 0.0 | - |
215
+ | 1.8754 | 2650 | 0.0 | - |
216
+ | 1.9108 | 2700 | 0.0001 | - |
217
+ | 1.9462 | 2750 | 0.0 | - |
218
+ | 1.9816 | 2800 | 0.0 | - |
219
+ | 2.0 | 2826 | - | 0.018 |
220
+ | 2.0170 | 2850 | 0.0 | - |
221
+ | 2.0524 | 2900 | 0.0 | - |
222
+ | 2.0878 | 2950 | 0.0 | - |
223
+ | 2.1231 | 3000 | 0.0 | - |
224
+ | 2.1585 | 3050 | 0.0 | - |
225
+ | 2.1939 | 3100 | 0.0 | - |
226
+ | 2.2293 | 3150 | 0.0 | - |
227
+ | 2.2647 | 3200 | 0.0 | - |
228
+ | 2.3001 | 3250 | 0.0 | - |
229
+ | 2.3355 | 3300 | 0.0 | - |
230
+ | 2.3708 | 3350 | 0.0 | - |
231
+ | 2.4062 | 3400 | 0.0 | - |
232
+ | 2.4416 | 3450 | 0.0 | - |
233
+ | 2.4770 | 3500 | 0.0 | - |
234
+ | 2.5124 | 3550 | 0.0 | - |
235
+ | 2.5478 | 3600 | 0.0 | - |
236
+ | 2.5832 | 3650 | 0.0 | - |
237
+ | 2.6185 | 3700 | 0.0 | - |
238
+ | 2.6539 | 3750 | 0.0 | - |
239
+ | 2.6893 | 3800 | 0.0 | - |
240
+ | 2.7247 | 3850 | 0.0 | - |
241
+ | 2.7601 | 3900 | 0.0 | - |
242
+ | 2.7955 | 3950 | 0.0 | - |
243
+ | 2.8309 | 4000 | 0.0 | - |
244
+ | 2.8662 | 4050 | 0.0001 | - |
245
+ | 2.9016 | 4100 | 0.0 | - |
246
+ | 2.9370 | 4150 | 0.0 | - |
247
+ | 2.9724 | 4200 | 0.0001 | - |
248
+ | 3.0 | 4239 | - | 0.0182 |
249
+
250
+ * The bold row denotes the saved checkpoint.
251
+ ### Framework Versions
252
+ - Python: 3.10.12
253
+ - SetFit: 1.0.3
254
+ - Sentence Transformers: 2.7.0
255
+ - Transformers: 4.40.0
256
+ - PyTorch: 2.2.1+cu121
257
+ - Datasets: 2.19.0
258
+ - Tokenizers: 0.19.1
259
+
260
+ ## Citation
261
+
262
+ ### BibTeX
263
+ ```bibtex
264
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
265
+ doi = {10.48550/ARXIV.2209.11055},
266
+ url = {https://arxiv.org/abs/2209.11055},
267
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
268
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
269
+ title = {Efficient Few-Shot Learning Without Prompts},
270
+ publisher = {arXiv},
271
+ year = {2022},
272
+ copyright = {Creative Commons Attribution 4.0 International}
273
+ }
274
+ ```
275
+
276
+ <!--
277
+ ## Glossary
278
+
279
+ *Clearly define terms in order to be accessible across audiences.*
280
+ -->
281
+
282
+ <!--
283
+ ## Model Card Authors
284
+
285
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
286
+ -->
287
+
288
+ <!--
289
+ ## Model Card Contact
290
+
291
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
292
+ -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "checkpoints/step_1413",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
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-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.40.0",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.7.0",
4
+ "transformers": "4.40.0",
5
+ "pytorch": "2.2.1+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null
9
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "True",
4
+ "False"
5
+ ],
6
+ "normalize_embeddings": false
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:549dfae8798214e768e5ae3a38aee4d73a94218b12ff67d229af6bdbf8af5603
3
+ size 437951328
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b43712c69e55c0ac2426b55586fa4fa54fb19b9f1003a78c859474c4062b428e
3
+ size 7023
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,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "mask_token": "[MASK]",
48
+ "max_length": 512,
49
+ "model_max_length": 512,
50
+ "pad_to_multiple_of": null,
51
+ "pad_token": "[PAD]",
52
+ "pad_token_type_id": 0,
53
+ "padding_side": "right",
54
+ "sep_token": "[SEP]",
55
+ "stride": 0,
56
+ "strip_accents": null,
57
+ "tokenize_chinese_chars": true,
58
+ "tokenizer_class": "BertTokenizer",
59
+ "truncation_side": "right",
60
+ "truncation_strategy": "longest_first",
61
+ "unk_token": "[UNK]"
62
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff