souvenger commited on
Commit
8f94f1b
1 Parent(s): 1a07ee8

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,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: Upgrade all installed packages with superuser privileges
12
+ - text: Install package 'vim' as superuser
13
+ - text: Remove package 'firefox' with superuser privileges
14
+ - text: Change permissions of directory 'docs' to writable
15
+ - text: Update package lists using superuser privileges
16
+ pipeline_tag: text-classification
17
+ inference: true
18
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
19
+ model-index:
20
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
21
+ results:
22
+ - task:
23
+ type: text-classification
24
+ name: Text Classification
25
+ dataset:
26
+ name: Unknown
27
+ type: unknown
28
+ split: test
29
+ metrics:
30
+ - type: accuracy
31
+ value: 0.0
32
+ name: Accuracy
33
+ ---
34
+
35
+ # SetFit with sentence-transformers/paraphrase-mpnet-base-v2
36
+
37
+ 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.
38
+
39
+ The model has been trained using an efficient few-shot learning technique that involves:
40
+
41
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
42
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
43
+
44
+ ## Model Details
45
+
46
+ ### Model Description
47
+ - **Model Type:** SetFit
48
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
49
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
50
+ - **Maximum Sequence Length:** 512 tokens
51
+ - **Number of Classes:** 30 classes
52
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
53
+ <!-- - **Language:** Unknown -->
54
+ <!-- - **License:** Unknown -->
55
+
56
+ ### Model Sources
57
+
58
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
59
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
60
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
61
+
62
+ ### Model Labels
63
+ | Label | Examples |
64
+ |:----------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------|
65
+ | ls | <ul><li>'List all files and directories'</li><li>'Show files in the current directory'</li><li>'Display contents of the current directory'</li></ul> |
66
+ | cd | <ul><li>'Change to the specified directory'</li><li>'Move to the home directory'</li><li>'Navigate to the specified directory path'</li></ul> |
67
+ | mkdir docs | <ul><li>"Create a new directory named 'docs'"</li></ul> |
68
+ | mkdir projects | <ul><li>"Make a directory named 'projects'"</li></ul> |
69
+ | mkdir data | <ul><li>"Create a folder called 'data'"</li></ul> |
70
+ | mkdir images | <ul><li>"Make a directory named 'images'"</li></ul> |
71
+ | mkdir scripts | <ul><li>"Create a new folder named 'scripts'"</li></ul> |
72
+ | rm example.txt | <ul><li>"Remove the file named 'example.txt'"</li></ul> |
73
+ | rm temp.txt | <ul><li>"Delete the file called 'temp.txt'"</li></ul> |
74
+ | rm file1 | <ul><li>"Remove the file named 'file1'"</li></ul> |
75
+ | rm file2 | <ul><li>"Delete the file named 'file2'"</li></ul> |
76
+ | rm backup.txt | <ul><li>"Remove the file named 'backup.txt'"</li></ul> |
77
+ | cp file1 /destination | <ul><li>'Copy file1 to directory /destination'</li></ul> |
78
+ | cp file2 /backup | <ul><li>'Duplicate file2 to directory /backup'</li></ul> |
79
+ | cp file3 /archive | <ul><li>'Copy file3 to folder /archive'</li></ul> |
80
+ | cp file4 /temp | <ul><li>'Duplicate file4 to folder /temp'</li></ul> |
81
+ | cp file5 /images | <ul><li>'Copy file5 to directory /images'</li></ul> |
82
+ | mv file2 /new_location | <ul><li>'Move file2 to directory /new_location'</li></ul> |
83
+ | mv file3 /backup | <ul><li>'Transfer file3 to directory /backup'</li></ul> |
84
+ | mv file4 /archive | <ul><li>'Move file4 to folder /archive'</li></ul> |
85
+ | mv file5 /temp | <ul><li>'Transfer file5 to folder /temp'</li></ul> |
86
+ | mv file6 /images | <ul><li>'Move file6 to directory /images'</li></ul> |
87
+ | cat README.md | <ul><li>"Display the contents of file 'README.md'"</li></ul> |
88
+ | cat notes.txt | <ul><li>"Show the content of file 'notes.txt'"</li></ul> |
89
+ | cat data.csv | <ul><li>"Print the contents of file 'data.csv'"</li></ul> |
90
+ | cat script.sh | <ul><li>"Display the content of file 'script.sh'"</li></ul> |
91
+ | cat config.ini | <ul><li>"Show the contents of file 'config.ini'"</li></ul> |
92
+ | grep 'pattern' data.txt | <ul><li>"Search for 'pattern' in file 'data.txt'"</li></ul> |
93
+ | grep 'word' text.txt | <ul><li>"Find occurrences of 'word' in file 'text.txt'"</li></ul> |
94
+ | grep 'keyword' document.txt | <ul><li>"Search for 'keyword' in file 'document.txt'"</li></ul> |
95
+
96
+ ## Evaluation
97
+
98
+ ### Metrics
99
+ | Label | Accuracy |
100
+ |:--------|:---------|
101
+ | **all** | 0.0 |
102
+
103
+ ## Uses
104
+
105
+ ### Direct Use for Inference
106
+
107
+ First install the SetFit library:
108
+
109
+ ```bash
110
+ pip install setfit
111
+ ```
112
+
113
+ Then you can load this model and run inference.
114
+
115
+ ```python
116
+ from setfit import SetFitModel
117
+
118
+ # Download from the 🤗 Hub
119
+ model = SetFitModel.from_pretrained("souvenger/NLP2Linux")
120
+ # Run inference
121
+ preds = model("Install package 'vim' as superuser")
122
+ ```
123
+
124
+ <!--
125
+ ### Downstream Use
126
+
127
+ *List how someone could finetune this model on their own dataset.*
128
+ -->
129
+
130
+ <!--
131
+ ### Out-of-Scope Use
132
+
133
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
134
+ -->
135
+
136
+ <!--
137
+ ## Bias, Risks and Limitations
138
+
139
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
140
+ -->
141
+
142
+ <!--
143
+ ### Recommendations
144
+
145
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
146
+ -->
147
+
148
+ ## Training Details
149
+
150
+ ### Training Set Metrics
151
+ | Training set | Min | Median | Max |
152
+ |:-------------|:----|:-------|:----|
153
+ | Word count | 5 | 5.6667 | 9 |
154
+
155
+ | Label | Training Sample Count |
156
+ |:----------------------------|:----------------------|
157
+ | cat README.md | 1 |
158
+ | cat config.ini | 1 |
159
+ | cat data.csv | 1 |
160
+ | cat notes.txt | 1 |
161
+ | cat script.sh | 1 |
162
+ | cd | 10 |
163
+ | cp file1 /destination | 1 |
164
+ | cp file2 /backup | 1 |
165
+ | cp file3 /archive | 1 |
166
+ | cp file4 /temp | 1 |
167
+ | cp file5 /images | 1 |
168
+ | grep 'keyword' document.txt | 1 |
169
+ | grep 'pattern' data.txt | 1 |
170
+ | grep 'word' text.txt | 1 |
171
+ | ls | 10 |
172
+ | mkdir data | 1 |
173
+ | mkdir docs | 1 |
174
+ | mkdir images | 1 |
175
+ | mkdir projects | 1 |
176
+ | mkdir scripts | 1 |
177
+ | mv file2 /new_location | 1 |
178
+ | mv file3 /backup | 1 |
179
+ | mv file4 /archive | 1 |
180
+ | mv file5 /temp | 1 |
181
+ | mv file6 /images | 1 |
182
+ | rm backup.txt | 1 |
183
+ | rm example.txt | 1 |
184
+ | rm file1 | 1 |
185
+ | rm file2 | 1 |
186
+ | rm temp.txt | 1 |
187
+
188
+ ### Training Hyperparameters
189
+ - batch_size: (8, 8)
190
+ - num_epochs: (1, 1)
191
+ - max_steps: -1
192
+ - sampling_strategy: oversampling
193
+ - num_iterations: 20
194
+ - body_learning_rate: (2e-05, 2e-05)
195
+ - head_learning_rate: 2e-05
196
+ - loss: CosineSimilarityLoss
197
+ - distance_metric: cosine_distance
198
+ - margin: 0.25
199
+ - end_to_end: False
200
+ - use_amp: False
201
+ - warmup_proportion: 0.1
202
+ - seed: 42
203
+ - eval_max_steps: -1
204
+ - load_best_model_at_end: False
205
+
206
+ ### Training Results
207
+ | Epoch | Step | Training Loss | Validation Loss |
208
+ |:------:|:----:|:-------------:|:---------------:|
209
+ | 0.0042 | 1 | 0.1215 | - |
210
+ | 0.2083 | 50 | 0.0232 | - |
211
+ | 0.4167 | 100 | 0.01 | - |
212
+ | 0.625 | 150 | 0.0044 | - |
213
+ | 0.8333 | 200 | 0.0025 | - |
214
+
215
+ ### Framework Versions
216
+ - Python: 3.10.13
217
+ - SetFit: 1.0.3
218
+ - Sentence Transformers: 2.3.1
219
+ - Transformers: 4.37.0
220
+ - PyTorch: 2.1.2
221
+ - Datasets: 2.1.0
222
+ - Tokenizers: 0.15.1
223
+
224
+ ## Citation
225
+
226
+ ### BibTeX
227
+ ```bibtex
228
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
229
+ doi = {10.48550/ARXIV.2209.11055},
230
+ url = {https://arxiv.org/abs/2209.11055},
231
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
232
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
233
+ title = {Efficient Few-Shot Learning Without Prompts},
234
+ publisher = {arXiv},
235
+ year = {2022},
236
+ copyright = {Creative Commons Attribution 4.0 International}
237
+ }
238
+ ```
239
+
240
+ <!--
241
+ ## Glossary
242
+
243
+ *Clearly define terms in order to be accessible across audiences.*
244
+ -->
245
+
246
+ <!--
247
+ ## Model Card Authors
248
+
249
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
250
+ -->
251
+
252
+ <!--
253
+ ## Model Card Contact
254
+
255
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
256
+ -->
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.0",
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,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "cat README.md",
4
+ "cat config.ini",
5
+ "cat data.csv",
6
+ "cat notes.txt",
7
+ "cat script.sh",
8
+ "cd",
9
+ "cp file1 /destination",
10
+ "cp file2 /backup",
11
+ "cp file3 /archive",
12
+ "cp file4 /temp",
13
+ "cp file5 /images",
14
+ "grep 'keyword' document.txt",
15
+ "grep 'pattern' data.txt",
16
+ "grep 'word' text.txt",
17
+ "ls",
18
+ "mkdir data",
19
+ "mkdir docs",
20
+ "mkdir images",
21
+ "mkdir projects",
22
+ "mkdir scripts",
23
+ "mv file2 /new_location",
24
+ "mv file3 /backup",
25
+ "mv file4 /archive",
26
+ "mv file5 /temp",
27
+ "mv file6 /images",
28
+ "rm backup.txt",
29
+ "rm example.txt",
30
+ "rm file1",
31
+ "rm file2",
32
+ "rm temp.txt"
33
+ ],
34
+ "normalize_embeddings": false
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4730a21856796350bb4948458ae4baaa872c1a2720a4565a320053a7c0efc62
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:389c231e4145f41a0d8906294beb0b421adb852f6fac405c905708231bb91528
3
+ size 188647
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