selina09 commited on
Commit
8789c95
1 Parent(s): 1e84b48

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
3
+ "pooling_mode_cls_token": true,
4
+ "pooling_mode_mean_tokens": false,
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,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: BAAI/bge-small-en-v1.5
3
+ library_name: setfit
4
+ metrics:
5
+ - accuracy
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - setfit
9
+ - sentence-transformers
10
+ - text-classification
11
+ - generated_from_setfit_trainer
12
+ widget:
13
+ - text: 'I have owned this NAS for almost a year now and actually purchased a second
14
+ one It works flawlessly and QNAP live tech support is superb There is also a fairly
15
+ comprehensive forum for users as well I have slowly upgraded my capacities as
16
+ newer larger capacity drives have come out on the market All have been recognized
17
+ and the space expanded without a hitch I highly recommend this product '
18
+ - text: Good as expected
19
+ - text: 'This is a very good video editing package In the past I ve only used Corel
20
+ video editing products but Cyberlink s offering is on par It offers similar options
21
+ but they are different enough for me to want to use both products depending on
22
+ what I m trying to achieve There are quick uploading options that make it very
23
+ easy to get video onto Youtube and other online video sites '
24
+ - text: Works great
25
+ - text: 'This is my favorite crack open the computer and amuse myself for a few hours
26
+ software Easy to pick up if you have no prior experience with computer animation
27
+ but advanced enough that someone with the right skills could pull together an
28
+ impressive movie '
29
+ inference: true
30
+ ---
31
+
32
+ # SetFit with BAAI/bge-small-en-v1.5
33
+
34
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5) 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.
35
+
36
+ The model has been trained using an efficient few-shot learning technique that involves:
37
+
38
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
39
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
40
+
41
+ ## Model Details
42
+
43
+ ### Model Description
44
+ - **Model Type:** SetFit
45
+ - **Sentence Transformer body:** [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5)
46
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
47
+ - **Maximum Sequence Length:** 512 tokens
48
+ - **Number of Classes:** 2 classes
49
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
50
+ <!-- - **Language:** Unknown -->
51
+ <!-- - **License:** Unknown -->
52
+
53
+ ### Model Sources
54
+
55
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
56
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
57
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
58
+
59
+ ### Model Labels
60
+ | Label | Examples |
61
+ |:------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
62
+ | 0 | <ul><li>'Have used Turbo Tax for years Never a problem I m pretty concerned now with the news that many of their users had their returns hacked by people who gained access to Turbo Tax and stole the information Not sure I will use it next year until I research how serious this is was '</li><li>'Can t beat an Apple computer Like P KB best by test '</li><li>'Works for Mac or Pc but not on widows '</li></ul> |
63
+ | 1 | <ul><li>'Would not install activation code not accepted Returned it '</li><li>'Worth all four of the software programs which are included in this product '</li><li>'The marketing information makes this software look like it should be fabulous lots of useful features that I would love to experiment with However the software just doesn t work I will keep using my very old JASC version of this software instead '</li></ul> |
64
+
65
+ ## Uses
66
+
67
+ ### Direct Use for Inference
68
+
69
+ First install the SetFit library:
70
+
71
+ ```bash
72
+ pip install setfit
73
+ ```
74
+
75
+ Then you can load this model and run inference.
76
+
77
+ ```python
78
+ from setfit import SetFitModel
79
+
80
+ # Download from the 🤗 Hub
81
+ model = SetFitModel.from_pretrained("selina09/yt_setfit")
82
+ # Run inference
83
+ preds = model("Works great")
84
+ ```
85
+
86
+ <!--
87
+ ### Downstream Use
88
+
89
+ *List how someone could finetune this model on their own dataset.*
90
+ -->
91
+
92
+ <!--
93
+ ### Out-of-Scope Use
94
+
95
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
96
+ -->
97
+
98
+ <!--
99
+ ## Bias, Risks and Limitations
100
+
101
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
102
+ -->
103
+
104
+ <!--
105
+ ### Recommendations
106
+
107
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
108
+ -->
109
+
110
+ ## Training Details
111
+
112
+ ### Training Set Metrics
113
+ | Training set | Min | Median | Max |
114
+ |:-------------|:----|:--------|:----|
115
+ | Word count | 1 | 34.9207 | 102 |
116
+
117
+ | Label | Training Sample Count |
118
+ |:------|:----------------------|
119
+ | 0 | 123 |
120
+ | 1 | 41 |
121
+
122
+ ### Training Hyperparameters
123
+ - batch_size: (32, 32)
124
+ - num_epochs: (10, 10)
125
+ - max_steps: -1
126
+ - sampling_strategy: oversampling
127
+ - body_learning_rate: (2e-05, 1e-05)
128
+ - head_learning_rate: 0.01
129
+ - loss: CosineSimilarityLoss
130
+ - distance_metric: cosine_distance
131
+ - margin: 0.25
132
+ - end_to_end: False
133
+ - use_amp: False
134
+ - warmup_proportion: 0.1
135
+ - seed: 42
136
+ - eval_max_steps: -1
137
+ - load_best_model_at_end: False
138
+
139
+ ### Training Results
140
+ | Epoch | Step | Training Loss | Validation Loss |
141
+ |:------:|:----:|:-------------:|:---------------:|
142
+ | 0.0019 | 1 | 0.2503 | - |
143
+ | 0.0942 | 50 | 0.2406 | - |
144
+ | 0.1883 | 100 | 0.2029 | - |
145
+ | 0.2825 | 150 | 0.2207 | - |
146
+ | 0.3766 | 200 | 0.1612 | - |
147
+ | 0.4708 | 250 | 0.0725 | - |
148
+ | 0.5650 | 300 | 0.0163 | - |
149
+ | 0.6591 | 350 | 0.0108 | - |
150
+ | 0.7533 | 400 | 0.0153 | - |
151
+ | 0.8475 | 450 | 0.0486 | - |
152
+ | 0.9416 | 500 | 0.0191 | - |
153
+ | 1.0358 | 550 | 0.0207 | - |
154
+ | 1.1299 | 600 | 0.0148 | - |
155
+ | 1.2241 | 650 | 0.0031 | - |
156
+ | 1.3183 | 700 | 0.001 | - |
157
+ | 1.4124 | 750 | 0.0287 | - |
158
+ | 1.5066 | 800 | 0.0146 | - |
159
+ | 1.6008 | 850 | 0.0147 | - |
160
+ | 1.6949 | 900 | 0.0165 | - |
161
+ | 1.7891 | 950 | 0.0008 | - |
162
+ | 1.8832 | 1000 | 0.0165 | - |
163
+ | 1.9774 | 1050 | 0.0007 | - |
164
+ | 2.0716 | 1100 | 0.0129 | - |
165
+ | 2.1657 | 1150 | 0.0143 | - |
166
+ | 2.2599 | 1200 | 0.0006 | - |
167
+ | 2.3540 | 1250 | 0.0008 | - |
168
+ | 2.4482 | 1300 | 0.0047 | - |
169
+ | 2.5424 | 1350 | 0.0005 | - |
170
+ | 2.6365 | 1400 | 0.0116 | - |
171
+ | 2.7307 | 1450 | 0.0093 | - |
172
+ | 2.8249 | 1500 | 0.0211 | - |
173
+ | 2.9190 | 1550 | 0.0076 | - |
174
+ | 3.0132 | 1600 | 0.0047 | - |
175
+ | 3.1073 | 1650 | 0.0005 | - |
176
+ | 3.2015 | 1700 | 0.0064 | - |
177
+ | 3.2957 | 1750 | 0.014 | - |
178
+ | 3.3898 | 1800 | 0.0479 | - |
179
+ | 3.4840 | 1850 | 0.0005 | - |
180
+ | 3.5782 | 1900 | 0.0045 | - |
181
+ | 3.6723 | 1950 | 0.0188 | - |
182
+ | 3.7665 | 2000 | 0.0004 | - |
183
+ | 3.8606 | 2050 | 0.0122 | - |
184
+ | 3.9548 | 2100 | 0.0004 | - |
185
+ | 4.0490 | 2150 | 0.008 | - |
186
+ | 4.1431 | 2200 | 0.0245 | - |
187
+ | 4.2373 | 2250 | 0.005 | - |
188
+ | 4.3315 | 2300 | 0.0244 | - |
189
+ | 4.4256 | 2350 | 0.0208 | - |
190
+ | 4.5198 | 2400 | 0.0237 | - |
191
+ | 4.6139 | 2450 | 0.0005 | - |
192
+ | 4.7081 | 2500 | 0.0004 | - |
193
+ | 4.8023 | 2550 | 0.02 | - |
194
+ | 4.8964 | 2600 | 0.0004 | - |
195
+ | 4.9906 | 2650 | 0.0067 | - |
196
+ | 5.0847 | 2700 | 0.0099 | - |
197
+ | 5.1789 | 2750 | 0.0138 | - |
198
+ | 5.2731 | 2800 | 0.0192 | - |
199
+ | 5.3672 | 2850 | 0.0217 | - |
200
+ | 5.4614 | 2900 | 0.0056 | - |
201
+ | 5.5556 | 2950 | 0.0003 | - |
202
+ | 5.6497 | 3000 | 0.0052 | - |
203
+ | 5.7439 | 3050 | 0.0123 | - |
204
+ | 5.8380 | 3100 | 0.0136 | - |
205
+ | 5.9322 | 3150 | 0.0221 | - |
206
+ | 6.0264 | 3200 | 0.0235 | - |
207
+ | 6.1205 | 3250 | 0.0144 | - |
208
+ | 6.2147 | 3300 | 0.0174 | - |
209
+ | 6.3089 | 3350 | 0.007 | - |
210
+ | 6.4030 | 3400 | 0.0044 | - |
211
+ | 6.4972 | 3450 | 0.0003 | - |
212
+ | 6.5913 | 3500 | 0.007 | - |
213
+ | 6.6855 | 3550 | 0.0004 | - |
214
+ | 6.7797 | 3600 | 0.0384 | - |
215
+ | 6.8738 | 3650 | 0.0055 | - |
216
+ | 6.9680 | 3700 | 0.0056 | - |
217
+ | 7.0621 | 3750 | 0.0118 | - |
218
+ | 7.1563 | 3800 | 0.0143 | - |
219
+ | 7.2505 | 3850 | 0.0289 | - |
220
+ | 7.3446 | 3900 | 0.0301 | - |
221
+ | 7.4388 | 3950 | 0.0119 | - |
222
+ | 7.5330 | 4000 | 0.012 | - |
223
+ | 7.6271 | 4050 | 0.0138 | - |
224
+ | 7.7213 | 4100 | 0.0148 | - |
225
+ | 7.8154 | 4150 | 0.0003 | - |
226
+ | 7.9096 | 4200 | 0.0268 | - |
227
+ | 8.0038 | 4250 | 0.0131 | - |
228
+ | 8.0979 | 4300 | 0.0237 | - |
229
+ | 8.1921 | 4350 | 0.0004 | - |
230
+ | 8.2863 | 4400 | 0.0211 | - |
231
+ | 8.3804 | 4450 | 0.0092 | - |
232
+ | 8.4746 | 4500 | 0.005 | - |
233
+ | 8.5687 | 4550 | 0.0056 | - |
234
+ | 8.6629 | 4600 | 0.0168 | - |
235
+ | 8.7571 | 4650 | 0.0045 | - |
236
+ | 8.8512 | 4700 | 0.0184 | - |
237
+ | 8.9454 | 4750 | 0.0049 | - |
238
+ | 9.0395 | 4800 | 0.0047 | - |
239
+ | 9.1337 | 4850 | 0.0099 | - |
240
+ | 9.2279 | 4900 | 0.0054 | - |
241
+ | 9.3220 | 4950 | 0.0185 | - |
242
+ | 9.4162 | 5000 | 0.005 | - |
243
+ | 9.5104 | 5050 | 0.0004 | - |
244
+ | 9.6045 | 5100 | 0.013 | - |
245
+ | 9.6987 | 5150 | 0.0002 | - |
246
+ | 9.7928 | 5200 | 0.0187 | - |
247
+ | 9.8870 | 5250 | 0.0003 | - |
248
+ | 9.9812 | 5300 | 0.0081 | - |
249
+
250
+ ### Framework Versions
251
+ - Python: 3.10.12
252
+ - SetFit: 1.0.3
253
+ - Sentence Transformers: 3.0.1
254
+ - Transformers: 4.40.2
255
+ - PyTorch: 2.4.0+cu121
256
+ - Datasets: 2.21.0
257
+ - Tokenizers: 0.19.1
258
+
259
+ ## Citation
260
+
261
+ ### BibTeX
262
+ ```bibtex
263
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
264
+ doi = {10.48550/ARXIV.2209.11055},
265
+ url = {https://arxiv.org/abs/2209.11055},
266
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
267
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
268
+ title = {Efficient Few-Shot Learning Without Prompts},
269
+ publisher = {arXiv},
270
+ year = {2022},
271
+ copyright = {Creative Commons Attribution 4.0 International}
272
+ }
273
+ ```
274
+
275
+ <!--
276
+ ## Glossary
277
+
278
+ *Clearly define terms in order to be accessible across audiences.*
279
+ -->
280
+
281
+ <!--
282
+ ## Model Card Authors
283
+
284
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
285
+ -->
286
+
287
+ <!--
288
+ ## Model Card Contact
289
+
290
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
291
+ -->
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "BAAI/bge-small-en-v1.5",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 384,
11
+ "id2label": {
12
+ "0": "LABEL_0"
13
+ },
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 1536,
16
+ "label2id": {
17
+ "LABEL_0": 0
18
+ },
19
+ "layer_norm_eps": 1e-12,
20
+ "max_position_embeddings": 512,
21
+ "model_type": "bert",
22
+ "num_attention_heads": 12,
23
+ "num_hidden_layers": 12,
24
+ "pad_token_id": 0,
25
+ "position_embedding_type": "absolute",
26
+ "torch_dtype": "float32",
27
+ "transformers_version": "4.40.2",
28
+ "type_vocab_size": 2,
29
+ "use_cache": true,
30
+ "vocab_size": 30522
31
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.0.1",
4
+ "transformers": "4.40.2",
5
+ "pytorch": "2.4.0+cu121"
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:b49a023a593684036510e052dfc9090ef97a54ed91171990054ac35ecee17e0b
3
+ size 133462128
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:613128c6dc5503ba761c362160ad96b673bd5694606d38a7fcff84e48fe1423e
3
+ size 3935
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": 512,
3
+ "do_lower_case": true
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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "BertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff