HarshalBhg commited on
Commit
0bb8dba
1 Parent(s): 5f65756

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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
+ }
README.md ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ datasets:
9
+ - dvilasuero/banking77-topics-setfit
10
+ metrics:
11
+ - accuracy
12
+ widget:
13
+ - text: I requested a refund, and never received it. What can I do?
14
+ - text: I have a 1 euro fee on my statement.
15
+ - text: I would like an account for my children, how do I go about doing this?
16
+ - text: What do I need to do to transfer money into my account?
17
+ - text: Which country's currency do you support?
18
+ pipeline_tag: text-classification
19
+ inference: true
20
+ base_model: thenlper/gte-large
21
+ model-index:
22
+ - name: SetFit with thenlper/gte-large
23
+ results:
24
+ - task:
25
+ type: text-classification
26
+ name: Text Classification
27
+ dataset:
28
+ name: dvilasuero/banking77-topics-setfit
29
+ type: dvilasuero/banking77-topics-setfit
30
+ split: test
31
+ metrics:
32
+ - type: accuracy
33
+ value: 0.9230769230769231
34
+ name: Accuracy
35
+ ---
36
+
37
+ # SetFit with thenlper/gte-large
38
+
39
+ This is a [SetFit](https://github.com/huggingface/setfit) model trained on the [dvilasuero/banking77-topics-setfit](https://huggingface.co/datasets/dvilasuero/banking77-topics-setfit) dataset that can be used for Text Classification. This SetFit model uses [thenlper/gte-large](https://huggingface.co/thenlper/gte-large) 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:** [thenlper/gte-large](https://huggingface.co/thenlper/gte-large)
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:** 8 classes
54
+ - **Training Dataset:** [dvilasuero/banking77-topics-setfit](https://huggingface.co/datasets/dvilasuero/banking77-topics-setfit)
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
+ | 2 | <ul><li>'The money I transferred does not show in the balance.'</li><li>'I was wondering how I could have two charges for the same item happen more than once in a 7 day period. Is there anyway I could get this corrected asap.'</li><li>'What is the source of my available funds?'</li></ul> |
68
+ | 0 | <ul><li>'Do you support the EU?'</li><li>"Can you freeze my account? I just saw there are transactions on my account that I don't recognize. How can I fix this?"</li><li>'Please close my account. I am unsatisfied with your service.'</li></ul> |
69
+ | 5 | <ul><li>'Are you able to unblock my pin?'</li><li>'I can not find my card pin.'</li><li>'If I need a PIN for my card, where is it located?'</li></ul> |
70
+ | 1 | <ul><li>"I can't get money out of the ATM"</li><li>'Where can I use this card at an ATM?'</li><li>'Can I use my card at any ATMs?'</li></ul> |
71
+ | 3 | <ul><li>'Can I get cash with this card anywhere?'</li><li>'Can you please show me where I can find the location to link my card?'</li><li>'Am I able to get a card in EU?'</li></ul> |
72
+ | 6 | <ul><li>'My friends want to top up my account'</li><li>'Can I be topped up once I hit a certain balance?'</li><li>'Can you tell me why my top up was reverted?'</li></ul> |
73
+ | 7 | <ul><li>'How do I send my account money through transfer?'</li><li>'How do I transfer money to my account?'</li><li>'How can I transfer money from an outside bank?'</li></ul> |
74
+ | 4 | <ul><li>'Do you work with all fiat currencies?'</li><li>'Can I exchange to EUR?'</li><li>'Is my country supported'</li></ul> |
75
+
76
+ ## Evaluation
77
+
78
+ ### Metrics
79
+ | Label | Accuracy |
80
+ |:--------|:---------|
81
+ | **all** | 0.9231 |
82
+
83
+ ## Uses
84
+
85
+ ### Direct Use for Inference
86
+
87
+ First install the SetFit library:
88
+
89
+ ```bash
90
+ pip install setfit
91
+ ```
92
+
93
+ Then you can load this model and run inference.
94
+
95
+ ```python
96
+ from setfit import SetFitModel
97
+
98
+ # Download from the 🤗 Hub
99
+ model = SetFitModel.from_pretrained("HarshalBhg/gte-large-setfit-train-test2")
100
+ # Run inference
101
+ preds = model("I have a 1 euro fee on my statement.")
102
+ ```
103
+
104
+ <!--
105
+ ### Downstream Use
106
+
107
+ *List how someone could finetune this model on their own dataset.*
108
+ -->
109
+
110
+ <!--
111
+ ### Out-of-Scope Use
112
+
113
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
114
+ -->
115
+
116
+ <!--
117
+ ## Bias, Risks and Limitations
118
+
119
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
120
+ -->
121
+
122
+ <!--
123
+ ### Recommendations
124
+
125
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
126
+ -->
127
+
128
+ ## Training Details
129
+
130
+ ### Training Set Metrics
131
+ | Training set | Min | Median | Max |
132
+ |:-------------|:----|:--------|:----|
133
+ | Word count | 4 | 10.5833 | 40 |
134
+
135
+ | Label | Training Sample Count |
136
+ |:------|:----------------------|
137
+ | 0 | 10 |
138
+ | 1 | 19 |
139
+ | 2 | 28 |
140
+ | 3 | 36 |
141
+ | 4 | 13 |
142
+ | 5 | 14 |
143
+ | 6 | 15 |
144
+ | 7 | 21 |
145
+
146
+ ### Training Hyperparameters
147
+ - batch_size: (16, 16)
148
+ - num_epochs: (1, 1)
149
+ - max_steps: -1
150
+ - sampling_strategy: oversampling
151
+ - num_iterations: 20
152
+ - body_learning_rate: (2e-05, 1e-05)
153
+ - head_learning_rate: 0.01
154
+ - loss: CosineSimilarityLoss
155
+ - distance_metric: cosine_distance
156
+ - margin: 0.25
157
+ - end_to_end: False
158
+ - use_amp: False
159
+ - warmup_proportion: 0.1
160
+ - seed: 42
161
+ - eval_max_steps: -1
162
+ - load_best_model_at_end: False
163
+
164
+ ### Training Results
165
+ | Epoch | Step | Training Loss | Validation Loss |
166
+ |:------:|:----:|:-------------:|:---------------:|
167
+ | 0.0026 | 1 | 0.3183 | - |
168
+ | 0.1282 | 50 | 0.0614 | - |
169
+ | 0.2564 | 100 | 0.0044 | - |
170
+ | 0.3846 | 150 | 0.001 | - |
171
+ | 0.5128 | 200 | 0.0008 | - |
172
+ | 0.6410 | 250 | 0.001 | - |
173
+ | 0.7692 | 300 | 0.0006 | - |
174
+ | 0.8974 | 350 | 0.0012 | - |
175
+
176
+ ### Framework Versions
177
+ - Python: 3.10.12
178
+ - SetFit: 1.0.1
179
+ - Sentence Transformers: 2.2.2
180
+ - Transformers: 4.35.2
181
+ - PyTorch: 2.1.0+cu121
182
+ - Datasets: 2.15.0
183
+ - Tokenizers: 0.15.0
184
+
185
+ ## Citation
186
+
187
+ ### BibTeX
188
+ ```bibtex
189
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
190
+ doi = {10.48550/ARXIV.2209.11055},
191
+ url = {https://arxiv.org/abs/2209.11055},
192
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
193
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
194
+ title = {Efficient Few-Shot Learning Without Prompts},
195
+ publisher = {arXiv},
196
+ year = {2022},
197
+ copyright = {Creative Commons Attribution 4.0 International}
198
+ }
199
+ ```
200
+
201
+ <!--
202
+ ## Glossary
203
+
204
+ *Clearly define terms in order to be accessible across audiences.*
205
+ -->
206
+
207
+ <!--
208
+ ## Model Card Authors
209
+
210
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
211
+ -->
212
+
213
+ <!--
214
+ ## Model Card Contact
215
+
216
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
217
+ -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/.cache/torch/sentence_transformers/thenlper_gte-large/",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 1024,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 4096,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 16,
18
+ "num_hidden_layers": 24,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.35.2",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.35.2",
5
+ "pytorch": "2.1.0+cu121"
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:fc3c32568d9df4c4e88426d14efcfd9071cfb90e9f592466bda41f85b7bf5da6
3
+ size 1340612432
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ca4fb5e35421aeaf8fbc060fe40511d66674e53e544b703459636bf370afc28
3
+ size 66487
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": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "mask_token": "[MASK]",
48
+ "max_length": 128,
49
+ "model_max_length": 1000000000000000019884624838656,
50
+ "pad_to_multiple_of": null,
51
+ "pad_token": "[PAD]",
52
+ "pad_token_type_id": 0,
53
+ "padding_side": "right",
54
+ "sep_token": "[SEP]",
55
+ "stride": 0,
56
+ "strip_accents": null,
57
+ "tokenize_chinese_chars": true,
58
+ "tokenizer_class": "BertTokenizer",
59
+ "truncation_side": "right",
60
+ "truncation_strategy": "longest_first",
61
+ "unk_token": "[UNK]"
62
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff