lucienbaumgartner commited on
Commit
142f895
·
verified ·
1 Parent(s): 4df3cc0

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,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: i’ve just been making sure that it is healthier food and not unhealthy food.
9
+ - text: 28 male, history of smoking but quit last year, no major health issues, history
10
+ of pretty bad acne on back as a teen - was on acutane as a teen, 6ft something,
11
+ healthy average weight.
12
+ - text: is this expected of a fairly healthy young person just due to getting covid?
13
+ - text: we never said no matter the cost, we always said as long as mom and baby are
14
+ healthy.
15
+ - text: for how many days in succession, can one healthy individual take a single
16
+ dose of 500mg paracetamol, without causing liver damage?
17
+ metrics:
18
+ - accuracy
19
+ - precision
20
+ - recall
21
+ - f1
22
+ pipeline_tag: text-classification
23
+ library_name: setfit
24
+ inference: true
25
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
26
+ model-index:
27
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
28
+ results:
29
+ - task:
30
+ type: text-classification
31
+ name: Text Classification
32
+ dataset:
33
+ name: Unknown
34
+ type: unknown
35
+ split: test
36
+ metrics:
37
+ - type: accuracy
38
+ value: 0.75
39
+ name: Accuracy
40
+ - type: precision
41
+ value: 0.75
42
+ name: Precision
43
+ - type: recall
44
+ value: 0.75
45
+ name: Recall
46
+ - type: f1
47
+ value: 0.75
48
+ name: F1
49
+ ---
50
+
51
+ # SetFit with sentence-transformers/paraphrase-mpnet-base-v2
52
+
53
+ 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 [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
54
+
55
+ The model has been trained using an efficient few-shot learning technique that involves:
56
+
57
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
58
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
59
+
60
+ ## Model Details
61
+
62
+ ### Model Description
63
+ - **Model Type:** SetFit
64
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
65
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
66
+ - **Maximum Sequence Length:** 512 tokens
67
+ - **Number of Classes:** 2 classes
68
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
69
+ <!-- - **Language:** Unknown -->
70
+ <!-- - **License:** Unknown -->
71
+
72
+ ### Model Sources
73
+
74
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
75
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
76
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
77
+
78
+ ### Model Labels
79
+ | Label | Examples |
80
+ |:------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
81
+ | time | <ul><li>"i mean it hasn't been that long, my heart is perfectly healthy otherwise."</li><li>'otherwise i’m been healthy and all other blood work they did this year was unremarkable. \n'</li><li>'but i can not run 3 seconds without breathing for 10 minutes that should say how unhealthy i am.'</li></ul> |
82
+ | no | <ul><li>'one of the ob doctors i work with likes to emphasize these lists are birth "preferences" as the birth plan is ultimately having a healthy baby and mom.'</li><li>'some who may seem “soft” to you enjoy the challenge and reward of safely delivering tens of thousands of healthy babies in their career and putting them in their mother’s arms. \n\n'</li><li>'so you are right, he is just going to wipe out normal healthy flora , and this includes that wee innocent little lactobacillus the gp wants to put down like old yeller.'</li></ul> |
83
+
84
+ ## Evaluation
85
+
86
+ ### Metrics
87
+ | Label | Accuracy | Precision | Recall | F1 |
88
+ |:--------|:---------|:----------|:-------|:-----|
89
+ | **all** | 0.75 | 0.75 | 0.75 | 0.75 |
90
+
91
+ ## Uses
92
+
93
+ ### Direct Use for Inference
94
+
95
+ First install the SetFit library:
96
+
97
+ ```bash
98
+ pip install setfit
99
+ ```
100
+
101
+ Then you can load this model and run inference.
102
+
103
+ ```python
104
+ from setfit import SetFitModel
105
+
106
+ # Download from the 🤗 Hub
107
+ model = SetFitModel.from_pretrained("setfit_model_id")
108
+ # Run inference
109
+ preds = model("i’ve just been making sure that it is healthier food and not unhealthy food.")
110
+ ```
111
+
112
+ <!--
113
+ ### Downstream Use
114
+
115
+ *List how someone could finetune this model on their own dataset.*
116
+ -->
117
+
118
+ <!--
119
+ ### Out-of-Scope Use
120
+
121
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
122
+ -->
123
+
124
+ <!--
125
+ ## Bias, Risks and Limitations
126
+
127
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
128
+ -->
129
+
130
+ <!--
131
+ ### Recommendations
132
+
133
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
134
+ -->
135
+
136
+ ## Training Details
137
+
138
+ ### Training Set Metrics
139
+ | Training set | Min | Median | Max |
140
+ |:-------------|:----|:-------|:----|
141
+ | Word count | 12 | 25.325 | 60 |
142
+
143
+ | Label | Training Sample Count |
144
+ |:------|:----------------------|
145
+ | no | 36 |
146
+ | time | 44 |
147
+
148
+ ### Training Hyperparameters
149
+ - batch_size: (16, 16)
150
+ - num_epochs: (10, 10)
151
+ - max_steps: -1
152
+ - sampling_strategy: oversampling
153
+ - num_iterations: 20
154
+ - body_learning_rate: (2e-05, 2e-05)
155
+ - head_learning_rate: 2e-05
156
+ - loss: CosineSimilarityLoss
157
+ - distance_metric: cosine_distance
158
+ - margin: 0.25
159
+ - end_to_end: False
160
+ - use_amp: False
161
+ - warmup_proportion: 0.1
162
+ - l2_weight: 0.01
163
+ - seed: 3786
164
+ - eval_max_steps: -1
165
+ - load_best_model_at_end: False
166
+
167
+ ### Training Results
168
+ | Epoch | Step | Training Loss | Validation Loss |
169
+ |:-----:|:----:|:-------------:|:---------------:|
170
+ | 0.005 | 1 | 0.2939 | - |
171
+ | 0.25 | 50 | 0.2641 | - |
172
+ | 0.5 | 100 | 0.195 | - |
173
+ | 0.75 | 150 | 0.0162 | - |
174
+ | 1.0 | 200 | 0.0007 | - |
175
+ | 1.25 | 250 | 0.0003 | - |
176
+ | 1.5 | 300 | 0.0002 | - |
177
+ | 1.75 | 350 | 0.0001 | - |
178
+ | 2.0 | 400 | 0.0001 | - |
179
+ | 2.25 | 450 | 0.0002 | - |
180
+ | 2.5 | 500 | 0.0013 | - |
181
+ | 2.75 | 550 | 0.0002 | - |
182
+ | 3.0 | 600 | 0.0006 | - |
183
+ | 3.25 | 650 | 0.0015 | - |
184
+ | 3.5 | 700 | 0.0008 | - |
185
+ | 3.75 | 750 | 0.0001 | - |
186
+ | 4.0 | 800 | 0.0001 | - |
187
+ | 4.25 | 850 | 0.0007 | - |
188
+ | 4.5 | 900 | 0.0001 | - |
189
+ | 4.75 | 950 | 0.003 | - |
190
+ | 5.0 | 1000 | 0.0001 | - |
191
+ | 5.25 | 1050 | 0.0018 | - |
192
+ | 5.5 | 1100 | 0.0001 | - |
193
+ | 5.75 | 1150 | 0.0001 | - |
194
+ | 6.0 | 1200 | 0.0014 | - |
195
+ | 6.25 | 1250 | 0.0001 | - |
196
+ | 6.5 | 1300 | 0.0009 | - |
197
+ | 6.75 | 1350 | 0.0001 | - |
198
+ | 7.0 | 1400 | 0.0002 | - |
199
+ | 7.25 | 1450 | 0.0 | - |
200
+ | 7.5 | 1500 | 0.0 | - |
201
+ | 7.75 | 1550 | 0.0002 | - |
202
+ | 8.0 | 1600 | 0.0 | - |
203
+ | 8.25 | 1650 | 0.0006 | - |
204
+ | 8.5 | 1700 | 0.0 | - |
205
+ | 8.75 | 1750 | 0.0 | - |
206
+ | 9.0 | 1800 | 0.0 | - |
207
+ | 9.25 | 1850 | 0.0 | - |
208
+ | 9.5 | 1900 | 0.0 | - |
209
+ | 9.75 | 1950 | 0.0 | - |
210
+ | 10.0 | 2000 | 0.0 | - |
211
+
212
+ ### Framework Versions
213
+ - Python: 3.11.7
214
+ - SetFit: 1.1.1
215
+ - Sentence Transformers: 3.3.1
216
+ - Transformers: 4.44.2
217
+ - PyTorch: 2.5.1
218
+ - Datasets: 2.19.0
219
+ - Tokenizers: 0.19.1
220
+
221
+ ## Citation
222
+
223
+ ### BibTeX
224
+ ```bibtex
225
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
226
+ doi = {10.48550/ARXIV.2209.11055},
227
+ url = {https://arxiv.org/abs/2209.11055},
228
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
229
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
230
+ title = {Efficient Few-Shot Learning Without Prompts},
231
+ publisher = {arXiv},
232
+ year = {2022},
233
+ copyright = {Creative Commons Attribution 4.0 International}
234
+ }
235
+ ```
236
+
237
+ <!--
238
+ ## Glossary
239
+
240
+ *Clearly define terms in order to be accessible across audiences.*
241
+ -->
242
+
243
+ <!--
244
+ ## Model Card Authors
245
+
246
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
247
+ -->
248
+
249
+ <!--
250
+ ## Model Card Contact
251
+
252
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
253
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "sentence-transformers/paraphrase-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.44.2",
23
+ "vocab_size": 30527
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.3.1",
4
+ "transformers": "4.44.2",
5
+ "pytorch": "2.5.1"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "no",
4
+ "time"
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:ca3edb312e1c9f62ba4c6af14fe94782de3b732e2adfd08e21ecf70e48d06a5b
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d03d05167b39aec039dca7260cb119ecc024fafa23eab9fcdf2b77d29b680a4
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,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,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "model_max_length": 512,
52
+ "never_split": null,
53
+ "pad_token": "<pad>",
54
+ "sep_token": "</s>",
55
+ "strip_accents": null,
56
+ "tokenize_chinese_chars": true,
57
+ "tokenizer_class": "MPNetTokenizer",
58
+ "unk_token": "[UNK]"
59
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff