MattiaTintori commited on
Commit
5d04b42
1 Parent(s): a52a297

Push model using huggingface_hub.

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
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,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: sentence-transformers/paraphrase-multilingual-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: Locale:Locale molto bene arredato, con stile e atmosfera tipica valtellinese.
15
+ Cucina ottima, dal bastone di carne al pesce, dai pizzoccheri agli gnocchetti,
16
+ dal vino ai dolci, tutto perfetto e soprattutto di grande qualità... Filippo
17
+ poi è un’autentica forza della natura, molto simpatico, cordiale e amichevole,...Altro
18
+ - text: cucina:Locale accogliente e familiare...bravissima la ragazza in cucina, come
19
+ le ragazze al banco e in sala! CONSIGLIATO
20
+ - text: servizio:Il servizio era impeccabile e il tortello di zucca era sublime.
21
+ - text: cucina:Il ristorante propone piatti vegetariani che NON sono vegetariani.
22
+ Dopo aver specificato al servizio la nostra etica alimentare, ci è stata consigliata
23
+ una portata che durante la consumazione abbiamo constatato con amarezza che avesse
24
+ parti di maiale come ingredienti (confermato dalla cucina). Poco valgono le...scuse
25
+ del servizio, trovo assurdo e inconcepibile che situazioni del genere possano
26
+ accadere nel 2024. Evidentemente questo è indice della poca professionalità di
27
+ questo ristorante.Altro
28
+ - text: servizio:La polenta con formaggio era saporita, ma il servizio è stato lento.
29
+ inference: false
30
+ model-index:
31
+ - name: SetFit Aspect Model with sentence-transformers/paraphrase-multilingual-mpnet-base-v2
32
+ results:
33
+ - task:
34
+ type: text-classification
35
+ name: Text Classification
36
+ dataset:
37
+ name: Unknown
38
+ type: unknown
39
+ split: test
40
+ metrics:
41
+ - type: f1
42
+ value: 0.8096514745308312
43
+ name: F1
44
+ ---
45
+
46
+ # SetFit Aspect Model with sentence-transformers/paraphrase-multilingual-mpnet-base-v2
47
+
48
+ 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/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-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 filtering aspect span candidates.
49
+
50
+ The model has been trained using an efficient few-shot learning technique that involves:
51
+
52
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
53
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
54
+
55
+ This model was trained within the context of a larger system for ABSA, which looks like so:
56
+
57
+ 1. Use a spaCy model to select possible aspect span candidates.
58
+ 2. **Use this SetFit model to filter these possible aspect span candidates.**
59
+ 3. Use a SetFit model to classify the filtered aspect span candidates.
60
+
61
+ ## Model Details
62
+
63
+ ### Model Description
64
+ - **Model Type:** SetFit
65
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2)
66
+ - **Classification head:** a [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance
67
+ - **spaCy Model:** it_core_news_lg
68
+ - **SetFitABSA Aspect Model:** [MattiaTintori/Final_aspect_Colab_It](https://huggingface.co/MattiaTintori/Final_aspect_Colab_It)
69
+ - **SetFitABSA Polarity Model:** [setfit-absa-polarity](https://huggingface.co/setfit-absa-polarity)
70
+ - **Maximum Sequence Length:** 128 tokens
71
+ - **Number of Classes:** 2 classes
72
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
73
+ <!-- - **Language:** Unknown -->
74
+ <!-- - **License:** Unknown -->
75
+
76
+ ### Model Sources
77
+
78
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
79
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
80
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
81
+
82
+ ### Model Labels
83
+ | Label | Examples |
84
+ |:----------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
85
+ | aspect | <ul><li>"tavolo:Purtroppo tutte le volte, ed è anni, che tento di prenotare non sono mai stato fortunato........devo dirvi che ora ho un po' perso la poesia!!!!!! O aggiungono tavoli o cambiano location......mai fatta cosi tanta fatica per trovare un tavolo!!!!! Non so francamente se comporro' ancora...Altro"</li><li>'spesa:Devo premettere che sono sempre stato ospite e non so la spesa.Da quanto posso intuire la carne la fa da padrona ed essendo io ve non posso giudicare.Per me trovo sempre cose piacevoli come antipasti a buffet,primi veg riso alle verdure, trofie al pesto patate...Altro'</li><li>'carne:Devo premettere che sono sempre stato ospite e non so la spesa.Da quanto posso intuire la carne la fa da padrona ed essendo io ve non posso giudicare.Per me trovo sempre cose piacevoli come antipasti a buffet,primi veg riso alle verdure, trofie al pesto patate...Altro'</li></ul> |
86
+ | no aspect | <ul><li>"volte:Purtroppo tutte le volte, ed è anni, che tento di prenotare non sono mai stato fortunato........devo dirvi che ora ho un po' perso la poesia!!!!!! O aggiungono tavoli o cambiano location......mai fatta cosi tanta fatica per trovare un tavolo!!!!! Non so francamente se comporro' ancora...Altro"</li><li>"anni:Purtroppo tutte le volte, ed è anni, che tento di prenotare non sono mai stato fortunato........devo dirvi che ora ho un po' perso la poesia!!!!!! O aggiungono tavoli o cambiano location......mai fatta cosi tanta fatica per trovare un tavolo!!!!! Non so francamente se comporro' ancora...Altro"</li><li>"poesia:Purtroppo tutte le volte, ed è anni, che tento di prenotare non sono mai stato fortunato........devo dirvi che ora ho un po' perso la poesia!!!!!! O aggiungono tavoli o cambiano location......mai fatta cosi tanta fatica per trovare un tavolo!!!!! Non so francamente se comporro' ancora...Altro"</li></ul> |
87
+
88
+ ## Evaluation
89
+
90
+ ### Metrics
91
+ | Label | F1 |
92
+ |:--------|:-------|
93
+ | **all** | 0.8097 |
94
+
95
+ ## Uses
96
+
97
+ ### Direct Use for Inference
98
+
99
+ First install the SetFit library:
100
+
101
+ ```bash
102
+ pip install setfit
103
+ ```
104
+
105
+ Then you can load this model and run inference.
106
+
107
+ ```python
108
+ from setfit import AbsaModel
109
+
110
+ # Download from the 🤗 Hub
111
+ model = AbsaModel.from_pretrained(
112
+ "MattiaTintori/Final_aspect_Colab_It",
113
+ "setfit-absa-polarity",
114
+ )
115
+ # Run inference
116
+ preds = model("The food was great, but the venue is just way too busy.")
117
+ ```
118
+
119
+ <!--
120
+ ### Downstream Use
121
+
122
+ *List how someone could finetune this model on their own dataset.*
123
+ -->
124
+
125
+ <!--
126
+ ### Out-of-Scope Use
127
+
128
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
129
+ -->
130
+
131
+ <!--
132
+ ## Bias, Risks and Limitations
133
+
134
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
135
+ -->
136
+
137
+ <!--
138
+ ### Recommendations
139
+
140
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
141
+ -->
142
+
143
+ ## Training Details
144
+
145
+ ### Training Set Metrics
146
+ | Training set | Min | Median | Max |
147
+ |:-------------|:----|:--------|:----|
148
+ | Word count | 9 | 40.3192 | 137 |
149
+
150
+ | Label | Training Sample Count |
151
+ |:----------|:----------------------|
152
+ | no aspect | 1379 |
153
+ | aspect | 1378 |
154
+
155
+ ### Training Hyperparameters
156
+ - batch_size: (128, 32)
157
+ - num_epochs: (5, 32)
158
+ - max_steps: -1
159
+ - sampling_strategy: oversampling
160
+ - num_iterations: 10
161
+ - body_learning_rate: (5e-05, 5e-05)
162
+ - head_learning_rate: 0.01
163
+ - loss: CosineSimilarityLoss
164
+ - distance_metric: cosine_distance
165
+ - margin: 0.25
166
+ - end_to_end: False
167
+ - use_amp: True
168
+ - warmup_proportion: 0.1
169
+ - l2_weight: 0.02
170
+ - seed: 42
171
+ - eval_max_steps: -1
172
+ - load_best_model_at_end: True
173
+
174
+ ### Training Results
175
+ | Epoch | Step | Training Loss | Validation Loss |
176
+ |:----------:|:-------:|:-------------:|:---------------:|
177
+ | 0.0023 | 1 | 0.2484 | - |
178
+ | 0.0464 | 20 | 0.2718 | 0.259 |
179
+ | 0.0928 | 40 | 0.2581 | 0.2544 |
180
+ | 0.1392 | 60 | 0.2266 | 0.2475 |
181
+ | 0.1856 | 80 | 0.233 | 0.2298 |
182
+ | 0.2320 | 100 | 0.2104 | 0.2145 |
183
+ | **0.2784** | **120** | **0.1487** | **0.2106** |
184
+ | 0.3248 | 140 | 0.1615 | 0.2314 |
185
+ | 0.3712 | 160 | 0.1328 | 0.2164 |
186
+ | 0.4176 | 180 | 0.0905 | 0.2164 |
187
+ | 0.4640 | 200 | 0.0934 | 0.2517 |
188
+ | 0.5104 | 220 | 0.0942 | 0.2185 |
189
+ | 0.5568 | 240 | 0.0774 | 0.2469 |
190
+ | 0.6032 | 260 | 0.1013 | 0.2248 |
191
+ | 0.6497 | 280 | 0.0781 | 0.2221 |
192
+ | 0.6961 | 300 | 0.0386 | 0.2362 |
193
+ | 0.7425 | 320 | 0.084 | 0.2386 |
194
+
195
+ * The bold row denotes the saved checkpoint.
196
+ ### Framework Versions
197
+ - Python: 3.10.12
198
+ - SetFit: 1.0.3
199
+ - Sentence Transformers: 3.1.0
200
+ - spaCy: 3.7.6
201
+ - Transformers: 4.39.0
202
+ - PyTorch: 2.4.0+cu121
203
+ - Datasets: 3.0.0
204
+ - Tokenizers: 0.15.2
205
+
206
+ ## Citation
207
+
208
+ ### BibTeX
209
+ ```bibtex
210
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
211
+ doi = {10.48550/ARXIV.2209.11055},
212
+ url = {https://arxiv.org/abs/2209.11055},
213
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
214
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
215
+ title = {Efficient Few-Shot Learning Without Prompts},
216
+ publisher = {arXiv},
217
+ year = {2022},
218
+ copyright = {Creative Commons Attribution 4.0 International}
219
+ }
220
+ ```
221
+
222
+ <!--
223
+ ## Glossary
224
+
225
+ *Clearly define terms in order to be accessible across audiences.*
226
+ -->
227
+
228
+ <!--
229
+ ## Model Card Authors
230
+
231
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
232
+ -->
233
+
234
+ <!--
235
+ ## Model Card Contact
236
+
237
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
238
+ -->
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "checkpoints/step_120",
3
+ "architectures": [
4
+ "XLMRobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 514,
18
+ "model_type": "xlm-roberta",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 12,
21
+ "output_past": true,
22
+ "pad_token_id": 1,
23
+ "position_embedding_type": "absolute",
24
+ "torch_dtype": "float32",
25
+ "transformers_version": "4.39.0",
26
+ "type_vocab_size": 1,
27
+ "use_cache": true,
28
+ "vocab_size": 250002
29
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.1.0",
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,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "no aspect",
4
+ "aspect"
5
+ ],
6
+ "span_context": 0,
7
+ "spacy_model": "it_core_news_lg",
8
+ "normalize_embeddings": true
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50d7562656c94f845bd0e3d3ab4a6af2d18afe0121ad2f04476ba9892831296c
3
+ size 1112197096
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ca6599d277cbdd7a1a332c4e3ae54464d35b4e31b449a85cef84a7cde9203a9
3
+ size 7706
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": 128,
3
+ "do_lower_case": false
4
+ }
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
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
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa685fc160bbdbab64058d4fc91b60e62d207e8dc60b9af5c002c5ab946ded00
3
+ size 17083009
tokenizer_config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
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
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "max_length": 128,
50
+ "model_max_length": 128,
51
+ "pad_to_multiple_of": null,
52
+ "pad_token": "<pad>",
53
+ "pad_token_type_id": 0,
54
+ "padding_side": "right",
55
+ "sep_token": "</s>",
56
+ "stride": 0,
57
+ "tokenizer_class": "XLMRobertaTokenizer",
58
+ "truncation_side": "right",
59
+ "truncation_strategy": "longest_first",
60
+ "unk_token": "<unk>"
61
+ }