vidhi0206 commited on
Commit
ea79c7f
1 Parent(s): c099e0e

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
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
+ }
README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: i honestly thought impossible at this point i feel pretty
12
+ - text: i feel convinced that im going to shy away from whatever is really good for
13
+ me
14
+ - text: i feel guilt that i should be more caring and im not
15
+ - text: i found myself feeling nostalgic as i thought about the temporarily abandoned
16
+ little bishop chronicles
17
+ - text: i am feeling very indecisive and spontaneous
18
+ pipeline_tag: text-classification
19
+ inference: true
20
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
21
+ model-index:
22
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
23
+ results:
24
+ - task:
25
+ type: text-classification
26
+ name: Text Classification
27
+ dataset:
28
+ name: Unknown
29
+ type: unknown
30
+ split: test
31
+ metrics:
32
+ - type: accuracy
33
+ value: 0.442
34
+ name: Accuracy
35
+ ---
36
+
37
+ # SetFit with sentence-transformers/paraphrase-mpnet-base-v2
38
+
39
+ 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.
40
+
41
+ The model has been trained using an efficient few-shot learning technique that involves:
42
+
43
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
44
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
45
+
46
+ ## Model Details
47
+
48
+ ### Model Description
49
+ - **Model Type:** SetFit
50
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
51
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
52
+ - **Maximum Sequence Length:** 512 tokens
53
+ - **Number of Classes:** 6 classes
54
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
55
+ <!-- - **Language:** Unknown -->
56
+ <!-- - **License:** Unknown -->
57
+
58
+ ### Model Sources
59
+
60
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
61
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
62
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
63
+
64
+ ### Model Labels
65
+ | Label | Examples |
66
+ |:------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
67
+ | 3 | <ul><li>'im fine mary anne answered feeling a little impatient'</li><li>'i feel outraged that my life is so easy so blessed'</li><li>'i suggested greys and blues with warm tones as the room is north facing and could feel quite cold and flat'</li></ul> |
68
+ | 4 | <ul><li>'i still feel its a little shaky at times and can move into the slightly odd jades hair in particular seems prone to this but generally it works well with spencers writing'</li><li>'i also feel strange that by the ripe old age of twenty three i want a goddamn life partner'</li><li>'i feel acclimated like i am finally a part of this organization rather than a timid observer'</li></ul> |
69
+ | 5 | <ul><li>'i always feel so flattered when another amazing blogger asks me to share a little of world on their blog so here it goes'</li><li>'i was like oh thats awesome blah but then he was like reminding me hes interested in this other girl and i was like i know this but what concerns me more is if it makes you feel too weird to be with me like this'</li><li>'i gotta say im feeling pretty impressed with how everything ended up considering my total dollars dropped totaled and i have three small canvases to play with display with'</li></ul> |
70
+ | 1 | <ul><li>'i still am not able to remember a single dull moment a detail that pissed me off a thing i didnt feel comfortable about'</li><li>'i can t find anything to feel other than complacent'</li><li>'i am feeling a little bouncy right now'</li></ul> |
71
+ | 0 | <ul><li>'i hide this secret inside of me away from everyone because i feel ashamed and like i have no assistance in making it better'</li><li>'i could feel how exhausted my arms and legs were'</li><li>'i am also feeling awful'</li></ul> |
72
+ | 2 | <ul><li>'i can feel passionate about taking a stand and maybe understand that this one as yet to be chosen issue is worthy of my time and efforts'</li><li>'i do awaken from a mild night sweat i usually feel hot as if i had a fever and i want to remove some of my blankets'</li><li>'i am feeling quite fond of my friends'</li></ul> |
73
+
74
+ ## Evaluation
75
+
76
+ ### Metrics
77
+ | Label | Accuracy |
78
+ |:--------|:---------|
79
+ | **all** | 0.442 |
80
+
81
+ ## Uses
82
+
83
+ ### Direct Use for Inference
84
+
85
+ First install the SetFit library:
86
+
87
+ ```bash
88
+ pip install setfit
89
+ ```
90
+
91
+ Then you can load this model and run inference.
92
+
93
+ ```python
94
+ from setfit import SetFitModel
95
+
96
+ # Download from the 🤗 Hub
97
+ model = SetFitModel.from_pretrained("vidhi0206/setfit-paraphrase-mpnet-emotion")
98
+ # Run inference
99
+ preds = model("i am feeling very indecisive and spontaneous")
100
+ ```
101
+
102
+ <!--
103
+ ### Downstream Use
104
+
105
+ *List how someone could finetune this model on their own dataset.*
106
+ -->
107
+
108
+ <!--
109
+ ### Out-of-Scope Use
110
+
111
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
112
+ -->
113
+
114
+ <!--
115
+ ## Bias, Risks and Limitations
116
+
117
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
118
+ -->
119
+
120
+ <!--
121
+ ### Recommendations
122
+
123
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
124
+ -->
125
+
126
+ ## Training Details
127
+
128
+ ### Training Set Metrics
129
+ | Training set | Min | Median | Max |
130
+ |:-------------|:----|:--------|:----|
131
+ | Word count | 4 | 18.7292 | 46 |
132
+
133
+ | Label | Training Sample Count |
134
+ |:------|:----------------------|
135
+ | 0 | 8 |
136
+ | 1 | 8 |
137
+ | 2 | 8 |
138
+ | 3 | 8 |
139
+ | 4 | 8 |
140
+ | 5 | 8 |
141
+
142
+ ### Training Hyperparameters
143
+ - batch_size: (8, 8)
144
+ - num_epochs: (1, 1)
145
+ - max_steps: -1
146
+ - sampling_strategy: oversampling
147
+ - num_iterations: 20
148
+ - body_learning_rate: (2e-05, 2e-05)
149
+ - head_learning_rate: 2e-05
150
+ - loss: CosineSimilarityLoss
151
+ - distance_metric: cosine_distance
152
+ - margin: 0.25
153
+ - end_to_end: False
154
+ - use_amp: False
155
+ - warmup_proportion: 0.1
156
+ - seed: 42
157
+ - eval_max_steps: -1
158
+ - load_best_model_at_end: False
159
+
160
+ ### Training Results
161
+ | Epoch | Step | Training Loss | Validation Loss |
162
+ |:------:|:----:|:-------------:|:---------------:|
163
+ | 0.0042 | 1 | 0.2264 | - |
164
+ | 0.2083 | 50 | 0.0997 | - |
165
+ | 0.4167 | 100 | 0.0257 | - |
166
+ | 0.625 | 150 | 0.0089 | - |
167
+ | 0.8333 | 200 | 0.003 | - |
168
+
169
+ ### Framework Versions
170
+ - Python: 3.8.10
171
+ - SetFit: 1.0.3
172
+ - Sentence Transformers: 2.3.1
173
+ - Transformers: 4.37.2
174
+ - PyTorch: 2.2.0+cu121
175
+ - Datasets: 2.17.0
176
+ - Tokenizers: 0.15.1
177
+
178
+ ## Citation
179
+
180
+ ### BibTeX
181
+ ```bibtex
182
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
183
+ doi = {10.48550/ARXIV.2209.11055},
184
+ url = {https://arxiv.org/abs/2209.11055},
185
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
186
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
187
+ title = {Efficient Few-Shot Learning Without Prompts},
188
+ publisher = {arXiv},
189
+ year = {2022},
190
+ copyright = {Creative Commons Attribution 4.0 International}
191
+ }
192
+ ```
193
+
194
+ <!--
195
+ ## Glossary
196
+
197
+ *Clearly define terms in order to be accessible across audiences.*
198
+ -->
199
+
200
+ <!--
201
+ ## Model Card Authors
202
+
203
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
204
+ -->
205
+
206
+ <!--
207
+ ## Model Card Contact
208
+
209
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
210
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "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.37.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:3b4d9434c877293c930726f50ecd81f94c4319d74ed8e307d906f18bca2d0d9d
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf3f7169b6f8b6229f78095699d58f6c0c468b03aefb2f8b48533896f12b79a3
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": 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,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