lucienbaumgartner commited on
Commit
7728ee4
·
verified ·
1 Parent(s): 75d010e

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,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: sentence-transformers/all-mpnet-base-v2
3
+ library_name: setfit
4
+ metrics:
5
+ - accuracy
6
+ - precision
7
+ - recall
8
+ - f1
9
+ pipeline_tag: text-classification
10
+ tags:
11
+ - setfit
12
+ - sentence-transformers
13
+ - text-classification
14
+ - generated_from_setfit_trainer
15
+ widget:
16
+ - text: chatgpt , in response to this , will propose an appropriate emoticon response
17
+ for that comment as well generate the specific text of a comment reply for me
18
+ to give .
19
+ - text: 'text - to - speech : once chatgpt has generated a response , you will need
20
+ to convert it into speech using a text - to - speech api , such as google text
21
+ - to - speech or microsoft azure text - to - speech . '
22
+ - text: 'yes , i know that chatgpt said this many many times , but this is a fact
23
+ that people need to eat it up and move on . '
24
+ - text: 'explanation : this makes it easier for chatgpt to understand and generate
25
+ a response for each individual point . '
26
+ - text: 'chatgpt makes choices , algorithms are n''t neutral . '
27
+ inference: true
28
+ model-index:
29
+ - name: SetFit with sentence-transformers/all-mpnet-base-v2
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.75
41
+ name: Accuracy
42
+ - type: precision
43
+ value: 0.7666666666666666
44
+ name: Precision
45
+ - type: recall
46
+ value: 0.746031746031746
47
+ name: Recall
48
+ - type: f1
49
+ value: 0.7488344988344989
50
+ name: F1
51
+ ---
52
+
53
+ # SetFit with sentence-transformers/all-mpnet-base-v2
54
+
55
+ 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 [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
56
+
57
+ The model has been trained using an efficient few-shot learning technique that involves:
58
+
59
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
60
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
61
+
62
+ ## Model Details
63
+
64
+ ### Model Description
65
+ - **Model Type:** SetFit
66
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
67
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
68
+ - **Maximum Sequence Length:** 384 tokens
69
+ - **Number of Classes:** 3 classes
70
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
71
+ <!-- - **Language:** Unknown -->
72
+ <!-- - **License:** Unknown -->
73
+
74
+ ### Model Sources
75
+
76
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
77
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
78
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
79
+
80
+ ### Model Labels
81
+ | Label | Examples |
82
+ |:------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
83
+ | 1 | <ul><li>'i panicked and made chatgpt write everything . '</li><li>'it is fundamental that chatgpt with developer mode can say anything about anyone , at any time for any reason . '</li><li>"chatgpt itself mentioned that homebrewing requires good system mastery and an understanding of the developer 's game philosophy to make properly balanced feats . "</li></ul> |
84
+ | 0 | <ul><li>'chatgpt confirmed it . '</li><li>"chatgpt does n't know that it writing text that is easily detected . "</li><li>"the timing of entering the initial prompt is essential to ensure that chatgpt understands the user 's request and can provide an accurate response . "</li></ul> |
85
+ | 2 | <ul><li>'3 . diversion : chatgpt might also create a diversion , directing a group of wasps to move away from the nest and act as a decoy . '</li><li>'chatgpt can generate content on a wide range of subjects , so the possibilities are endless . '</li><li>'does anyone know if chatgpt can generate the code of a sound wave , with the specifications that are requested , as it does with programming codes . '</li></ul> |
86
+
87
+ ## Evaluation
88
+
89
+ ### Metrics
90
+ | Label | Accuracy | Precision | Recall | F1 |
91
+ |:--------|:---------|:----------|:-------|:-------|
92
+ | **all** | 0.75 | 0.7667 | 0.7460 | 0.7488 |
93
+
94
+ ## Uses
95
+
96
+ ### Direct Use for Inference
97
+
98
+ First install the SetFit library:
99
+
100
+ ```bash
101
+ pip install setfit
102
+ ```
103
+
104
+ Then you can load this model and run inference.
105
+
106
+ ```python
107
+ from setfit import SetFitModel
108
+
109
+ # Download from the 🤗 Hub
110
+ model = SetFitModel.from_pretrained("setfit_model_id")
111
+ # Run inference
112
+ preds = model("chatgpt makes choices , algorithms are n't neutral . ")
113
+ ```
114
+
115
+ <!--
116
+ ### Downstream Use
117
+
118
+ *List how someone could finetune this model on their own dataset.*
119
+ -->
120
+
121
+ <!--
122
+ ### Out-of-Scope Use
123
+
124
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
125
+ -->
126
+
127
+ <!--
128
+ ## Bias, Risks and Limitations
129
+
130
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
131
+ -->
132
+
133
+ <!--
134
+ ### Recommendations
135
+
136
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
137
+ -->
138
+
139
+ ## Training Details
140
+
141
+ ### Training Set Metrics
142
+ | Training set | Min | Median | Max |
143
+ |:-------------|:----|:--------|:----|
144
+ | Word count | 3 | 20.7848 | 51 |
145
+
146
+ | Label | Training Sample Count |
147
+ |:------|:----------------------|
148
+ | 0 | 26 |
149
+ | 1 | 27 |
150
+ | 2 | 26 |
151
+
152
+ ### Training Hyperparameters
153
+ - batch_size: (32, 2)
154
+ - num_epochs: (10, 10)
155
+ - max_steps: -1
156
+ - sampling_strategy: oversampling
157
+ - body_learning_rate: (2e-05, 1e-05)
158
+ - head_learning_rate: 0.01
159
+ - loss: CosineSimilarityLoss
160
+ - distance_metric: cosine_distance
161
+ - margin: 0.25
162
+ - end_to_end: False
163
+ - use_amp: False
164
+ - warmup_proportion: 0.1
165
+ - l2_weight: 0.01
166
+ - seed: 42
167
+ - evaluation_strategy: epoch
168
+ - eval_max_steps: -1
169
+ - load_best_model_at_end: True
170
+
171
+ ### Training Results
172
+ | Epoch | Step | Training Loss | Validation Loss |
173
+ |:------:|:----:|:-------------:|:---------------:|
174
+ | 0.0077 | 1 | 0.2555 | - |
175
+ | 0.3846 | 50 | 0.2528 | - |
176
+ | 0.7692 | 100 | 0.1993 | - |
177
+ | 1.0 | 130 | - | 0.1527 |
178
+ | 1.1538 | 150 | 0.0222 | - |
179
+ | 1.5385 | 200 | 0.0023 | - |
180
+ | 1.9231 | 250 | 0.0013 | - |
181
+ | 2.0 | 260 | - | 0.1461 |
182
+ | 2.3077 | 300 | 0.0015 | - |
183
+ | 2.6923 | 350 | 0.0005 | - |
184
+ | 3.0 | 390 | - | 0.1465 |
185
+ | 3.0769 | 400 | 0.0003 | - |
186
+ | 3.4615 | 450 | 0.0002 | - |
187
+ | 3.8462 | 500 | 0.0003 | - |
188
+ | 4.0 | 520 | - | 0.1353 |
189
+ | 4.2308 | 550 | 0.0007 | - |
190
+ | 4.6154 | 600 | 0.0002 | - |
191
+ | 5.0 | 650 | 0.0011 | 0.1491 |
192
+ | 5.3846 | 700 | 0.0002 | - |
193
+ | 5.7692 | 750 | 0.0002 | - |
194
+ | 6.0 | 780 | - | 0.1478 |
195
+ | 6.1538 | 800 | 0.0002 | - |
196
+ | 6.5385 | 850 | 0.0001 | - |
197
+ | 6.9231 | 900 | 0.0001 | - |
198
+ | 7.0 | 910 | - | 0.1472 |
199
+ | 7.3077 | 950 | 0.0001 | - |
200
+ | 7.6923 | 1000 | 0.0001 | - |
201
+ | 8.0 | 1040 | - | 0.1461 |
202
+ | 8.0769 | 1050 | 0.0001 | - |
203
+ | 8.4615 | 1100 | 0.0001 | - |
204
+ | 8.8462 | 1150 | 0.0001 | - |
205
+ | 9.0 | 1170 | - | 0.1393 |
206
+ | 9.2308 | 1200 | 0.0001 | - |
207
+ | 9.6154 | 1250 | 0.0001 | - |
208
+ | 10.0 | 1300 | 0.0001 | 0.1399 |
209
+
210
+ ### Framework Versions
211
+ - Python: 3.11.7
212
+ - SetFit: 1.1.0
213
+ - Sentence Transformers: 3.2.0
214
+ - Transformers: 4.45.2
215
+ - PyTorch: 2.4.1
216
+ - Datasets: 3.0.1
217
+ - Tokenizers: 0.20.1
218
+
219
+ ## Citation
220
+
221
+ ### BibTeX
222
+ ```bibtex
223
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
224
+ doi = {10.48550/ARXIV.2209.11055},
225
+ url = {https://arxiv.org/abs/2209.11055},
226
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
227
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
228
+ title = {Efficient Few-Shot Learning Without Prompts},
229
+ publisher = {arXiv},
230
+ year = {2022},
231
+ copyright = {Creative Commons Attribution 4.0 International}
232
+ }
233
+ ```
234
+
235
+ <!--
236
+ ## Glossary
237
+
238
+ *Clearly define terms in order to be accessible across audiences.*
239
+ -->
240
+
241
+ <!--
242
+ ## Model Card Authors
243
+
244
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
245
+ -->
246
+
247
+ <!--
248
+ ## Model Card Contact
249
+
250
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
251
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "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.45.2",
23
+ "vocab_size": 30527
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.2.0",
4
+ "transformers": "4.45.2",
5
+ "pytorch": "2.4.1"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
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:fc585c46045783015caf9caf77b031b00b876d13f9a7c3f3915116008cc0e68c
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2da15f86f10ab1d00ec97af011c39598e959d8f1a528708b3853757699c8d7a
3
+ size 19327
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
+ ]
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,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,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "104": {
36
+ "content": "[UNK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "30526": {
44
+ "content": "<mask>",
45
+ "lstrip": true,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ }
51
+ },
52
+ "bos_token": "<s>",
53
+ "clean_up_tokenization_spaces": false,
54
+ "cls_token": "<s>",
55
+ "do_lower_case": true,
56
+ "eos_token": "</s>",
57
+ "mask_token": "<mask>",
58
+ "max_length": 128,
59
+ "model_max_length": 384,
60
+ "pad_to_multiple_of": null,
61
+ "pad_token": "<pad>",
62
+ "pad_token_type_id": 0,
63
+ "padding_side": "right",
64
+ "sep_token": "</s>",
65
+ "stride": 0,
66
+ "strip_accents": null,
67
+ "tokenize_chinese_chars": true,
68
+ "tokenizer_class": "MPNetTokenizer",
69
+ "truncation_side": "right",
70
+ "truncation_strategy": "longest_first",
71
+ "unk_token": "[UNK]"
72
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff