bhaskars113 commited on
Commit
7260e4a
1 Parent(s): 1969585

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,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/all-mpnet-base-v2
9
+ datasets:
10
+ - bhaskars113/toyota-paint-attributes
11
+ metrics:
12
+ - accuracy
13
+ widget:
14
+ - text: Hey guys, I'm buying a 2004 Mach 1 Mustang and I'm super excited! It's in
15
+ great condition and has only had one owner. Only thing is the grill mustang ornament
16
+ was stolen years ago he said and he never bothered to replace it. After searching
17
+ online I cannot find anything that's at least a reliable source. I am in Canada
18
+ by the way. If anyone knows how to search one down I would be very appreciative!
19
+ Thanks!
20
+ - text: Mine is actually gold! I think the official paint name is harvest gold. It's
21
+ nice but I'd rather something like the two-tone paints of the 2nd gen. The dull
22
+ metallic gold reminds me of boring grey old corollas lol
23
+ - text: Arrgh. Click to expand... Welcome to owning a Jeep/Dodge product. in 150,000km
24
+ of ownership of our Jeep, we have replaced everything in the suspension 2 times,
25
+ throttle body, 3 sets of plugs, various electrical things, stereo pooped the bed,
26
+ I could go on and on. The most reliable dodge/jeep product I owned was my 2011
27
+ Wrangler Once I removed all the dumb design features jeep put there, like freaking
28
+ plastic in the ball joints. Move to another brand and be MUCH happier. We have
29
+ 179k on our Ford F150 5.0 and all that's been replaced is one set of plugs and
30
+ one ball joint.
31
+ - text: The car is from Utah and garage kept, so the paint is still in very good condition
32
+ - text: I've seen wonders done by a good paintless dent repair professional. The right
33
+ person with the right tools could make this look brand new, or at least better
34
+ than slightly mismatched paint.
35
+ pipeline_tag: text-classification
36
+ inference: false
37
+ ---
38
+
39
+ # SetFit with sentence-transformers/all-mpnet-base-v2
40
+
41
+ This is a [SetFit](https://github.com/huggingface/setfit) model trained on the [bhaskars113/toyota-paint-attributes](https://huggingface.co/datasets/bhaskars113/toyota-paint-attributes) dataset 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 OneVsRestClassifier instance is used for classification.
42
+
43
+ The model has been trained using an efficient few-shot learning technique that involves:
44
+
45
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
46
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
47
+
48
+ ## Model Details
49
+
50
+ ### Model Description
51
+ - **Model Type:** SetFit
52
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
53
+ - **Classification head:** a OneVsRestClassifier instance
54
+ - **Maximum Sequence Length:** 384 tokens
55
+ <!-- - **Number of Classes:** Unknown -->
56
+ - **Training Dataset:** [bhaskars113/toyota-paint-attributes](https://huggingface.co/datasets/bhaskars113/toyota-paint-attributes)
57
+ <!-- - **Language:** Unknown -->
58
+ <!-- - **License:** Unknown -->
59
+
60
+ ### Model Sources
61
+
62
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
63
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
64
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
65
+
66
+ ## Uses
67
+
68
+ ### Direct Use for Inference
69
+
70
+ First install the SetFit library:
71
+
72
+ ```bash
73
+ pip install setfit
74
+ ```
75
+
76
+ Then you can load this model and run inference.
77
+
78
+ ```python
79
+ from setfit import SetFitModel
80
+
81
+ # Download from the 🤗 Hub
82
+ model = SetFitModel.from_pretrained("bhaskars113/toyota-paint-attribute-1.1")
83
+ # Run inference
84
+ preds = model("The car is from Utah and garage kept, so the paint is still in very good condition")
85
+ ```
86
+
87
+ <!--
88
+ ### Downstream Use
89
+
90
+ *List how someone could finetune this model on their own dataset.*
91
+ -->
92
+
93
+ <!--
94
+ ### Out-of-Scope Use
95
+
96
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
97
+ -->
98
+
99
+ <!--
100
+ ## Bias, Risks and Limitations
101
+
102
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
103
+ -->
104
+
105
+ <!--
106
+ ### Recommendations
107
+
108
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
109
+ -->
110
+
111
+ ## Training Details
112
+
113
+ ### Training Set Metrics
114
+ | Training set | Min | Median | Max |
115
+ |:-------------|:----|:--------|:----|
116
+ | Word count | 5 | 33.8098 | 155 |
117
+
118
+ ### Training Hyperparameters
119
+ - batch_size: (16, 16)
120
+ - num_epochs: (1, 1)
121
+ - max_steps: -1
122
+ - sampling_strategy: oversampling
123
+ - num_iterations: 20
124
+ - body_learning_rate: (2e-05, 2e-05)
125
+ - head_learning_rate: 2e-05
126
+ - loss: CosineSimilarityLoss
127
+ - distance_metric: cosine_distance
128
+ - margin: 0.25
129
+ - end_to_end: False
130
+ - use_amp: False
131
+ - warmup_proportion: 0.1
132
+ - seed: 42
133
+ - eval_max_steps: -1
134
+ - load_best_model_at_end: False
135
+
136
+ ### Training Results
137
+ | Epoch | Step | Training Loss | Validation Loss |
138
+ |:------:|:----:|:-------------:|:---------------:|
139
+ | 0.0004 | 1 | 0.1664 | - |
140
+ | 0.0196 | 50 | 0.2377 | - |
141
+ | 0.0392 | 100 | 0.1178 | - |
142
+ | 0.0588 | 150 | 0.0577 | - |
143
+ | 0.0784 | 200 | 0.0163 | - |
144
+ | 0.0980 | 250 | 0.0265 | - |
145
+ | 0.1176 | 300 | 0.0867 | - |
146
+ | 0.1373 | 350 | 0.0181 | - |
147
+ | 0.1569 | 400 | 0.0153 | - |
148
+ | 0.1765 | 450 | 0.0411 | - |
149
+ | 0.1961 | 500 | 0.0308 | - |
150
+ | 0.2157 | 550 | 0.0258 | - |
151
+ | 0.2353 | 600 | 0.0062 | - |
152
+ | 0.2549 | 650 | 0.0036 | - |
153
+ | 0.2745 | 700 | 0.0087 | - |
154
+ | 0.2941 | 750 | 0.0025 | - |
155
+ | 0.3137 | 800 | 0.004 | - |
156
+ | 0.3333 | 850 | 0.0025 | - |
157
+ | 0.3529 | 900 | 0.0044 | - |
158
+ | 0.3725 | 950 | 0.0031 | - |
159
+ | 0.3922 | 1000 | 0.0018 | - |
160
+ | 0.4118 | 1050 | 0.0046 | - |
161
+ | 0.4314 | 1100 | 0.0013 | - |
162
+ | 0.4510 | 1150 | 0.0014 | - |
163
+ | 0.4706 | 1200 | 0.002 | - |
164
+ | 0.4902 | 1250 | 0.0015 | - |
165
+ | 0.5098 | 1300 | 0.0039 | - |
166
+ | 0.5294 | 1350 | 0.0019 | - |
167
+ | 0.5490 | 1400 | 0.0011 | - |
168
+ | 0.5686 | 1450 | 0.0008 | - |
169
+ | 0.5882 | 1500 | 0.0015 | - |
170
+ | 0.6078 | 1550 | 0.0012 | - |
171
+ | 0.6275 | 1600 | 0.0011 | - |
172
+ | 0.6471 | 1650 | 0.0008 | - |
173
+ | 0.6667 | 1700 | 0.0016 | - |
174
+ | 0.6863 | 1750 | 0.0009 | - |
175
+ | 0.7059 | 1800 | 0.0008 | - |
176
+ | 0.7255 | 1850 | 0.0008 | - |
177
+ | 0.7451 | 1900 | 0.0008 | - |
178
+ | 0.7647 | 1950 | 0.0011 | - |
179
+ | 0.7843 | 2000 | 0.0008 | - |
180
+ | 0.8039 | 2050 | 0.001 | - |
181
+ | 0.8235 | 2100 | 0.001 | - |
182
+ | 0.8431 | 2150 | 0.0009 | - |
183
+ | 0.8627 | 2200 | 0.0067 | - |
184
+ | 0.8824 | 2250 | 0.0008 | - |
185
+ | 0.9020 | 2300 | 0.0009 | - |
186
+ | 0.9216 | 2350 | 0.0009 | - |
187
+ | 0.9412 | 2400 | 0.0007 | - |
188
+ | 0.9608 | 2450 | 0.0006 | - |
189
+ | 0.9804 | 2500 | 0.0007 | - |
190
+ | 1.0 | 2550 | 0.0006 | - |
191
+
192
+ ### Framework Versions
193
+ - Python: 3.10.12
194
+ - SetFit: 1.0.3
195
+ - Sentence Transformers: 2.7.0
196
+ - Transformers: 4.40.2
197
+ - PyTorch: 2.2.1+cu121
198
+ - Datasets: 2.19.1
199
+ - Tokenizers: 0.19.1
200
+
201
+ ## Citation
202
+
203
+ ### BibTeX
204
+ ```bibtex
205
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
206
+ doi = {10.48550/ARXIV.2209.11055},
207
+ url = {https://arxiv.org/abs/2209.11055},
208
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
209
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
210
+ title = {Efficient Few-Shot Learning Without Prompts},
211
+ publisher = {arXiv},
212
+ year = {2022},
213
+ copyright = {Creative Commons Attribution 4.0 International}
214
+ }
215
+ ```
216
+
217
+ <!--
218
+ ## Glossary
219
+
220
+ *Clearly define terms in order to be accessible across audiences.*
221
+ -->
222
+
223
+ <!--
224
+ ## Model Card Authors
225
+
226
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
227
+ -->
228
+
229
+ <!--
230
+ ## Model Card Contact
231
+
232
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
233
+ -->
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.40.2",
23
+ "vocab_size": 30527
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.6.1",
5
+ "pytorch": "1.8.1"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null
9
+ }
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:0836116e7ac74c7a52745ed956ff30df409a79c3f9c4172bcf72fb1f1ef95368
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0159592c96d1cf914aa1c9b07d4d3492feb20f3a155cd1d7aaec3622362e48c6
3
+ size 195396
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": true,
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": 512,
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