luis-espinosa commited on
Commit
2267ac7
1 Parent(s): b0ed8a5

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
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
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: thenlper/gte-small
3
+ library_name: setfit
4
+ metrics:
5
+ - accuracy
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - setfit
9
+ - sentence-transformers
10
+ - text-classification
11
+ - generated_from_setfit_trainer
12
+ widget:
13
+ - text: Walgreens shares suffered their worst monthly decline in nearly five years
14
+ in August . In June, the company cut its full-year guidance to $4 to $4.05, while
15
+ FactSet earnings-per-share consensus is $4.01 . The company has appointed Ginger
16
+ Graham as interim CEO .
17
+ - text: Walgreens CEO Tim Wentworth said he's committed to the company's strategy
18
+ of adding a range of care options atop its massive store network . He said that
19
+ his primary focus for now is to improve the firm's finances across the board .
20
+ The move comes as the holding company faces a tough consumer spending environment
21
+ as well as pressure to rein in costs .
22
+ - text: Walgreens' 'non-drowsy' cough meds are anything but, lawsuit claims $3B project
23
+ with AbilityLab's Detroit outpost breaks ground this spring There's a battle underway
24
+ over medication abortion, the most common method of terminating a pregnancy in
25
+ the US . The Supreme Court is scheduled to hear arguments on March 26 in a case
26
+ that will determine how available mifepristone will be . It would also open the
27
+ door to challenges to other FDA decisions .
28
+ - text: Walgreens' new CEO Tim Wentworth says the pressure is on to develop new drug
29
+ pricing models . In his first earnings call as CEO, Mr.Wentworth said "everything
30
+ is on the table to deliver greater shareholder value" he noted that "the fact
31
+ that there may be some more marketplace pull there only presents a sense of urgency"
32
+ - text: Wentworth will become Walgreens CEO effective Oct. 23 . He is the former CEO
33
+ of Express Scripts, the pharmacy benefit manager acquired by Cigna in 2018 .
34
+ inference: true
35
+ ---
36
+
37
+ # SetFit with thenlper/gte-small
38
+
39
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [thenlper/gte-small](https://huggingface.co/thenlper/gte-small) 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-small](https://huggingface.co/thenlper/gte-small)
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:** 2 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
+ | 1 | <ul><li>'Wentworth will become Walgreens CEO effective Oct. 23 . He is the former CEO of Express Scripts, the pharmacy benefit manager acquired by Cigna in 2018 .'</li><li>'CVS Health announces CFO Shawn Guertin to take leave of absence . Senior Vice President of Corporate Finance, Tom Cowhey, has been appointed interim CFO . CEO of Oak Street Health Mike Pykosz has been named interim President of Health Services .'</li><li>'Walgreens Boots Alliance Inc. appointed Tim Wentworth as its next chief executive officer . The former CEO of pharmacy-benefits manager Express Scripts succeeds Rosalind Brewer, a longtime retail executive whose 2 1/2-year tenure saw the shares lose half their value .'</li></ul> |
68
+ | 0 | <ul><li>"Dove's Milk Chocolate Tiramisu Caramel Promises is debuting a new addition to its Promises line of sweets . Inspired by the Italian dessert, the candy features a tiramisu-flavored caramel center that is surrounded by milk chocolate . The new flavor features fried dough flavored cookies with a churro flavored crème ."</li><li>"Walgreens' 'non-drowsy' cough meds are anything but, lawsuit claims $3B project with AbilityLab's Detroit outpost breaks ground this spring There's a battle underway over medication abortion, the most common method of terminating a pregnancy in the US . The Supreme Court is scheduled to hear arguments on March 26 in a case that will determine how available mifepristone will be . It would also open the door to challenges to other FDA decisions ."</li><li>'CVS Health invests more than $3M to improve health outcomes in Phoenix Terms of use Photo and video available via the CVS health Newsroom are for'</li></ul> |
69
+
70
+ ## Uses
71
+
72
+ ### Direct Use for Inference
73
+
74
+ First install the SetFit library:
75
+
76
+ ```bash
77
+ pip install setfit
78
+ ```
79
+
80
+ Then you can load this model and run inference.
81
+
82
+ ```python
83
+ from setfit import SetFitModel
84
+
85
+ # Download from the 🤗 Hub
86
+ model = SetFitModel.from_pretrained("luis-espinosa/gte-small_lc_summs_setfit")
87
+ # Run inference
88
+ preds = model("Wentworth will become Walgreens CEO effective Oct. 23 . He is the former CEO of Express Scripts, the pharmacy benefit manager acquired by Cigna in 2018 .")
89
+ ```
90
+
91
+ <!--
92
+ ### Downstream Use
93
+
94
+ *List how someone could finetune this model on their own dataset.*
95
+ -->
96
+
97
+ <!--
98
+ ### Out-of-Scope Use
99
+
100
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
101
+ -->
102
+
103
+ <!--
104
+ ## Bias, Risks and Limitations
105
+
106
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
107
+ -->
108
+
109
+ <!--
110
+ ### Recommendations
111
+
112
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
113
+ -->
114
+
115
+ ## Training Details
116
+
117
+ ### Training Set Metrics
118
+ | Training set | Min | Median | Max |
119
+ |:-------------|:----|:--------|:----|
120
+ | Word count | 26 | 52.6190 | 80 |
121
+
122
+ | Label | Training Sample Count |
123
+ |:------|:----------------------|
124
+ | 0 | 11 |
125
+ | 1 | 10 |
126
+
127
+ ### Training Hyperparameters
128
+ - batch_size: (16, 16)
129
+ - num_epochs: (3, 3)
130
+ - max_steps: -1
131
+ - sampling_strategy: oversampling
132
+ - num_iterations: 20
133
+ - body_learning_rate: (2e-05, 2e-05)
134
+ - head_learning_rate: 2e-05
135
+ - loss: CosineSimilarityLoss
136
+ - distance_metric: cosine_distance
137
+ - margin: 0.25
138
+ - end_to_end: False
139
+ - use_amp: False
140
+ - warmup_proportion: 0.1
141
+ - seed: 42
142
+ - eval_max_steps: -1
143
+ - load_best_model_at_end: False
144
+
145
+ ### Training Results
146
+ | Epoch | Step | Training Loss | Validation Loss |
147
+ |:------:|:----:|:-------------:|:---------------:|
148
+ | 0.0189 | 1 | 0.3391 | - |
149
+ | 0.9434 | 50 | 0.0106 | - |
150
+ | 1.8868 | 100 | 0.001 | - |
151
+ | 2.8302 | 150 | 0.0005 | - |
152
+
153
+ ### Framework Versions
154
+ - Python: 3.10.12
155
+ - SetFit: 1.0.3
156
+ - Sentence Transformers: 3.0.1
157
+ - Transformers: 4.41.2
158
+ - PyTorch: 2.3.1+cu121
159
+ - Datasets: 2.19.2
160
+ - Tokenizers: 0.19.1
161
+
162
+ ## Citation
163
+
164
+ ### BibTeX
165
+ ```bibtex
166
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
167
+ doi = {10.48550/ARXIV.2209.11055},
168
+ url = {https://arxiv.org/abs/2209.11055},
169
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
170
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
171
+ title = {Efficient Few-Shot Learning Without Prompts},
172
+ publisher = {arXiv},
173
+ year = {2022},
174
+ copyright = {Creative Commons Attribution 4.0 International}
175
+ }
176
+ ```
177
+
178
+ <!--
179
+ ## Glossary
180
+
181
+ *Clearly define terms in order to be accessible across audiences.*
182
+ -->
183
+
184
+ <!--
185
+ ## Model Card Authors
186
+
187
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
188
+ -->
189
+
190
+ <!--
191
+ ## Model Card Contact
192
+
193
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
194
+ -->
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "thenlper/gte-small",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
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": 12,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "torch_dtype": "float32",
21
+ "transformers_version": "4.41.2",
22
+ "type_vocab_size": 2,
23
+ "use_cache": true,
24
+ "vocab_size": 30522
25
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.0.1",
4
+ "transformers": "4.41.2",
5
+ "pytorch": "2.3.1+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": null
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:396767ad62b6750bd5ab8c4eb2902fff0ac16878a786b8c0d167a4424eb81af6
3
+ size 133462128
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec05ed88d2a4c5f397a26dfac89da5c389dd05bdb67599210e6d192f9819bec4
3
+ size 3935
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,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
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
+ "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_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "max_length": 128,
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_to_multiple_of": null,
53
+ "pad_token": "[PAD]",
54
+ "pad_token_type_id": 0,
55
+ "padding_side": "right",
56
+ "sep_token": "[SEP]",
57
+ "stride": 0,
58
+ "strip_accents": null,
59
+ "tokenize_chinese_chars": true,
60
+ "tokenizer_class": "BertTokenizer",
61
+ "truncation_side": "right",
62
+ "truncation_strategy": "longest_first",
63
+ "unk_token": "[UNK]"
64
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff