Omar-Nasr commited on
Commit
01e9e6e
1 Parent(s): 1d22c20

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 1024,
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,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ base_model: sentence-transformers/all-roberta-large-v1
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: ' Anytime I’d feel uncomfortable in gatherings I’d be like “haha fuck this
13
+ I’m OUTTTTTAAAA HEEERRREEE” then go outside to recollect myself for a few moments'
14
+ - text: ' But even then, I didn''t have any other problems outside school I still
15
+ had no friends at European school, I haven''t had any walks which I had constantly
16
+ with my friends back in Ukraine'
17
+ - text: ' I do try to get out a lot because of this especially now that it''s nicer
18
+ outside I go for runs every day almost but this last week like something threw
19
+ me off'
20
+ - text: ' I literally do not leave the house, I will sometimes go in the garden but
21
+ no further So I just ran outside and back to the car'
22
+ - text: ' I hated even going outside and seeing other people, because I just knew
23
+ how awkward and weird they would think I am for the way I looked and the way I
24
+ walked I hated even going outside and seeing other people, because I just knew
25
+ how awkward and weird they would think I am for the way I looked and the way I
26
+ walked'
27
+ pipeline_tag: text-classification
28
+ inference: true
29
+ model-index:
30
+ - name: SetFit with sentence-transformers/all-roberta-large-v1
31
+ results:
32
+ - task:
33
+ type: text-classification
34
+ name: Text Classification
35
+ dataset:
36
+ name: Unknown
37
+ type: unknown
38
+ split: test
39
+ metrics:
40
+ - type: accuracy
41
+ value: 0.43333333333333335
42
+ name: Accuracy
43
+ ---
44
+
45
+ # SetFit with sentence-transformers/all-roberta-large-v1
46
+
47
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/all-roberta-large-v1](https://huggingface.co/sentence-transformers/all-roberta-large-v1) 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.
48
+
49
+ The model has been trained using an efficient few-shot learning technique that involves:
50
+
51
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
52
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
53
+
54
+ ## Model Details
55
+
56
+ ### Model Description
57
+ - **Model Type:** SetFit
58
+ - **Sentence Transformer body:** [sentence-transformers/all-roberta-large-v1](https://huggingface.co/sentence-transformers/all-roberta-large-v1)
59
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
60
+ - **Maximum Sequence Length:** 256 tokens
61
+ - **Number of Classes:** 4 classes
62
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
63
+ <!-- - **Language:** Unknown -->
64
+ <!-- - **License:** Unknown -->
65
+
66
+ ### Model Sources
67
+
68
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
69
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
70
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
71
+
72
+ ### Model Labels
73
+ | Label | Examples |
74
+ |:------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75
+ | 3.0 | <ul><li>' However, one day after lunch I was walking to his classroom to get to his class Every time I go outside I instantly get nervous'</li><li>' Very generic title, but i was just wondering, does anyone feel really safe and happy when hiding? For example everytime i go outside for work i get stared at'</li><li>" Also, i'm living in my parent's home for 20 years and although i know very few neighbors i feel stalked outside, and it's like everyone knows who i am (the building complex is in a dead-end street and all the windows make me anxious) Today i was leaving school's parking lot when i gave way to 2 other students - one looked at me in complete disgust while passing by, the other laughed at me (i even considered if i made some mistake) So i parked a bit more inclined to the road side than to the sidewalk (these are small streets and people usually park in the sidewalk) and other car couldn't pass to the end of the street"</li></ul> |
76
+ | 0.0 | <ul><li>' Good to know that some people are in the same camp'</li><li>' If anything you should be thinking about wearing sun screen so you retain your good skin as it becomes your ally as you age outside'</li><li>" I'm sure if the worlds ever did clash that your friends would understand (few people actually enjoy being at work) and, worst case scenario, your coworkers would be surprised at your outgoing nature while around friends"</li></ul> |
77
+ | 1.0 | <ul><li>" Now I'm not saying to go to a party on the spot, just go out, shop, take a walk in the park, that kind of thing Now I'm not saying to go to a party on the spot, just go out, shop, take a walk in the park, that kind of thing"</li><li>" Dairy can help a lot too! And for the boost and help that exercise makes, Go for jogs at night assuming you live in a safe area! Thats what I do! Between 1am and 3am nobody is ever out In my months of walking at night I've never seen someone even look at me from their car"</li><li>" That's kind of the nature of my volunteer work, but you could volunteer with a food bank or boys and girls club, which would involve more social interaction Just breaking that cycle by going for a short walk around the neighbourhood is a good idea"</li></ul> |
78
+ | 2.0 | <ul><li>' It could be 100 degrees outside and I refused to take the hoodie off'</li><li>' I hated even going outside and seeing other people, because I just knew how awkward and weird they would think I am for the way I looked and the way I walked I hated even going outside and seeing other people, because I just knew how awkward and weird they would think I am for the way I looked and the way I walked'</li><li>' I like art and nature but you can’t really talk about those for more than a few seconds'</li></ul> |
79
+
80
+ ## Evaluation
81
+
82
+ ### Metrics
83
+ | Label | Accuracy |
84
+ |:--------|:---------|
85
+ | **all** | 0.4333 |
86
+
87
+ ## Uses
88
+
89
+ ### Direct Use for Inference
90
+
91
+ First install the SetFit library:
92
+
93
+ ```bash
94
+ pip install setfit
95
+ ```
96
+
97
+ Then you can load this model and run inference.
98
+
99
+ ```python
100
+ from setfit import SetFitModel
101
+
102
+ # Download from the 🤗 Hub
103
+ model = SetFitModel.from_pretrained("Omar-Nasr/setfitmodel")
104
+ # Run inference
105
+ preds = model(" I literally do not leave the house, I will sometimes go in the garden but no further So I just ran outside and back to the car")
106
+ ```
107
+
108
+ <!--
109
+ ### Downstream Use
110
+
111
+ *List how someone could finetune this model on their own dataset.*
112
+ -->
113
+
114
+ <!--
115
+ ### Out-of-Scope Use
116
+
117
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
118
+ -->
119
+
120
+ <!--
121
+ ## Bias, Risks and Limitations
122
+
123
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
124
+ -->
125
+
126
+ <!--
127
+ ### Recommendations
128
+
129
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
130
+ -->
131
+
132
+ ## Training Details
133
+
134
+ ### Training Set Metrics
135
+ | Training set | Min | Median | Max |
136
+ |:-------------|:----|:-------|:----|
137
+ | Word count | 7 | 33.15 | 121 |
138
+
139
+ | Label | Training Sample Count |
140
+ |:------|:----------------------|
141
+ | 0.0 | 10 |
142
+ | 1.0 | 10 |
143
+ | 2.0 | 10 |
144
+ | 3.0 | 10 |
145
+
146
+ ### Training Hyperparameters
147
+ - batch_size: (16, 16)
148
+ - num_epochs: (4, 4)
149
+ - max_steps: -1
150
+ - sampling_strategy: oversampling
151
+ - body_learning_rate: (2e-05, 1e-05)
152
+ - head_learning_rate: 0.01
153
+ - loss: CosineSimilarityLoss
154
+ - distance_metric: cosine_distance
155
+ - margin: 0.25
156
+ - end_to_end: False
157
+ - use_amp: False
158
+ - warmup_proportion: 0.1
159
+ - seed: 42
160
+ - eval_max_steps: -1
161
+ - load_best_model_at_end: False
162
+
163
+ ### Training Results
164
+ | Epoch | Step | Training Loss | Validation Loss |
165
+ |:------:|:----:|:-------------:|:---------------:|
166
+ | 0.0133 | 1 | 0.2699 | - |
167
+ | 0.6667 | 50 | 0.0497 | - |
168
+ | 1.3333 | 100 | 0.0012 | - |
169
+ | 2.0 | 150 | 0.0003 | - |
170
+ | 2.6667 | 200 | 0.0003 | - |
171
+ | 3.3333 | 250 | 0.0002 | - |
172
+ | 4.0 | 300 | 0.0001 | - |
173
+
174
+ ### Framework Versions
175
+ - Python: 3.10.13
176
+ - SetFit: 1.0.3
177
+ - Sentence Transformers: 2.7.0
178
+ - Transformers: 4.38.1
179
+ - PyTorch: 2.1.2
180
+ - Datasets: 2.19.0
181
+ - Tokenizers: 0.15.2
182
+
183
+ ## Citation
184
+
185
+ ### BibTeX
186
+ ```bibtex
187
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
188
+ doi = {10.48550/ARXIV.2209.11055},
189
+ url = {https://arxiv.org/abs/2209.11055},
190
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
191
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
192
+ title = {Efficient Few-Shot Learning Without Prompts},
193
+ publisher = {arXiv},
194
+ year = {2022},
195
+ copyright = {Creative Commons Attribution 4.0 International}
196
+ }
197
+ ```
198
+
199
+ <!--
200
+ ## Glossary
201
+
202
+ *Clearly define terms in order to be accessible across audiences.*
203
+ -->
204
+
205
+ <!--
206
+ ## Model Card Authors
207
+
208
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
209
+ -->
210
+
211
+ <!--
212
+ ## Model Card Contact
213
+
214
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
215
+ -->
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "sentence-transformers/all-roberta-large-v1",
3
+ "architectures": [
4
+ "RobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 1024,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 4096,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 514,
18
+ "model_type": "roberta",
19
+ "num_attention_heads": 16,
20
+ "num_hidden_layers": 24,
21
+ "pad_token_id": 1,
22
+ "position_embedding_type": "absolute",
23
+ "torch_dtype": "float32",
24
+ "transformers_version": "4.38.1",
25
+ "type_vocab_size": 1,
26
+ "use_cache": true,
27
+ "vocab_size": 50265
28
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.6.1",
5
+ "pytorch": "1.8.1"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null
9
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "labels": null,
3
+ "normalize_embeddings": false
4
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f9d8937185092da4ad87406e8efb306c4adafec466f0878b00016e95a99d359
3
+ size 1421483904
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:653a6490d54676a06268211ad22fb93ef91390fe33b5d1dc097f6a92f3dafdac
3
+ size 33639
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": 256,
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,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "max_length": 128,
52
+ "model_max_length": 512,
53
+ "pad_to_multiple_of": null,
54
+ "pad_token": "<pad>",
55
+ "pad_token_type_id": 0,
56
+ "padding_side": "right",
57
+ "sep_token": "</s>",
58
+ "stride": 0,
59
+ "tokenizer_class": "RobertaTokenizer",
60
+ "trim_offsets": true,
61
+ "truncation_side": "right",
62
+ "truncation_strategy": "longest_first",
63
+ "unk_token": "<unk>"
64
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff