mann2107 commited on
Commit
fde2a23
1 Parent(s): 4ec9ed5

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
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,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-MiniLM-L6-v2
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: The itinerary meets our requirements, please book as proposed.
13
+ - text: 'Please may you kindly send us the invoices for our stay at the Protea hotel
14
+ in Cape Town from 20/07/2023 - 22/07/2023. The four confirmation numbers from
15
+ the vouchers are as follows: 74733068 74731210 74729566 74727187'
16
+ - text: Can you please tell me if this Flight ticket for Shaun Connolly was charge
17
+ to the LBP travel card.
18
+ - text: I am very confused on the itineraries I've received for Michelle Curtin. Can
19
+ you please send me an updated itinerary with her actual travel schedule?
20
+ - text: I got a call late Friday afternoon to move our meeting of today. The rental
21
+ company was supposed to drop off the car for me at 13:00. Can you please call
22
+ and find out if they can deliver it before 10 this morning. Preferably 9. Sorry
23
+ for the inconvenience.
24
+ pipeline_tag: text-classification
25
+ inference: true
26
+ model-index:
27
+ - name: SetFit with sentence-transformers/all-MiniLM-L6-v2
28
+ results:
29
+ - task:
30
+ type: text-classification
31
+ name: Text Classification
32
+ dataset:
33
+ name: Unknown
34
+ type: unknown
35
+ split: test
36
+ metrics:
37
+ - type: accuracy
38
+ value: 0.875
39
+ name: Accuracy
40
+ ---
41
+
42
+ # SetFit with sentence-transformers/all-MiniLM-L6-v2
43
+
44
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-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.
45
+
46
+ The model has been trained using an efficient few-shot learning technique that involves:
47
+
48
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
49
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
50
+
51
+ ## Model Details
52
+
53
+ ### Model Description
54
+ - **Model Type:** SetFit
55
+ - **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
56
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
57
+ - **Maximum Sequence Length:** 256 tokens
58
+ - **Number of Classes:** 9 classes
59
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
60
+ <!-- - **Language:** Unknown -->
61
+ <!-- - **License:** Unknown -->
62
+
63
+ ### Model Sources
64
+
65
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
66
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
67
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
68
+
69
+ ### Model Labels
70
+ | Label | Examples |
71
+ |:------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
72
+ | 0 | <ul><li>'Please send me quotation for a flight for Lindelani Mkhize - East London/ Durban 31 August @ 12:00'</li><li>'I need to go to Fort Smith AR via XNA for PD days. I d like to take AA 4064 at 10:00 am arriving 11:58 am on Monday, May 11 returning on AA 4064 at 12:26 pm arriving 2:16 pm on Saturday May 16. I will need a Hertz rental. I d like to stay at the Courtyard Marriott in Fort Smith on Monday through Thursday nights checking out on Friday morning. Then I d like to stay at the Hilton Garden Inn in Bentonville AR on Walton Road Friday night checking out Saturday morning.'</li><li>'I am planning to attend a Training in to be held between Nov 22-24 2023 at Avon, France (Specific address is Corning, 7 Bis Av. de Valvins, 77210 Avon, France) I have to arrive in France on the 21st of Nov and leave on the 25th of Nov. May you please help me with the travel itinerary and accommodation quotation (within walking distance preferably), transport in France to the hotel from the airport and back. I would like to put in an overseas travel request.'</li></ul> |
73
+ | 1 | <ul><li>"Hello, Can someone help to cancel my trip in Concur? I'm unable to do it in the system. Trip from San Francisco to Minneapolis/St Paul (MDFNTI)<https://www.concursolutions.com/travelportal/triplibrary.asp>"</li><li>'Please cancel my flight for late March to Chicago and DC. Meetings have been cancelled. I am not available by phone.'</li><li>'I need to cancel the below trip due to illness in family. Could you please assist with this?'</li></ul> |
74
+ | 2 | <ul><li>'I have a travel booking question. I booked a flight for myself & a coworker, however, it was requested that we leave a couple days earlier than planned. How can I revise/move our first flight up without cancelling the whole trip? The flights home will remain the same.'</li><li>'I just received my KTN today and added it to my profile. However, I have flights in Nov booked with United and Delta. Any way to add the KTN to those reservations so the tickets come through with Pre-Check?'</li><li>"Lerato I checked Selbourne B/B, its not a nice place. Your colleague Stella booked Lindelani Mkhize in Hempston it's a beautiful place next to Garden Court, please change the accommodation from Selbourne to Hempston. This Selbourne is on the outskirt and my colleagues are not familiar with East London"</li></ul> |
75
+ | 3 | <ul><li>'Please add the below employee to our Concur system. In addition, make sure the Ghost Card is added into their profile. Lindsay Griffin lgriffin@arlingtonroe.com'</li><li>"Good afternoon - CAEP has 4 new staff members that we'd like to set - up new user profiles for. Please see the below information and let me know should anything additional be required. Last First Middle Travel Class Email Gender DOB Graham Rose - Helen Xiuqing Staff rose - helen.graham@caepnet.org Female 6/14/1995 Gumbs Mary - Frances Akua Staff mary.gumbs@caepnet.org Female 10/18/1995 Lee Elizabeth Andie Staff liz.lee@caepnet.org Female 4/23/1991 Gilchrist Gabriel Jake Staff gabriel.gilchrist@caepnet.org Male"</li><li>'Good Morning, Please create a profile for Amelia West: Name: Amelia Jean - Danielle West DOB: 05/21/1987 PH: 202 - 997 - 6592 Email: asuermann@facs.org'</li></ul> |
76
+ | 4 | <ul><li>'Invoices October 2019 Hi, My name is Lucia De Las Heras property accountant at Trion Properties. I am missing a few receipts to allocate the following charges. Would you please be able to provide a detailed invoice? 10/10/2019 FROSCH/GANT TRAVEL MBLOOMINGTON IN - 21'</li><li>'I would like to request an invoice/s for the above-mentioned employee who stayed at your establishment. Thank you for the other invoice August 2023 & the confirmation for the new reservation 01st - 04th October 2023, Thanking you in Advance!'</li><li>"Hello, Looking for an invoice for the below charge to Ryan Schulke's card - could you please assist? Vendor: United Airlines Transaction Date: 02/04/2020 Amount: $2,132.07 Ticket Number: 0167515692834"</li></ul> |
77
+ | 5 | <ul><li>'This is the second email with this trip, but I still need an itinerary for trip scheduled for January 27. Derek'</li><li>'Please send us all the flights used by G4S Kenya in the year 2022. Sorry for the short notice but we need the information by 12:00 noon today.'</li><li>'Jen Holt Can you please send me the itinerary for Jen Holt for this trip this week to Jackson Mississippi?'</li></ul> |
78
+ | 6 | <ul><li>"I've had to call off my vacation. What are my options for getting refunded?"</li><li>"Looks like I won't be traveling due to some health issues. Is getting a refund for my booking possible?"</li><li>"I've fallen ill and can't travel as planned. Can you process a refund for me?"</li></ul> |
79
+ | 7 | <ul><li>'The arrangements as stated are acceptable. Please go ahead and confirm all bookings accordingly.'</li><li>"I've reviewed the details and everything seems in order. Please proceed with the booking."</li><li>'This travel plan is satisfactory. Please secure the necessary reservations.'</li></ul> |
80
+ | 8 | <ul><li>'I need some clarification on charges for a rebooked flight. It seems higher than anticipated. Who can provide more details?'</li><li>'Wishing you and your family a very Merry Christmas and a Happy and Healthy New Year. I have one unidentified item this month, hope you can help, and as always thanks in advance. Very limited information on this. 11/21/2019 #N/A #N/A #N/A 142.45 Rail Europe North Amer'</li><li>"We've identified a mismatch between our booking records and credit card statement. Who can assist with this issue?"</li></ul> |
81
+
82
+ ## Evaluation
83
+
84
+ ### Metrics
85
+ | Label | Accuracy |
86
+ |:--------|:---------|
87
+ | **all** | 0.875 |
88
+
89
+ ## Uses
90
+
91
+ ### Direct Use for Inference
92
+
93
+ First install the SetFit library:
94
+
95
+ ```bash
96
+ pip install setfit
97
+ ```
98
+
99
+ Then you can load this model and run inference.
100
+
101
+ ```python
102
+ from setfit import SetFitModel
103
+
104
+ # Download from the 🤗 Hub
105
+ model = SetFitModel.from_pretrained("mann2107/BCMPIIRABSentSim")
106
+ # Run inference
107
+ preds = model("The itinerary meets our requirements, please book as proposed.")
108
+ ```
109
+
110
+ <!--
111
+ ### Downstream Use
112
+
113
+ *List how someone could finetune this model on their own dataset.*
114
+ -->
115
+
116
+ <!--
117
+ ### Out-of-Scope Use
118
+
119
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
120
+ -->
121
+
122
+ <!--
123
+ ## Bias, Risks and Limitations
124
+
125
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
126
+ -->
127
+
128
+ <!--
129
+ ### Recommendations
130
+
131
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
132
+ -->
133
+
134
+ ## Training Details
135
+
136
+ ### Training Set Metrics
137
+ | Training set | Min | Median | Max |
138
+ |:-------------|:----|:--------|:----|
139
+ | Word count | 1 | 30.4097 | 124 |
140
+
141
+ | Label | Training Sample Count |
142
+ |:------|:----------------------|
143
+ | 0 | 16 |
144
+ | 1 | 16 |
145
+ | 2 | 16 |
146
+ | 3 | 16 |
147
+ | 4 | 16 |
148
+ | 5 | 16 |
149
+ | 6 | 16 |
150
+ | 7 | 16 |
151
+ | 8 | 16 |
152
+
153
+ ### Training Hyperparameters
154
+ - batch_size: (16, 16)
155
+ - num_epochs: (1, 1)
156
+ - max_steps: -1
157
+ - sampling_strategy: oversampling
158
+ - body_learning_rate: (2e-05, 1e-05)
159
+ - head_learning_rate: 0.01
160
+ - loss: CosineSimilarityLoss
161
+ - distance_metric: cosine_distance
162
+ - margin: 0.25
163
+ - end_to_end: False
164
+ - use_amp: False
165
+ - warmup_proportion: 0.1
166
+ - seed: 42
167
+ - eval_max_steps: -1
168
+ - load_best_model_at_end: True
169
+
170
+ ### Training Results
171
+ | Epoch | Step | Training Loss | Validation Loss |
172
+ |:-------:|:--------:|:-------------:|:---------------:|
173
+ | 0.0009 | 1 | 0.1977 | - |
174
+ | 0.0434 | 50 | 0.1642 | - |
175
+ | 0.0868 | 100 | 0.1034 | - |
176
+ | 0.1302 | 150 | 0.05 | - |
177
+ | 0.1736 | 200 | 0.0177 | - |
178
+ | 0.2170 | 250 | 0.0128 | - |
179
+ | 0.2604 | 300 | 0.0148 | - |
180
+ | 0.3038 | 350 | 0.0109 | - |
181
+ | 0.3472 | 400 | 0.0059 | - |
182
+ | 0.3906 | 450 | 0.004 | - |
183
+ | 0.4340 | 500 | 0.0036 | - |
184
+ | 0.4774 | 550 | 0.0064 | - |
185
+ | 0.5208 | 600 | 0.0042 | - |
186
+ | 0.5642 | 650 | 0.002 | - |
187
+ | 0.6076 | 700 | 0.0017 | - |
188
+ | 0.6510 | 750 | 0.002 | - |
189
+ | 0.6944 | 800 | 0.0026 | - |
190
+ | 0.7378 | 850 | 0.0019 | - |
191
+ | 0.7812 | 900 | 0.0017 | - |
192
+ | 0.8247 | 950 | 0.0017 | - |
193
+ | 0.8681 | 1000 | 0.0015 | - |
194
+ | 0.9115 | 1050 | 0.0009 | - |
195
+ | 0.9549 | 1100 | 0.002 | - |
196
+ | 0.9983 | 1150 | 0.0008 | - |
197
+ | **1.0** | **1152** | **-** | **0.0732** |
198
+
199
+ * The bold row denotes the saved checkpoint.
200
+ ### Framework Versions
201
+ - Python: 3.9.16
202
+ - SetFit: 1.1.0.dev0
203
+ - Sentence Transformers: 2.2.2
204
+ - Transformers: 4.21.3
205
+ - PyTorch: 1.12.1+cu116
206
+ - Datasets: 2.4.0
207
+ - Tokenizers: 0.12.1
208
+
209
+ ## Citation
210
+
211
+ ### BibTeX
212
+ ```bibtex
213
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
214
+ doi = {10.48550/ARXIV.2209.11055},
215
+ url = {https://arxiv.org/abs/2209.11055},
216
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
217
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
218
+ title = {Efficient Few-Shot Learning Without Prompts},
219
+ publisher = {arXiv},
220
+ year = {2022},
221
+ copyright = {Creative Commons Attribution 4.0 International}
222
+ }
223
+ ```
224
+
225
+ <!--
226
+ ## Glossary
227
+
228
+ *Clearly define terms in order to be accessible across audiences.*
229
+ -->
230
+
231
+ <!--
232
+ ## Model Card Authors
233
+
234
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
235
+ -->
236
+
237
+ <!--
238
+ ## Model Card Contact
239
+
240
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
241
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "nreimers/MiniLM-L6-H384-uncased",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "gradient_checkpointing": false,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 384,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 1536,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 6,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "transformers_version": "4.8.2",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 30522
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.6.1",
5
+ "pytorch": "1.8.1"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": null
4
+ }
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15b6a70cdb3099c1bd608127f07be59a61058c34a5fc6bd783bc68339244294e
3
+ size 28683
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
+ ]
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1deccf1340cb988837e82e9637610686c1dbcb189c17e6e3176393972140ad4
3
+ size 90890353
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,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,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "do_basic_tokenize": true,
4
+ "do_lower_case": true,
5
+ "mask_token": "[MASK]",
6
+ "model_max_length": 512,
7
+ "name_or_path": "checkpoints/step_1152/",
8
+ "never_split": null,
9
+ "pad_token": "[PAD]",
10
+ "sep_token": "[SEP]",
11
+ "special_tokens_map_file": "/root/.cache/torch/sentence_transformers/sentence-transformers_all-MiniLM-L6-v2/special_tokens_map.json",
12
+ "strip_accents": null,
13
+ "tokenize_chinese_chars": true,
14
+ "tokenizer_class": "BertTokenizer",
15
+ "unk_token": "[UNK]"
16
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff