MattiaTintori commited on
Commit
dd15cb3
·
verified ·
1 Parent(s): 074f519

Push model using huggingface_hub.

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
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
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: sentence-transformers/all-mpnet-base-v2
3
+ library_name: setfit
4
+ metrics:
5
+ - f1
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - setfit
9
+ - absa
10
+ - sentence-transformers
11
+ - text-classification
12
+ - generated_from_setfit_trainer
13
+ widget:
14
+ - text: The ambience is very calm and quiet:The ambience is very calm and quiet.
15
+ - text: For great chinese food nearby, you have Wu:For great chinese food nearby,
16
+ you have Wu Liang Ye and Grand Sichuan just a block away.
17
+ - text: The menu choices are similar but the taste:The menu choices are similar but
18
+ the taste lacked more flavor than it looked.
19
+ - text: The food was authentic.:The food was authentic.
20
+ - text: prompt to jump behind the bar and fix drinks, they:The staff is very kind
21
+ and well trained, they're fast, they are always prompt to jump behind the bar
22
+ and fix drinks, they know details of every item in the menu and make excelent
23
+ recomendations.
24
+ inference: false
25
+ model-index:
26
+ - name: SetFit Polarity Model with sentence-transformers/all-mpnet-base-v2
27
+ results:
28
+ - task:
29
+ type: text-classification
30
+ name: Text Classification
31
+ dataset:
32
+ name: Unknown
33
+ type: unknown
34
+ split: test
35
+ metrics:
36
+ - type: f1
37
+ value: 0.8170404156194555
38
+ name: F1
39
+ ---
40
+
41
+ # SetFit Polarity Model with sentence-transformers/all-mpnet-base-v2
42
+
43
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Aspect Based Sentiment Analysis (ABSA). This SetFit model uses [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) as the Sentence Transformer embedding model. A [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance is used for classification. In particular, this model is in charge of classifying aspect polarities.
44
+
45
+ The model has been trained using an efficient few-shot learning technique that involves:
46
+
47
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
48
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
49
+
50
+ This model was trained within the context of a larger system for ABSA, which looks like so:
51
+
52
+ 1. Use a spaCy model to select possible aspect span candidates.
53
+ 2. Use a SetFit model to filter these possible aspect span candidates.
54
+ 3. **Use this SetFit model to classify the filtered aspect span candidates.**
55
+
56
+ ## Model Details
57
+
58
+ ### Model Description
59
+ - **Model Type:** SetFit
60
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
61
+ - **Classification head:** a [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance
62
+ - **spaCy Model:** en_core_web_trf
63
+ - **SetFitABSA Aspect Model:** [setfit-absa-aspect](https://huggingface.co/setfit-absa-aspect)
64
+ - **SetFitABSA Polarity Model:** [MattiaTintori/Final_polarity_Colab](https://huggingface.co/MattiaTintori/Final_polarity_Colab)
65
+ - **Maximum Sequence Length:** 384 tokens
66
+ - **Number of Classes:** 3 classes
67
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
68
+ <!-- - **Language:** Unknown -->
69
+ <!-- - **License:** Unknown -->
70
+
71
+ ### Model Sources
72
+
73
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
74
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
75
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
76
+
77
+ ### Model Labels
78
+ | Label | Examples |
79
+ |:------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
80
+ | 1 | <ul><li>'waiter) We got no cheese offered for the pasta,:(food was delivered by a busboy, not waiter) We got no cheese offered for the pasta, our water and wine glasses remained EMPTY our entire meal, when we would have easily spent another $20 on wine.'</li><li>'by a busboy, not waiter) We got no cheese:(food was delivered by a busboy, not waiter) We got no cheese offered for the pasta, our water and wine glasses remained EMPTY our entire meal, when we would have easily spent another $20 on wine.'</li><li>'for the pasta, our water and wine glasses remained EMPTY our entire meal:(food was delivered by a busboy, not waiter) We got no cheese offered for the pasta, our water and wine glasses remained EMPTY our entire meal, when we would have easily spent another $20 on wine.'</li></ul> |
81
+ | 2 | <ul><li>'(food was delivered by a busboy:(food was delivered by a busboy, not waiter) We got no cheese offered for the pasta, our water and wine glasses remained EMPTY our entire meal, when we would have easily spent another $20 on wine.'</li><li>'glasses remained EMPTY our entire meal, when we would have:(food was delivered by a busboy, not waiter) We got no cheese offered for the pasta, our water and wine glasses remained EMPTY our entire meal, when we would have easily spent another $20 on wine.'</li><li>'spent another $20 on wine.:(food was delivered by a busboy, not waiter) We got no cheese offered for the pasta, our water and wine glasses remained EMPTY our entire meal, when we would have easily spent another $20 on wine.'</li></ul> |
82
+ | 0 | <ul><li>'few cocktails and enjoy our surroundings and each other.:20 minutes for our reservation but it gave us time to have a few cocktails and enjoy our surroundings and each other.'</li><li>'Barbecued codfish was gorgeously moist - as:Barbecued codfish was gorgeously moist - as if poached - yet the fabulous texture was let down by curiously bland seasoning - a spice rub might have overwhelmed, however herb mix or other sauce would have done much to enhance.'</li><li>'Even though its good seafood, the prices are too:Even though its good seafood, the prices are too high.'</li></ul> |
83
+
84
+ ## Evaluation
85
+
86
+ ### Metrics
87
+ | Label | F1 |
88
+ |:--------|:-------|
89
+ | **all** | 0.8170 |
90
+
91
+ ## Uses
92
+
93
+ ### Direct Use for Inference
94
+
95
+ First install the SetFit library:
96
+
97
+ ```bash
98
+ pip install setfit
99
+ ```
100
+
101
+ Then you can load this model and run inference.
102
+
103
+ ```python
104
+ from setfit import AbsaModel
105
+
106
+ # Download from the 🤗 Hub
107
+ model = AbsaModel.from_pretrained(
108
+ "setfit-absa-aspect",
109
+ "MattiaTintori/Final_polarity_Colab",
110
+ )
111
+ # Run inference
112
+ preds = model("The food was great, but the venue is just way too busy.")
113
+ ```
114
+
115
+ <!--
116
+ ### Downstream Use
117
+
118
+ *List how someone could finetune this model on their own dataset.*
119
+ -->
120
+
121
+ <!--
122
+ ### Out-of-Scope Use
123
+
124
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
125
+ -->
126
+
127
+ <!--
128
+ ## Bias, Risks and Limitations
129
+
130
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
131
+ -->
132
+
133
+ <!--
134
+ ### Recommendations
135
+
136
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
137
+ -->
138
+
139
+ ## Training Details
140
+
141
+ ### Training Set Metrics
142
+ | Training set | Min | Median | Max |
143
+ |:-------------|:----|:--------|:----|
144
+ | Word count | 1 | 25.0463 | 79 |
145
+
146
+ | Label | Training Sample Count |
147
+ |:------|:----------------------|
148
+ | 0 | 1148 |
149
+ | 1 | 607 |
150
+ | 2 | 489 |
151
+
152
+ ### Training Hyperparameters
153
+ - batch_size: (64, 4)
154
+ - num_epochs: (5, 32)
155
+ - max_steps: -1
156
+ - sampling_strategy: oversampling
157
+ - num_iterations: 10
158
+ - body_learning_rate: (5e-05, 5e-05)
159
+ - head_learning_rate: 0.04
160
+ - loss: CosineSimilarityLoss
161
+ - distance_metric: cosine_distance
162
+ - margin: 0.25
163
+ - end_to_end: False
164
+ - use_amp: True
165
+ - warmup_proportion: 0.1
166
+ - l2_weight: 0.01
167
+ - seed: 42
168
+ - eval_max_steps: -1
169
+ - load_best_model_at_end: True
170
+
171
+ ### Training Results
172
+ | Epoch | Step | Training Loss | Validation Loss |
173
+ |:----------:|:-------:|:-------------:|:---------------:|
174
+ | 0.0014 | 1 | 0.3084 | - |
175
+ | 0.0285 | 20 | 0.2735 | 0.2591 |
176
+ | 0.0570 | 40 | 0.2228 | 0.2351 |
177
+ | 0.0855 | 60 | 0.2071 | 0.1993 |
178
+ | 0.1140 | 80 | 0.1522 | 0.1696 |
179
+ | 0.1425 | 100 | 0.1441 | 0.1671 |
180
+ | 0.1709 | 120 | 0.1632 | 0.161 |
181
+ | 0.1994 | 140 | 0.0966 | 0.1575 |
182
+ | 0.2279 | 160 | 0.1737 | 0.1504 |
183
+ | 0.2564 | 180 | 0.1092 | 0.1671 |
184
+ | 0.2849 | 200 | 0.1314 | 0.1459 |
185
+ | 0.3134 | 220 | 0.0972 | 0.1483 |
186
+ | 0.3419 | 240 | 0.1014 | 0.1537 |
187
+ | 0.3704 | 260 | 0.0506 | 0.1514 |
188
+ | **0.3989** | **280** | **0.0817** | **0.143** |
189
+ | 0.4274 | 300 | 0.0592 | 0.1526 |
190
+ | 0.4558 | 320 | 0.0311 | 0.1562 |
191
+ | 0.4843 | 340 | 0.038 | 0.1546 |
192
+ | 0.5128 | 360 | 0.0852 | 0.1497 |
193
+ | 0.5413 | 380 | 0.0359 | 0.144 |
194
+ | 0.5698 | 400 | 0.0449 | 0.1639 |
195
+ | 0.5983 | 420 | 0.0314 | 0.1517 |
196
+
197
+ * The bold row denotes the saved checkpoint.
198
+ ### Framework Versions
199
+ - Python: 3.10.12
200
+ - SetFit: 1.0.3
201
+ - Sentence Transformers: 3.0.1
202
+ - spaCy: 3.7.6
203
+ - Transformers: 4.39.0
204
+ - PyTorch: 2.4.0+cu121
205
+ - Datasets: 2.21.0
206
+ - Tokenizers: 0.15.2
207
+
208
+ ## Citation
209
+
210
+ ### BibTeX
211
+ ```bibtex
212
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
213
+ doi = {10.48550/ARXIV.2209.11055},
214
+ url = {https://arxiv.org/abs/2209.11055},
215
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
216
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
217
+ title = {Efficient Few-Shot Learning Without Prompts},
218
+ publisher = {arXiv},
219
+ year = {2022},
220
+ copyright = {Creative Commons Attribution 4.0 International}
221
+ }
222
+ ```
223
+
224
+ <!--
225
+ ## Glossary
226
+
227
+ *Clearly define terms in order to be accessible across audiences.*
228
+ -->
229
+
230
+ <!--
231
+ ## Model Card Authors
232
+
233
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
234
+ -->
235
+
236
+ <!--
237
+ ## Model Card Contact
238
+
239
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
240
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "checkpoints/step_280",
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.39.0",
23
+ "vocab_size": 30527
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.0.1",
4
+ "transformers": "4.39.0",
5
+ "pytorch": "2.4.0+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "labels": null,
3
+ "span_context": 5,
4
+ "normalize_embeddings": true,
5
+ "spacy_model": "en_core_web_trf"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a2128d6e9d5ff1127d5de640f2a32fe2f811f6f36bae83cf06cc1b116085c59
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57306dc9ec058760839f6b32a369873eeaec2deede3a45b680b750cd39d5f922
3
+ size 13847
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": 384,
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,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "104": {
36
+ "content": "[UNK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "30526": {
44
+ "content": "<mask>",
45
+ "lstrip": true,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ }
51
+ },
52
+ "bos_token": "<s>",
53
+ "clean_up_tokenization_spaces": true,
54
+ "cls_token": "<s>",
55
+ "do_lower_case": true,
56
+ "eos_token": "</s>",
57
+ "mask_token": "<mask>",
58
+ "max_length": 128,
59
+ "model_max_length": 384,
60
+ "pad_to_multiple_of": null,
61
+ "pad_token": "<pad>",
62
+ "pad_token_type_id": 0,
63
+ "padding_side": "right",
64
+ "sep_token": "</s>",
65
+ "stride": 0,
66
+ "strip_accents": null,
67
+ "tokenize_chinese_chars": true,
68
+ "tokenizer_class": "MPNetTokenizer",
69
+ "truncation_side": "right",
70
+ "truncation_strategy": "longest_first",
71
+ "unk_token": "[UNK]"
72
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff