davidadamczyk commited on
Commit
719ab46
1 Parent(s): 3c7baa4

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,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: sentence-transformers/all-mpnet-base-v2
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: 'Sure! Support it 100 percent. Good opportunity to watch a president follow
14
+ the law and accept consequences rather that whine and complain like a toddler.
15
+
16
+ '
17
+ - text: 'Steve During Prime Minister Ardern''s leadership, the first eighteen months
18
+ of the pandemic resulted in virtually no cases of Covid or Covid deaths and New
19
+ Zealand has suffered less than twenty-five hundred deaths from Covid to date. After
20
+ the deadliest shooting in New Zealand''s history, in her role as the youngest
21
+ leader ever elected in the country, she mourned with a grief-stricken nation and
22
+ responded to the crisis by changing the gun laws in seven days. It makes me want
23
+ to weep thinking of the compassionate and intelligent leadership New Zealand has
24
+ enjoyed under Prime Minister Ardern. It''s a magnificent place and she is a credit
25
+ to her country.
26
+
27
+ '
28
+ - text: 'I am very happy for her. I think she has made absolutely the right decision.
29
+ I have been very critical of some of the policies she endorsed although I understood
30
+ the reasoning behind them. She was a shining beacon in the earlier years but at
31
+ some point she lost her firm grip on principle and became captive to doctrinaire
32
+ theories that did not always serve the country despite the best of intentions.
33
+ Ardern is a very great soul and I don''t doubt that there is an even more brilliant
34
+ future still ahead of her, one that will allow her to lead on the international
35
+ stage without compromising her personal principles. Meantime she deserves time
36
+ to regroup, heal, and spend precious time with her family. Personally I hope Chris
37
+ Hipkins steps into her shoes although he also has a young family and would have
38
+ to make similar sacrifices. He has shown himself to be very able and decent, and
39
+ like Ardern is a master communicator.
40
+
41
+ '
42
+ - text: 'I spoke with an elderly gentlemen with a British accent today in the local
43
+ library here in New Zealand who said he had never voted for Ardern because she
44
+ had been living in an unmarried relationship and to compound this issue had insulted
45
+ the Queen by appearing before her while pregnant. A point that keeps being overlooked
46
+ is that Ardern leaves office not only with record low unemployment but having
47
+ set in train a major social housing program and removed restrictions that prevented
48
+ housing intensification. These in time will hopefully reduce both house prices
49
+ and rents, thus alleviating child poverty. Ardern also dramatically raised the
50
+ insulation standards for new houses. which will mean that they are warmer and
51
+ healthierArdern totally replaced the bureaucratic Resource Management Act which
52
+ had been blamed for nearly 20 years by business and right wing commentators for
53
+ preventing development. Legislation was also passed that will fund the clean-up
54
+ of the country’s woeful drinking, stormwater and sewerage systems. Compared with
55
+ her predecessors John Key and Bill English, Ardern at least tried to deal with
56
+ many of the country''s long standing issues. While still the popular preferred
57
+ prime minister leaving now removes herself as a lightning rod for the haters while
58
+ allowing her successor to drop any upcoming planned legislation that is considered
59
+ to be controversial. At the same time the successor has 9 months to develop their
60
+ relationship with voters.
61
+
62
+ '
63
+ - text: 'Jeff In some states, felons are not allowed to vote after they''ve completed
64
+ their sentences. See Florida. Florida wants felons to pay fines after they''ve
65
+ been released, only in most cases, the government can''t tell the formerly imprisoned
66
+ how much is owed.
67
+
68
+ '
69
+ inference: true
70
+ model-index:
71
+ - name: SetFit with sentence-transformers/all-mpnet-base-v2
72
+ results:
73
+ - task:
74
+ type: text-classification
75
+ name: Text Classification
76
+ dataset:
77
+ name: Unknown
78
+ type: unknown
79
+ split: test
80
+ metrics:
81
+ - type: accuracy
82
+ value: 1.0
83
+ name: Accuracy
84
+ ---
85
+
86
+ # SetFit with sentence-transformers/all-mpnet-base-v2
87
+
88
+ 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.
89
+
90
+ The model has been trained using an efficient few-shot learning technique that involves:
91
+
92
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
93
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
94
+
95
+ ## Model Details
96
+
97
+ ### Model Description
98
+ - **Model Type:** SetFit
99
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
100
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
101
+ - **Maximum Sequence Length:** 384 tokens
102
+ - **Number of Classes:** 2 classes
103
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
104
+ <!-- - **Language:** Unknown -->
105
+ <!-- - **License:** Unknown -->
106
+
107
+ ### Model Sources
108
+
109
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
110
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
111
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
112
+
113
+ ### Model Labels
114
+ | Label | Examples |
115
+ |:------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
116
+ | yes | <ul><li>'Jacinda Ardern is stepping out because her approval rating is below 30%. She has become an ineffective prime minister due in part to rising crime, social inequality, and lingering economic and societal effects of the COVID lockdowns. Workplace burnout is real. But so, apparently, is journalists desire to fit square pegs in round holes. . .\n'</li><li>"Feeling very sad that Jacinda Ardern, a great liberal leader of her country, is stepping down from her five years as New Zealand's Prime Minister. Her courage was inspirational to women (and men) in her country and everywhere. Would that we had American leaders who would know when they should step aside. ! Stepping down from the burden of political leadership in NZ is an example of Ms. Ardern's great character. Jacinda Ardern will always shine through in the memory of her country!\n"</li><li>'Jacinda Ardern is the very definition of public service, and a rare world leader who combined great strength with great empathy. Her decisiveness when protecting her countrymen and women from Covid and in the aftermath of the Christchurch massacre showed what real leadership looks like. And of course she would prioritize the needs of New Zealanders over her premiership if she felt that she had not enough “reserves in the tank” to be as effective as she wished- she’s that sort of politician/public servant. I only hope that with time to recover from her grueling years as prime minister, she will return to the international stage and use her extraordinary presence and talents in a role worthy of her.\n'</li></ul> |
117
+ | no | <ul><li>'Are you not aware of the fact that the people who could have arrested them were overwhelmingly outnumbered with many injuries? Or worse dead. Trump declined to call in the National Guard or other security. Rewatch the video and explain exactly how the insurrectionists could have been arrested on the spot! They are being brought to justice with strong evidence against them.\n'</li><li>"Frau Greta Absolutely!If there are no consequences ( I mean, we drum this point into our kids about responsibilities and consequences) then what would ever keep future Presidents from willfully breaking the law? The message would be that attaining the Presidency is an automatic 'Get Out of Jail Free' card for life.\n"</li><li>'Two candidates trying to outdo each other in their promotion of dismantling of democracy. Two examples of the business model of the modern GOP. One ingratiating themselves with smarmy displays of obeisance the other with industrial strength vitriol. Two loud messages of alarm for the nation.\n'</li></ul> |
118
+
119
+ ## Evaluation
120
+
121
+ ### Metrics
122
+ | Label | Accuracy |
123
+ |:--------|:---------|
124
+ | **all** | 1.0 |
125
+
126
+ ## Uses
127
+
128
+ ### Direct Use for Inference
129
+
130
+ First install the SetFit library:
131
+
132
+ ```bash
133
+ pip install setfit
134
+ ```
135
+
136
+ Then you can load this model and run inference.
137
+
138
+ ```python
139
+ from setfit import SetFitModel
140
+
141
+ # Download from the 🤗 Hub
142
+ model = SetFitModel.from_pretrained("davidadamczyk/setfit-model-5")
143
+ # Run inference
144
+ preds = model("Sure! Support it 100 percent. Good opportunity to watch a president follow the law and accept consequences rather that whine and complain like a toddler.
145
+ ")
146
+ ```
147
+
148
+ <!--
149
+ ### Downstream Use
150
+
151
+ *List how someone could finetune this model on their own dataset.*
152
+ -->
153
+
154
+ <!--
155
+ ### Out-of-Scope Use
156
+
157
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
158
+ -->
159
+
160
+ <!--
161
+ ## Bias, Risks and Limitations
162
+
163
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
164
+ -->
165
+
166
+ <!--
167
+ ### Recommendations
168
+
169
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
170
+ -->
171
+
172
+ ## Training Details
173
+
174
+ ### Training Set Metrics
175
+ | Training set | Min | Median | Max |
176
+ |:-------------|:----|:-------|:----|
177
+ | Word count | 16 | 90.75 | 249 |
178
+
179
+ | Label | Training Sample Count |
180
+ |:------|:----------------------|
181
+ | no | 18 |
182
+ | yes | 22 |
183
+
184
+ ### Training Hyperparameters
185
+ - batch_size: (16, 16)
186
+ - num_epochs: (1, 1)
187
+ - max_steps: -1
188
+ - sampling_strategy: oversampling
189
+ - num_iterations: 120
190
+ - body_learning_rate: (2e-05, 2e-05)
191
+ - head_learning_rate: 2e-05
192
+ - loss: CosineSimilarityLoss
193
+ - distance_metric: cosine_distance
194
+ - margin: 0.25
195
+ - end_to_end: False
196
+ - use_amp: False
197
+ - warmup_proportion: 0.1
198
+ - l2_weight: 0.01
199
+ - seed: 42
200
+ - eval_max_steps: -1
201
+ - load_best_model_at_end: False
202
+
203
+ ### Training Results
204
+ | Epoch | Step | Training Loss | Validation Loss |
205
+ |:------:|:----:|:-------------:|:---------------:|
206
+ | 0.0017 | 1 | 0.3081 | - |
207
+ | 0.0833 | 50 | 0.1044 | - |
208
+ | 0.1667 | 100 | 0.001 | - |
209
+ | 0.25 | 150 | 0.0003 | - |
210
+ | 0.3333 | 200 | 0.0002 | - |
211
+ | 0.4167 | 250 | 0.0002 | - |
212
+ | 0.5 | 300 | 0.0001 | - |
213
+ | 0.5833 | 350 | 0.0001 | - |
214
+ | 0.6667 | 400 | 0.0001 | - |
215
+ | 0.75 | 450 | 0.0001 | - |
216
+ | 0.8333 | 500 | 0.0001 | - |
217
+ | 0.9167 | 550 | 0.0001 | - |
218
+ | 1.0 | 600 | 0.0001 | - |
219
+
220
+ ### Framework Versions
221
+ - Python: 3.10.13
222
+ - SetFit: 1.1.0
223
+ - Sentence Transformers: 3.0.1
224
+ - Transformers: 4.45.2
225
+ - PyTorch: 2.4.0+cu124
226
+ - Datasets: 2.21.0
227
+ - Tokenizers: 0.20.0
228
+
229
+ ## Citation
230
+
231
+ ### BibTeX
232
+ ```bibtex
233
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
234
+ doi = {10.48550/ARXIV.2209.11055},
235
+ url = {https://arxiv.org/abs/2209.11055},
236
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
237
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
238
+ title = {Efficient Few-Shot Learning Without Prompts},
239
+ publisher = {arXiv},
240
+ year = {2022},
241
+ copyright = {Creative Commons Attribution 4.0 International}
242
+ }
243
+ ```
244
+
245
+ <!--
246
+ ## Glossary
247
+
248
+ *Clearly define terms in order to be accessible across audiences.*
249
+ -->
250
+
251
+ <!--
252
+ ## Model Card Authors
253
+
254
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
255
+ -->
256
+
257
+ <!--
258
+ ## Model Card Contact
259
+
260
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
261
+ -->
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.0.1",
4
+ "transformers": "4.45.2",
5
+ "pytorch": "2.4.0+cu124"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "no",
5
+ "yes"
6
+ ]
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b32745811ada456451046c24a3b7640d9fd42b42d1ec6531cae3cfb906edea7
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7330dded9a098ad4a1958030b00146673f03db45975e46db83434ce8a952b205
3
+ size 7023
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