bhaskars113 commited on
Commit
af6a573
1 Parent(s): 5057de8

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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
+ }
README.md ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: There’s been an early morning skate that’s been going on for years. They have
12
+ a Facebook page. I think its “6:30 am morning drop-in skate at lakeview” might
13
+ be on a break right now, but would be a good way to find some other drop in skates
14
+ or a way into some of the beer leagues. Mountain biking is a great year around
15
+ activity, and a good way to meet people. Stop into any of the shops and ask about
16
+ group rides.
17
+ - text: So despite the minor audience, i think they can be quite damaging. Especially
18
+ after the burning of the tents. It's only the beginning (not that I am expecting
19
+ some form of January 6 style thing), they have been brewing for a while and have
20
+ now found an outlet.
21
+ - text: My worry is that pretty much my entire social life is spent at a bar of some
22
+ sort, especially in the winter. So this month might suck. But I'm going to go
23
+ to my golf course's bar after work today with my 6pk of Craft non-alcoholic beer
24
+ so we'll see how that goes! Best of luck to you as well!
25
+ - text: '@GayChemist @TylerDinucci It''s Wisconsin. I assume that "drinking fountains"
26
+ mean beer there.'
27
+ - text: It's great! Spent some time at the brewery and got it there. Craft beer and
28
+ hot sauces are probably my two biggest vices lol.
29
+ pipeline_tag: text-classification
30
+ inference: true
31
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
32
+ model-index:
33
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
34
+ results:
35
+ - task:
36
+ type: text-classification
37
+ name: Text Classification
38
+ dataset:
39
+ name: Unknown
40
+ type: unknown
41
+ split: test
42
+ metrics:
43
+ - type: accuracy
44
+ value: 0.0
45
+ name: Accuracy
46
+ ---
47
+
48
+ # SetFit with sentence-transformers/paraphrase-mpnet-base-v2
49
+
50
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-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.
51
+
52
+ The model has been trained using an efficient few-shot learning technique that involves:
53
+
54
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
55
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
56
+
57
+ ## Model Details
58
+
59
+ ### Model Description
60
+ - **Model Type:** SetFit
61
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
62
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
63
+ - **Maximum Sequence Length:** 512 tokens
64
+ - **Number of Classes:** 6 classes
65
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
66
+ <!-- - **Language:** Unknown -->
67
+ <!-- - **License:** Unknown -->
68
+
69
+ ### Model Sources
70
+
71
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
72
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
73
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
74
+
75
+ ### Model Labels
76
+ | Label | Examples |
77
+ |:------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
78
+ | 3 | <ul><li>"I can relate to a lot of what you've described here. I call myself a beer snob because I enjoy trying new craft beers but won't usually go for any thing else, and I know what I like when it comes to beer. I'm currently on a hiatus because while I was doing well at having less for a couple of weeks, last weekend I went for 8/day two weekend days in a row. My doctor told me recently that 3 is a healthy limit, and I more than doubled that on those days so ... When it becomes a problem for you; When you're too sick the next day to do anything, etc, that's what eventually made me decide I want to shift my focus from drinking beer to everything else in life. It was fun while it lasted, may not be over for me entirely I just don't like where I was headed. Hope this helps."</li><li>'I’ve been trying out NA beer. They’re significantly lower calories and, well, non-alcoholic. It scratches the itch for me.'</li><li>"Yeah, I weigh myself daily and definitely notice how much even a couple hundred extra calories can stall my weight loss. It's been helpful in motivating myself: while a couple of beers after work doesn't seem like much, it's not worth it when I hop on the scale the next few days. Being strict also helped me choose healthier options. If I know a slice of cake has the same calories as a high-protein wrap but is more likely to make me feel tired and hungry later, it naturally becomes a lot less appealing."</li></ul> |
79
+ | 1 | <ul><li>"These things happen sometimes, and that's what rescue meds are for. Today is the day I try to get out of the house and meet up with friends at a bar. Part of why I'm not drinking right now is because I'd skip going out and just drink beers at home. I want to socialize more. I'm a bit hesitant to go today though."</li><li>"Beer and boardgames in Heidelberg. It's an Event you can find on Meetup. Just 20 to 40 mostly international people meeting to play boardgames. No drinking beer needed, I drink apple juice. There is also a boardgame group meeting at the kolosseum in Heidelberg Thursdays at 17 uhr Hope you like those options"</li><li>'I go to a lot of motorcycle meetups, they are often at bars or breweries. My usual m.o. is to have one regular beer, and then switch over to Athletic Brews, a Non alcoholic beer. I like the taste, and it’s nice to be able to chill and drink with the other guys. I just really don’t want to risk riding home after having more than one alcoholic beer.'</li></ul> |
80
+ | 4 | <ul><li>'Like the title says, what are your ways of keeping track of bourbons and other spirits you’ve tried over the years? When it comes to beer I’ve used the app untappd to rate and discover new craft beers in the past and I’ve really enjoyed using something like that.'</li><li>'Enjoy it. S-189 is a great yeast. I would not call it a Cold IPA. I would just call it a tasty noble-dry-hopped pilsner. Prost! Click to expand...'</li><li>"I've got some super high gravity homebrews that are over 20 years old - some over 25. They've been kept properly. Last one I cracked was a few years ago (over 20 years old - an imperial stout with elderberries from my sister's farm) and it was sublime. I wouldn't bother with commercial American light lagers that are over six months old (they are so underhopped anyway and those hop oils deteriorate), but whatever floats your goat."</li></ul> |
81
+ | 2 | <ul><li>"Taking one beer or glass of wine or so helps me relax and calm my thoughts. And it's tasty."</li><li>"Every person I know who works night shift has a drink or two after their shift just to fall asleep lol it might be a common thing. If it's in moderation and it's not ruining your health or interfering with your life, I'd say there's nothing wrong with having a beer or two to relax after work. After all you worked for it."</li><li>'Yes rdr2 is a really good game if you just want to relax, i come back from work sometimes order 2 beers, a burger, and fries and just enjoy the good music, scenery, and story'</li></ul> |
82
+ | 5 | <ul><li>'Having a beer at a wine farm, ah bo gintsa bona will never leave me ????'</li><li>"As a java lover, I determined to locate out which quickly meals chain in Canada made the fine coffee... and the reply certainly took me via surprise. To get an concept of the great espresso in Canada, I tried the brew from three of the most famous espresso chains in the country. I stored it easy by means of sampling a small black espresso from Starbucks, Tim Hortons and McDonald's to discover out which one reigns supreme."</li><li>"Despite it being only 92 with 35% humidity, a notably comfortable summer evening, my beer is gone and I'd better go cook up some supper . Y'all have fun!"</li></ul> |
83
+ | 0 | <ul><li>'It is 6:00 am. I’m preparing to head to the Muni with my father to celebrate the lives of my lifelong Browns fan uncle and grandfather who both passed away last week. Beers will be had, good times will be celebrated, and the Browns will kick ass. It is written. IT IS GAMEDAY MY DUDES.'</li><li>'I live in the "boonies" and beer is $14+ a can at any sporting event or concert I go to. Its wild.'</li><li>'Love it everytime! Best wings ever in my opinion especially the Carolina sweet & tangy. Bar quesadillas are to die for , lots of beer options for beer lovers like myself. & ALWAYS has the games on that I want to watch whether it’s basketball , baseball or football . My go to bar on the island .'</li></ul> |
84
+
85
+ ## Evaluation
86
+
87
+ ### Metrics
88
+ | Label | Accuracy |
89
+ |:--------|:---------|
90
+ | **all** | 0.0 |
91
+
92
+ ## Uses
93
+
94
+ ### Direct Use for Inference
95
+
96
+ First install the SetFit library:
97
+
98
+ ```bash
99
+ pip install setfit
100
+ ```
101
+
102
+ Then you can load this model and run inference.
103
+
104
+ ```python
105
+ from setfit import SetFitModel
106
+
107
+ # Download from the 🤗 Hub
108
+ model = SetFitModel.from_pretrained("bhaskars113/beer-model")
109
+ # Run inference
110
+ preds = model("@GayChemist @TylerDinucci It's Wisconsin. I assume that \"drinking fountains\" mean beer there.")
111
+ ```
112
+
113
+ <!--
114
+ ### Downstream Use
115
+
116
+ *List how someone could finetune this model on their own dataset.*
117
+ -->
118
+
119
+ <!--
120
+ ### Out-of-Scope Use
121
+
122
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
123
+ -->
124
+
125
+ <!--
126
+ ## Bias, Risks and Limitations
127
+
128
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
129
+ -->
130
+
131
+ <!--
132
+ ### Recommendations
133
+
134
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
135
+ -->
136
+
137
+ ## Training Details
138
+
139
+ ### Training Set Metrics
140
+ | Training set | Min | Median | Max |
141
+ |:-------------|:----|:--------|:----|
142
+ | Word count | 3 | 60.6875 | 260 |
143
+
144
+ | Label | Training Sample Count |
145
+ |:------|:----------------------|
146
+ | 0 | 16 |
147
+ | 1 | 16 |
148
+ | 2 | 16 |
149
+ | 3 | 16 |
150
+ | 4 | 16 |
151
+ | 5 | 16 |
152
+
153
+ ### Training Hyperparameters
154
+ - batch_size: (16, 16)
155
+ - num_epochs: (1, 1)
156
+ - max_steps: -1
157
+ - sampling_strategy: oversampling
158
+ - num_iterations: 20
159
+ - body_learning_rate: (2e-05, 2e-05)
160
+ - head_learning_rate: 2e-05
161
+ - loss: CosineSimilarityLoss
162
+ - distance_metric: cosine_distance
163
+ - margin: 0.25
164
+ - end_to_end: False
165
+ - use_amp: False
166
+ - warmup_proportion: 0.1
167
+ - seed: 42
168
+ - eval_max_steps: -1
169
+ - load_best_model_at_end: False
170
+
171
+ ### Training Results
172
+ | Epoch | Step | Training Loss | Validation Loss |
173
+ |:------:|:----:|:-------------:|:---------------:|
174
+ | 0.0042 | 1 | 0.2324 | - |
175
+ | 0.2083 | 50 | 0.1497 | - |
176
+ | 0.4167 | 100 | 0.0141 | - |
177
+ | 0.625 | 150 | 0.002 | - |
178
+ | 0.8333 | 200 | 0.0013 | - |
179
+
180
+ ### Framework Versions
181
+ - Python: 3.10.12
182
+ - SetFit: 1.0.3
183
+ - Sentence Transformers: 2.2.2
184
+ - Transformers: 4.35.2
185
+ - PyTorch: 2.1.0+cu121
186
+ - Datasets: 2.16.1
187
+ - Tokenizers: 0.15.1
188
+
189
+ ## Citation
190
+
191
+ ### BibTeX
192
+ ```bibtex
193
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
194
+ doi = {10.48550/ARXIV.2209.11055},
195
+ url = {https://arxiv.org/abs/2209.11055},
196
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
197
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
198
+ title = {Efficient Few-Shot Learning Without Prompts},
199
+ publisher = {arXiv},
200
+ year = {2022},
201
+ copyright = {Creative Commons Attribution 4.0 International}
202
+ }
203
+ ```
204
+
205
+ <!--
206
+ ## Glossary
207
+
208
+ *Clearly define terms in order to be accessible across audiences.*
209
+ -->
210
+
211
+ <!--
212
+ ## Model Card Authors
213
+
214
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
215
+ -->
216
+
217
+ <!--
218
+ ## Model Card Contact
219
+
220
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
221
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-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.35.2",
23
+ "vocab_size": 30527
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.7.0",
5
+ "pytorch": "1.9.0+cu102"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "labels": null,
3
+ "normalize_embeddings": false
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2459d7739cb9579600b5e2af33dace2c1e8dc91f40e29b0119d5b1988fc941c
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4586b6f3813a0205697cc74f5dfd1461e6536f2df353d83253531493f6c8ba78
3
+ size 37783
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
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": true,
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": true,
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,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "104": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "30526": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "do_basic_tokenize": true,
48
+ "do_lower_case": true,
49
+ "eos_token": "</s>",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 512,
52
+ "never_split": null,
53
+ "pad_token": "<pad>",
54
+ "sep_token": "</s>",
55
+ "strip_accents": null,
56
+ "tokenize_chinese_chars": true,
57
+ "tokenizer_class": "MPNetTokenizer",
58
+ "unk_token": "[UNK]"
59
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff