davidadamczyk commited on
Commit
4fd53cc
1 Parent(s): ff98b5e

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,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 'There is, of course, much to digest. I hope that these rubes and those who
14
+ incited them are locked up, along with the fake electors and their advisors, and
15
+ those who conspired to convince elections officials to violate the law, and finally,
16
+ those who have and continue to threaten true Americans just doing their constitution-based
17
+ jobs. One thing jumps out. Judge McFadden, who seems willing to demand that the
18
+ government prove its case beyond a reasonable doubt, also seems to be willing
19
+ to sentence convicted lawbreakers to serious time. That he acquitted the guy who
20
+ claimed the police let him gives me confidence that these are not sham trials.The
21
+ thing that I haven’t heard much about are the firings, trials, convictions, and
22
+ sentences of those LEOs who aided and abetted the traitors. That would include
23
+ the cops who let Mr. Martin enter the Capitol, and those on Trump’s secret service
24
+ detail who may have been aiding Trump’s efforts to foment a riot.
25
+
26
+ '
27
+ - text: 'Both Vladimir Putin and Yevgeny Prigozhin are international war criminals.Both
28
+ also undermined US elections in favor of Trump.<a href="https://www.reuters.com/world/us/russias-prigozhin-admits-interfering-us-elections-2022-11-07"
29
+ target="_blank">https://www.reuters.com/world/us/russias-prigozhin-admits-interfering-us-elections-2022-11-07</a>/
30
+
31
+ '
32
+ - text: 'Aaron 100 percent. citizens united was a huge win for Russian citizen Vlad
33
+ and Chinese citizen Xi.
34
+
35
+ '
36
+ - text: 'George Corsetti “Russia did NOT interfere in the 2016 election.”Sorry George,
37
+ this is not true. Read the Russia report, it details more than a dozen felonies
38
+ committed by TFG and his family and Campaign personnel during the 2015/16 Campaign
39
+ along with evidence of Russian hackers and agents directly interfering in the
40
+ 2016 election.
41
+
42
+ '
43
+ - text: 'Ms.Renkl does a nice job here, yet only hints at the decimation to public
44
+ schools, libraries, governance, and healthcare by Bill Lee and the Red Legislators
45
+ .Tennessee has a $50 B per year budget, $25B 0f this comes from federal government.
46
+ It is a wealthy state ranking in the top 16 economically and 3rd in fiscal stability
47
+ ( USNews).The stability comes from the egregious, wrongheaded use of federal monies
48
+ earmarked for public schools and healthcare,Governor controls all Federal school
49
+ and healthcare dollars rather than decimating to citizens. The US tax payer is
50
+ subsidizing this state as the Governor and legislators deny ACA low cost insurance
51
+ to WORKING poor and the Governor used for unrelated purposes. . Federal public
52
+ school monies are used to subsidize private schools and Lee’s pet project:private
53
+ DeVos/Hillsdale religious charter schools. US tax payers should be made aware
54
+ of the mishandling of our tax dollars in support of the ultra conservative regime.
55
+
56
+ '
57
+ inference: true
58
+ model-index:
59
+ - name: SetFit with sentence-transformers/all-mpnet-base-v2
60
+ results:
61
+ - task:
62
+ type: text-classification
63
+ name: Text Classification
64
+ dataset:
65
+ name: Unknown
66
+ type: unknown
67
+ split: test
68
+ metrics:
69
+ - type: accuracy
70
+ value: 0.8
71
+ name: Accuracy
72
+ ---
73
+
74
+ # SetFit with sentence-transformers/all-mpnet-base-v2
75
+
76
+ 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.
77
+
78
+ The model has been trained using an efficient few-shot learning technique that involves:
79
+
80
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
81
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
82
+
83
+ ## Model Details
84
+
85
+ ### Model Description
86
+ - **Model Type:** SetFit
87
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
88
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
89
+ - **Maximum Sequence Length:** 384 tokens
90
+ - **Number of Classes:** 2 classes
91
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
92
+ <!-- - **Language:** Unknown -->
93
+ <!-- - **License:** Unknown -->
94
+
95
+ ### Model Sources
96
+
97
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
98
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
99
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
100
+
101
+ ### Model Labels
102
+ | Label | Examples |
103
+ |:------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
104
+ | yes | <ul><li>'Ken The FBI and DOJ should open an investigation into Russian interference in the 2022 election.\n'</li><li>"But you still haven't mentioned the crucial upcoming elections in Czechia, which cold alter the balance in Eastern/Central Europe.\n"</li><li>'factsonly She won the 2022 election. She beat at least one Dem primary opponent and beat her Republican opponent by a decent margin in the general election.\n'</li></ul> |
105
+ | no | <ul><li>"Sean Who needs a source when you have Trump's well documented relationship with Putin?\n"</li><li>'After a years-long crime spree by Donald Trump, his children, and his accomplices, we\'re still waiting for indictments. Why? Why is this so hard? The man who said, "Russia, if you\'re listening..." has openly and loudly ignored the law, the constitution, precedent, tradition, common decency and common sense for years, and yet we\'re still waiting for some part of his manifold misdeeds to land him in the docket. Again, why? Why?! There is so much evidence against him, it is impossible to see why he hasn\'t been arrested and charged for sedition, insurrection, money laundering, violating the Espionage Act, the Presidential Records Act, payoffs to hide his adulterous affairs, and other crimes up to and including attempting to mastermind a coup. There is no Witch Hunt. There\'s a just an inexplicably as-yet unindicted multiple felon who continues to grift dollars out of his hoodwinked followers.I am beginning to wonder if the DOJ has forgotten what upholding the law means, or if it is just the person who runs the DOJ.Donald Trump is not the only person to have questions that need to be answered: so does Merrick Garland -- and foremost amongst them is, \'What\'s the hold up?\'\n'</li><li>"Most writers just imitate what they've read. They repeat formulas and replicate familiar sentence structures. Most TV could be written by ChatGPT. So it seems like ChatGPT writes pretty much like 90 percent of writers in a creative writing class. And 90 percent of readers don't want writing that pushes creative limits—look at the success of Colleen Hoover. I'd don't see why something like ChatGPT couldn't write her books. I don't mean that to be insulting—I do doubt an AI book would touch hearts as hers apparently do because it would lack her ineffable humanity. But even if an AI novel became a popular success, it wouldn't mean that AI had bested Nabokov or Woolf or DFW or … well, it's a very large list, and I'm not even claiming these as anything more than the first three whose names came to mind.(And in answer to Elon, sure, if I had to choose, I guess I'd rather live under the rule of Marcus Aurelius than Caligula's. But in fact I wouldn't get a vote on that, and I'd rather not live under an emperor at all.)\n"</li></ul> |
106
+
107
+ ## Evaluation
108
+
109
+ ### Metrics
110
+ | Label | Accuracy |
111
+ |:--------|:---------|
112
+ | **all** | 0.8 |
113
+
114
+ ## Uses
115
+
116
+ ### Direct Use for Inference
117
+
118
+ First install the SetFit library:
119
+
120
+ ```bash
121
+ pip install setfit
122
+ ```
123
+
124
+ Then you can load this model and run inference.
125
+
126
+ ```python
127
+ from setfit import SetFitModel
128
+
129
+ # Download from the 🤗 Hub
130
+ model = SetFitModel.from_pretrained("davidadamczyk/setfit-model-2")
131
+ # Run inference
132
+ preds = model("Aaron 100 percent. citizens united was a huge win for Russian citizen Vlad and Chinese citizen Xi.
133
+ ")
134
+ ```
135
+
136
+ <!--
137
+ ### Downstream Use
138
+
139
+ *List how someone could finetune this model on their own dataset.*
140
+ -->
141
+
142
+ <!--
143
+ ### Out-of-Scope Use
144
+
145
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
146
+ -->
147
+
148
+ <!--
149
+ ## Bias, Risks and Limitations
150
+
151
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
152
+ -->
153
+
154
+ <!--
155
+ ### Recommendations
156
+
157
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
158
+ -->
159
+
160
+ ## Training Details
161
+
162
+ ### Training Set Metrics
163
+ | Training set | Min | Median | Max |
164
+ |:-------------|:----|:-------|:----|
165
+ | Word count | 6 | 80.325 | 276 |
166
+
167
+ | Label | Training Sample Count |
168
+ |:------|:----------------------|
169
+ | no | 18 |
170
+ | yes | 22 |
171
+
172
+ ### Training Hyperparameters
173
+ - batch_size: (16, 16)
174
+ - num_epochs: (1, 1)
175
+ - max_steps: -1
176
+ - sampling_strategy: oversampling
177
+ - num_iterations: 120
178
+ - body_learning_rate: (2e-05, 2e-05)
179
+ - head_learning_rate: 2e-05
180
+ - loss: CosineSimilarityLoss
181
+ - distance_metric: cosine_distance
182
+ - margin: 0.25
183
+ - end_to_end: False
184
+ - use_amp: False
185
+ - warmup_proportion: 0.1
186
+ - l2_weight: 0.01
187
+ - seed: 42
188
+ - eval_max_steps: -1
189
+ - load_best_model_at_end: False
190
+
191
+ ### Training Results
192
+ | Epoch | Step | Training Loss | Validation Loss |
193
+ |:------:|:----:|:-------------:|:---------------:|
194
+ | 0.0017 | 1 | 0.4496 | - |
195
+ | 0.0833 | 50 | 0.1797 | - |
196
+ | 0.1667 | 100 | 0.0034 | - |
197
+ | 0.25 | 150 | 0.0003 | - |
198
+ | 0.3333 | 200 | 0.0002 | - |
199
+ | 0.4167 | 250 | 0.0002 | - |
200
+ | 0.5 | 300 | 0.0001 | - |
201
+ | 0.5833 | 350 | 0.0001 | - |
202
+ | 0.6667 | 400 | 0.0001 | - |
203
+ | 0.75 | 450 | 0.0001 | - |
204
+ | 0.8333 | 500 | 0.0001 | - |
205
+ | 0.9167 | 550 | 0.0001 | - |
206
+ | 1.0 | 600 | 0.0001 | - |
207
+
208
+ ### Framework Versions
209
+ - Python: 3.10.13
210
+ - SetFit: 1.1.0
211
+ - Sentence Transformers: 3.0.1
212
+ - Transformers: 4.45.2
213
+ - PyTorch: 2.4.0+cu124
214
+ - Datasets: 2.21.0
215
+ - Tokenizers: 0.20.0
216
+
217
+ ## Citation
218
+
219
+ ### BibTeX
220
+ ```bibtex
221
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
222
+ doi = {10.48550/ARXIV.2209.11055},
223
+ url = {https://arxiv.org/abs/2209.11055},
224
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
225
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
226
+ title = {Efficient Few-Shot Learning Without Prompts},
227
+ publisher = {arXiv},
228
+ year = {2022},
229
+ copyright = {Creative Commons Attribution 4.0 International}
230
+ }
231
+ ```
232
+
233
+ <!--
234
+ ## Glossary
235
+
236
+ *Clearly define terms in order to be accessible across audiences.*
237
+ -->
238
+
239
+ <!--
240
+ ## Model Card Authors
241
+
242
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
243
+ -->
244
+
245
+ <!--
246
+ ## Model Card Contact
247
+
248
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
249
+ -->
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:de392552d940712a1d5c4068d4e44795f067b60b78704736015c5a02b2edeb92
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbe3b25b490465dd08ca78edccf63dd2b7b5b483b4ee07db886ed8fc64ed5a5f
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