bew commited on
Commit
b59fde7
1 Parent(s): 0f9bbde

Push model using huggingface_hub.

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
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
+ }
README.md ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ metrics:
9
+ - accuracy
10
+ widget:
11
+ - text: What's your favorite way to learn? Through books, videos, or experiments?
12
+ Experiments. I like seeing science in action.
13
+ - text: Can you name a living organism's basic needs? Food, water... Can we change
14
+ the subject?
15
+ - text: What do you find fascinating about the human body? That our brain works like
16
+ a supercomputer.
17
+ - text: What's something you learned about in technology? We learned about coding.
18
+ I made a simple game.
19
+ - text: Do you know how to code? Nope. Sounds complicated.
20
+ pipeline_tag: text-classification
21
+ inference: true
22
+ base_model: BAAI/bge-small-en-v1.5
23
+ ---
24
+
25
+ # SetFit with BAAI/bge-small-en-v1.5
26
+
27
+ 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.
28
+
29
+ The model has been trained using an efficient few-shot learning technique that involves:
30
+
31
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
32
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
33
+
34
+ ## Model Details
35
+
36
+ ### Model Description
37
+ - **Model Type:** SetFit
38
+ - **Sentence Transformer body:** [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5)
39
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
40
+ - **Maximum Sequence Length:** 512 tokens
41
+ - **Number of Classes:** 2 classes
42
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
43
+ <!-- - **Language:** Unknown -->
44
+ <!-- - **License:** Unknown -->
45
+
46
+ ### Model Sources
47
+
48
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
49
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
50
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
51
+
52
+ ### Model Labels
53
+ | Label | Examples |
54
+ |:---------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
55
+ | negative | <ul><li>'What did you learn in school today? Nothing much, just the usual stuff.'</li><li>"Do you know the capital of France? Don't know, don't care."</li><li>"Can you tell me what 2 + 2 equals? Guess it's 4, but why does it matter?"</li></ul> |
56
+ | positive | <ul><li>"What's your favorite subject? Science, because I love experiments."</li><li>'Can you tell me the planets in order? Sure, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune. Pluto used to be one, but not anymore.'</li><li>"Do you enjoy math class? Yeah, it's cool, especially when we do geometry."</li></ul> |
57
+
58
+ ## Uses
59
+
60
+ ### Direct Use for Inference
61
+
62
+ First install the SetFit library:
63
+
64
+ ```bash
65
+ pip install setfit
66
+ ```
67
+
68
+ Then you can load this model and run inference.
69
+
70
+ ```python
71
+ from setfit import SetFitModel
72
+
73
+ # Download from the 🤗 Hub
74
+ model = SetFitModel.from_pretrained("bew/setfit-engagement-model-basic")
75
+ # Run inference
76
+ preds = model("Do you know how to code? Nope. Sounds complicated.")
77
+ ```
78
+
79
+ <!--
80
+ ### Downstream Use
81
+
82
+ *List how someone could finetune this model on their own dataset.*
83
+ -->
84
+
85
+ <!--
86
+ ### Out-of-Scope Use
87
+
88
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
89
+ -->
90
+
91
+ <!--
92
+ ## Bias, Risks and Limitations
93
+
94
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
95
+ -->
96
+
97
+ <!--
98
+ ### Recommendations
99
+
100
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
101
+ -->
102
+
103
+ ## Training Details
104
+
105
+ ### Training Set Metrics
106
+ | Training set | Min | Median | Max |
107
+ |:-------------|:----|:--------|:----|
108
+ | Word count | 6 | 15.0470 | 26 |
109
+
110
+ | Label | Training Sample Count |
111
+ |:---------|:----------------------|
112
+ | negative | 79 |
113
+ | positive | 70 |
114
+
115
+ ### Training Hyperparameters
116
+ - batch_size: (32, 32)
117
+ - num_epochs: (10, 10)
118
+ - max_steps: -1
119
+ - sampling_strategy: oversampling
120
+ - body_learning_rate: (2e-05, 1e-05)
121
+ - head_learning_rate: 0.01
122
+ - loss: CosineSimilarityLoss
123
+ - distance_metric: cosine_distance
124
+ - margin: 0.25
125
+ - end_to_end: False
126
+ - use_amp: False
127
+ - warmup_proportion: 0.1
128
+ - seed: 42
129
+ - eval_max_steps: -1
130
+ - load_best_model_at_end: False
131
+
132
+ ### Training Results
133
+ | Epoch | Step | Training Loss | Validation Loss |
134
+ |:------:|:----:|:-------------:|:---------------:|
135
+ | 0.0028 | 1 | 0.2418 | - |
136
+ | 0.1416 | 50 | 0.2311 | - |
137
+ | 0.2833 | 100 | 0.2425 | - |
138
+ | 0.4249 | 150 | 0.0572 | - |
139
+ | 0.5666 | 200 | 0.0049 | - |
140
+ | 0.7082 | 250 | 0.0031 | - |
141
+ | 0.8499 | 300 | 0.0019 | - |
142
+ | 0.9915 | 350 | 0.0018 | - |
143
+ | 1.1331 | 400 | 0.0015 | - |
144
+ | 1.2748 | 450 | 0.001 | - |
145
+ | 1.4164 | 500 | 0.0011 | - |
146
+ | 1.5581 | 550 | 0.0008 | - |
147
+ | 1.6997 | 600 | 0.0008 | - |
148
+ | 1.8414 | 650 | 0.0007 | - |
149
+ | 1.9830 | 700 | 0.0008 | - |
150
+ | 2.1246 | 750 | 0.0007 | - |
151
+ | 2.2663 | 800 | 0.0005 | - |
152
+ | 2.4079 | 850 | 0.0006 | - |
153
+ | 2.5496 | 900 | 0.0005 | - |
154
+ | 2.6912 | 950 | 0.0005 | - |
155
+ | 2.8329 | 1000 | 0.0005 | - |
156
+ | 2.9745 | 1050 | 0.0005 | - |
157
+ | 3.1161 | 1100 | 0.0005 | - |
158
+ | 3.2578 | 1150 | 0.0005 | - |
159
+ | 3.3994 | 1200 | 0.0004 | - |
160
+ | 3.5411 | 1250 | 0.0004 | - |
161
+ | 3.6827 | 1300 | 0.0004 | - |
162
+ | 3.8244 | 1350 | 0.0004 | - |
163
+ | 3.9660 | 1400 | 0.0004 | - |
164
+ | 4.1076 | 1450 | 0.0004 | - |
165
+ | 4.2493 | 1500 | 0.0003 | - |
166
+ | 4.3909 | 1550 | 0.0004 | - |
167
+ | 4.5326 | 1600 | 0.0004 | - |
168
+ | 4.6742 | 1650 | 0.0003 | - |
169
+ | 4.8159 | 1700 | 0.0003 | - |
170
+ | 4.9575 | 1750 | 0.0004 | - |
171
+ | 5.0992 | 1800 | 0.0003 | - |
172
+ | 5.2408 | 1850 | 0.0003 | - |
173
+ | 5.3824 | 1900 | 0.0003 | - |
174
+ | 5.5241 | 1950 | 0.0003 | - |
175
+ | 5.6657 | 2000 | 0.0003 | - |
176
+ | 5.8074 | 2050 | 0.0003 | - |
177
+ | 5.9490 | 2100 | 0.0003 | - |
178
+ | 6.0907 | 2150 | 0.0003 | - |
179
+ | 6.2323 | 2200 | 0.0003 | - |
180
+ | 6.3739 | 2250 | 0.0003 | - |
181
+ | 6.5156 | 2300 | 0.0003 | - |
182
+ | 6.6572 | 2350 | 0.0003 | - |
183
+ | 6.7989 | 2400 | 0.0002 | - |
184
+ | 6.9405 | 2450 | 0.0003 | - |
185
+ | 7.0822 | 2500 | 0.0003 | - |
186
+ | 7.2238 | 2550 | 0.0003 | - |
187
+ | 7.3654 | 2600 | 0.0003 | - |
188
+ | 7.5071 | 2650 | 0.0003 | - |
189
+ | 7.6487 | 2700 | 0.0003 | - |
190
+ | 7.7904 | 2750 | 0.0003 | - |
191
+ | 7.9320 | 2800 | 0.0003 | - |
192
+ | 8.0737 | 2850 | 0.0003 | - |
193
+ | 8.2153 | 2900 | 0.0003 | - |
194
+ | 8.3569 | 2950 | 0.0003 | - |
195
+ | 8.4986 | 3000 | 0.0002 | - |
196
+ | 8.6402 | 3050 | 0.0003 | - |
197
+ | 8.7819 | 3100 | 0.0003 | - |
198
+ | 8.9235 | 3150 | 0.0003 | - |
199
+ | 9.0652 | 3200 | 0.0003 | - |
200
+ | 9.2068 | 3250 | 0.0002 | - |
201
+ | 9.3484 | 3300 | 0.0003 | - |
202
+ | 9.4901 | 3350 | 0.0002 | - |
203
+ | 9.6317 | 3400 | 0.0003 | - |
204
+ | 9.7734 | 3450 | 0.0003 | - |
205
+ | 9.9150 | 3500 | 0.0002 | - |
206
+
207
+ ### Framework Versions
208
+ - Python: 3.10.12
209
+ - SetFit: 1.0.3
210
+ - Sentence Transformers: 2.3.1
211
+ - Transformers: 4.35.2
212
+ - PyTorch: 2.1.0+cu121
213
+ - Datasets: 2.17.0
214
+ - Tokenizers: 0.15.2
215
+
216
+ ## Citation
217
+
218
+ ### BibTeX
219
+ ```bibtex
220
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
221
+ doi = {10.48550/ARXIV.2209.11055},
222
+ url = {https://arxiv.org/abs/2209.11055},
223
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
224
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
225
+ title = {Efficient Few-Shot Learning Without Prompts},
226
+ publisher = {arXiv},
227
+ year = {2022},
228
+ copyright = {Creative Commons Attribution 4.0 International}
229
+ }
230
+ ```
231
+
232
+ <!--
233
+ ## Glossary
234
+
235
+ *Clearly define terms in order to be accessible across audiences.*
236
+ -->
237
+
238
+ <!--
239
+ ## Model Card Authors
240
+
241
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
242
+ -->
243
+
244
+ <!--
245
+ ## Model Card Contact
246
+
247
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
248
+ -->
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.35.2",
28
+ "type_vocab_size": 2,
29
+ "use_cache": true,
30
+ "vocab_size": 30522
31
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.28.1",
5
+ "pytorch": "1.13.0+cu117"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "negative",
5
+ "positive"
6
+ ]
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:760285771eea7bb36ebbd79ef600ba7ae65974574b5affe0e1106bc0b2cb47e8
3
+ size 133462128
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4ea1a3f6161cda010344951464be04d71c78975b6d1a82d27749d80699fee03
3
+ size 3967
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,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
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