Shankhdhar commited on
Commit
bec5921
1 Parent(s): f7d6e24

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,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: What is the process for exchanging sneakers?
13
+ - text: Do you offer a satisfaction guarantee for sneakers purchased with a store
14
+ promotional code?
15
+ - text: cookie boxes with dividers
16
+ - text: What is the optimal brewing time for green tea to ensure the highest health
17
+ benefits?
18
+ - text: What information might be shared with third parties, and in what situations
19
+ would this occur?
20
+ pipeline_tag: text-classification
21
+ inference: true
22
+ model-index:
23
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
24
+ results:
25
+ - task:
26
+ type: text-classification
27
+ name: Text Classification
28
+ dataset:
29
+ name: Unknown
30
+ type: unknown
31
+ split: test
32
+ metrics:
33
+ - type: accuracy
34
+ value: 0.84
35
+ name: Accuracy
36
+ ---
37
+
38
+ # SetFit with sentence-transformers/paraphrase-mpnet-base-v2
39
+
40
+ 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.
41
+
42
+ The model has been trained using an efficient few-shot learning technique that involves:
43
+
44
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
45
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
46
+
47
+ ## Model Details
48
+
49
+ ### Model Description
50
+ - **Model Type:** SetFit
51
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
52
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
53
+ - **Maximum Sequence Length:** 512 tokens
54
+ - **Number of Classes:** 5 classes
55
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
56
+ <!-- - **Language:** Unknown -->
57
+ <!-- - **License:** Unknown -->
58
+
59
+ ### Model Sources
60
+
61
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
62
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
63
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
64
+
65
+ ### Model Labels
66
+ | Label | Examples |
67
+ |:------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
68
+ | order tracking | <ul><li>'What is the delivery status for my order placed using phone number 123456789?'</li><li>'I ordered the Cake Decorating Kit 4 days ago, can you provide the tracking information?'</li><li>'I ordered the Cake Stands 2 days ago with order no 54321 how long will it take to deliver?'</li></ul> |
69
+ | general faq | <ul><li>'How do the traditional hand-woven Banarasi sarees from HKV Benaras differ from those made by machine-driven industries?'</li><li>'What are the key factors to consider when developing a personalized diet plan for weight loss?'</li><li>"Are there any scientific studies that support Green Tea's role in preventing Alzheimer's and Parkinson's diseases?"</li></ul> |
70
+ | product policy | <ul><li>'How do you use the information collected through tracking tools like Google Analytics and cookies?'</li><li>'How does bakeyy handle returns for items that were purchased with a thank you discount?'</li><li>'What is the procedure for returning a product that was part of a special occasion promotion?'</li></ul> |
71
+ | product discoverability | <ul><li>'What is the price of the organic honey?'</li><li>'Variety of cookie boxes'</li><li>'what apparells do you have from Drew House'</li></ul> |
72
+ | product faq | <ul><li>'What is the price of the bestseller honey?'</li><li>'Do you offer any bulk discounts on organic honey?'</li><li>'Are the big plum cake boxes available in packs of 30?'</li></ul> |
73
+
74
+ ## Evaluation
75
+
76
+ ### Metrics
77
+ | Label | Accuracy |
78
+ |:--------|:---------|
79
+ | **all** | 0.84 |
80
+
81
+ ## Uses
82
+
83
+ ### Direct Use for Inference
84
+
85
+ First install the SetFit library:
86
+
87
+ ```bash
88
+ pip install setfit
89
+ ```
90
+
91
+ Then you can load this model and run inference.
92
+
93
+ ```python
94
+ from setfit import SetFitModel
95
+
96
+ # Download from the 🤗 Hub
97
+ model = SetFitModel.from_pretrained("Shankhdhar/classifier_woog_firstbud_updated")
98
+ # Run inference
99
+ preds = model("cookie boxes with dividers")
100
+ ```
101
+
102
+ <!--
103
+ ### Downstream Use
104
+
105
+ *List how someone could finetune this model on their own dataset.*
106
+ -->
107
+
108
+ <!--
109
+ ### Out-of-Scope Use
110
+
111
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
112
+ -->
113
+
114
+ <!--
115
+ ## Bias, Risks and Limitations
116
+
117
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
118
+ -->
119
+
120
+ <!--
121
+ ### Recommendations
122
+
123
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
124
+ -->
125
+
126
+ ## Training Details
127
+
128
+ ### Training Set Metrics
129
+ | Training set | Min | Median | Max |
130
+ |:-------------|:----|:--------|:----|
131
+ | Word count | 4 | 11.9760 | 28 |
132
+
133
+ | Label | Training Sample Count |
134
+ |:------------------------|:----------------------|
135
+ | general faq | 24 |
136
+ | order tracking | 34 |
137
+ | product discoverability | 50 |
138
+ | product faq | 50 |
139
+ | product policy | 50 |
140
+
141
+ ### Training Hyperparameters
142
+ - batch_size: (16, 16)
143
+ - num_epochs: (2, 2)
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.0005 | 1 | 0.2048 | - |
162
+ | 0.0235 | 50 | 0.2874 | - |
163
+ | 0.0470 | 100 | 0.126 | - |
164
+ | 0.0705 | 150 | 0.0388 | - |
165
+ | 0.0940 | 200 | 0.0786 | - |
166
+ | 0.1175 | 250 | 0.0049 | - |
167
+ | 0.1410 | 300 | 0.0048 | - |
168
+ | 0.1646 | 350 | 0.0018 | - |
169
+ | 0.1881 | 400 | 0.0011 | - |
170
+ | 0.2116 | 450 | 0.0004 | - |
171
+ | 0.2351 | 500 | 0.0006 | - |
172
+ | 0.2586 | 550 | 0.0005 | - |
173
+ | 0.2821 | 600 | 0.0012 | - |
174
+ | 0.3056 | 650 | 0.0004 | - |
175
+ | 0.3291 | 700 | 0.0003 | - |
176
+ | 0.3526 | 750 | 0.0002 | - |
177
+ | 0.3761 | 800 | 0.0002 | - |
178
+ | 0.3996 | 850 | 0.0002 | - |
179
+ | 0.4231 | 900 | 0.0002 | - |
180
+ | 0.4466 | 950 | 0.0008 | - |
181
+ | 0.4701 | 1000 | 0.0002 | - |
182
+ | 0.4937 | 1050 | 0.0003 | - |
183
+ | 0.5172 | 1100 | 0.0001 | - |
184
+ | 0.5407 | 1150 | 0.0002 | - |
185
+ | 0.5642 | 1200 | 0.0001 | - |
186
+ | 0.5877 | 1250 | 0.0001 | - |
187
+ | 0.6112 | 1300 | 0.0001 | - |
188
+ | 0.6347 | 1350 | 0.0004 | - |
189
+ | 0.6582 | 1400 | 0.0002 | - |
190
+ | 0.6817 | 1450 | 0.0001 | - |
191
+ | 0.7052 | 1500 | 0.0002 | - |
192
+ | 0.7287 | 1550 | 0.0001 | - |
193
+ | 0.7522 | 1600 | 0.0001 | - |
194
+ | 0.7757 | 1650 | 0.0001 | - |
195
+ | 0.7992 | 1700 | 0.0001 | - |
196
+ | 0.8228 | 1750 | 0.0001 | - |
197
+ | 0.8463 | 1800 | 0.0001 | - |
198
+ | 0.8698 | 1850 | 0.0001 | - |
199
+ | 0.8933 | 1900 | 0.0001 | - |
200
+ | 0.9168 | 1950 | 0.0001 | - |
201
+ | 0.9403 | 2000 | 0.0001 | - |
202
+ | 0.9638 | 2050 | 0.0001 | - |
203
+ | 0.9873 | 2100 | 0.0002 | - |
204
+ | 1.0108 | 2150 | 0.0001 | - |
205
+ | 1.0343 | 2200 | 0.0001 | - |
206
+ | 1.0578 | 2250 | 0.0001 | - |
207
+ | 1.0813 | 2300 | 0.0001 | - |
208
+ | 1.1048 | 2350 | 0.0001 | - |
209
+ | 1.1283 | 2400 | 0.0 | - |
210
+ | 1.1519 | 2450 | 0.0001 | - |
211
+ | 1.1754 | 2500 | 0.0 | - |
212
+ | 1.1989 | 2550 | 0.0001 | - |
213
+ | 1.2224 | 2600 | 0.0007 | - |
214
+ | 1.2459 | 2650 | 0.0001 | - |
215
+ | 1.2694 | 2700 | 0.0001 | - |
216
+ | 1.2929 | 2750 | 0.0001 | - |
217
+ | 1.3164 | 2800 | 0.0001 | - |
218
+ | 1.3399 | 2850 | 0.0001 | - |
219
+ | 1.3634 | 2900 | 0.0001 | - |
220
+ | 1.3869 | 2950 | 0.0001 | - |
221
+ | 1.4104 | 3000 | 0.0001 | - |
222
+ | 1.4339 | 3050 | 0.0001 | - |
223
+ | 1.4575 | 3100 | 0.0001 | - |
224
+ | 1.4810 | 3150 | 0.0001 | - |
225
+ | 1.5045 | 3200 | 0.0001 | - |
226
+ | 1.5280 | 3250 | 0.0001 | - |
227
+ | 1.5515 | 3300 | 0.0001 | - |
228
+ | 1.5750 | 3350 | 0.0001 | - |
229
+ | 1.5985 | 3400 | 0.0001 | - |
230
+ | 1.6220 | 3450 | 0.0001 | - |
231
+ | 1.6455 | 3500 | 0.0001 | - |
232
+ | 1.6690 | 3550 | 0.0001 | - |
233
+ | 1.6925 | 3600 | 0.0001 | - |
234
+ | 1.7160 | 3650 | 0.0 | - |
235
+ | 1.7395 | 3700 | 0.0001 | - |
236
+ | 1.7630 | 3750 | 0.0001 | - |
237
+ | 1.7866 | 3800 | 0.0 | - |
238
+ | 1.8101 | 3850 | 0.0001 | - |
239
+ | 1.8336 | 3900 | 0.0001 | - |
240
+ | 1.8571 | 3950 | 0.0 | - |
241
+ | 1.8806 | 4000 | 0.0001 | - |
242
+ | 1.9041 | 4050 | 0.0001 | - |
243
+ | 1.9276 | 4100 | 0.0001 | - |
244
+ | 1.9511 | 4150 | 0.0001 | - |
245
+ | 1.9746 | 4200 | 0.0001 | - |
246
+ | 1.9981 | 4250 | 0.0001 | - |
247
+
248
+ ### Framework Versions
249
+ - Python: 3.10.13
250
+ - SetFit: 1.0.3
251
+ - Sentence Transformers: 3.0.1
252
+ - Transformers: 4.39.0
253
+ - PyTorch: 2.2.2+cu121
254
+ - Datasets: 2.19.2
255
+ - Tokenizers: 0.15.2
256
+
257
+ ## Citation
258
+
259
+ ### BibTeX
260
+ ```bibtex
261
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
262
+ doi = {10.48550/ARXIV.2209.11055},
263
+ url = {https://arxiv.org/abs/2209.11055},
264
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
265
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
266
+ title = {Efficient Few-Shot Learning Without Prompts},
267
+ publisher = {arXiv},
268
+ year = {2022},
269
+ copyright = {Creative Commons Attribution 4.0 International}
270
+ }
271
+ ```
272
+
273
+ <!--
274
+ ## Glossary
275
+
276
+ *Clearly define terms in order to be accessible across audiences.*
277
+ -->
278
+
279
+ <!--
280
+ ## Model Card Authors
281
+
282
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
283
+ -->
284
+
285
+ <!--
286
+ ## Model Card Contact
287
+
288
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
289
+ -->
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.39.0",
23
+ "vocab_size": 30527
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.0.1",
4
+ "transformers": "4.39.0",
5
+ "pytorch": "2.2.2+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "general faq",
4
+ "order tracking",
5
+ "product discoverability",
6
+ "product faq",
7
+ "product policy"
8
+ ],
9
+ "normalize_embeddings": false
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50552d21a43d0743dd9d5ab1d183d388abcde0db194cd4197a46364564e1bbf2
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c2fe59bcc26153e89c686fff5ddd7718fc59c49bea6c4854420d5924068ba41
3
+ size 32063
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