MattiaTintori commited on
Commit
eb0b13a
1 Parent(s): 901604c

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,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: bargain:Monday nights are a bargain at the $28 prix fix - this includes a
15
+ three course meal plus *three* glasses of wine paired with each course.
16
+ - text: seated:We walked in on a Wednesday night and were seated promptly.
17
+ - text: drinks:While most people can attest to spending over $50 on drinks in New
18
+ York bars and hardly feeling a thing, the drinks here are plentiful and unique.
19
+ - text: Lassi:I ordered a Lassi and asked 4 times for it but never got it.
20
+ - text: stomach:Check it out, it won't hurt your stomach or your wallet.
21
+ inference: false
22
+ model-index:
23
+ - name: SetFit Aspect Model with sentence-transformers/all-mpnet-base-v2
24
+ results:
25
+ - task:
26
+ type: text-classification
27
+ name: Text Classification
28
+ dataset:
29
+ name: Unknown
30
+ type: unknown
31
+ split: test
32
+ metrics:
33
+ - type: f1
34
+ value: 0.923076923076923
35
+ name: F1
36
+ ---
37
+
38
+ # SetFit Aspect Model with sentence-transformers/all-mpnet-base-v2
39
+
40
+ 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 filtering aspect span candidates.
41
+
42
+ The model has been trained using an efficient few-shot learning technique that involves:
43
+
44
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
45
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
46
+
47
+ This model was trained within the context of a larger system for ABSA, which looks like so:
48
+
49
+ 1. Use a spaCy model to select possible aspect span candidates.
50
+ 2. **Use this SetFit model to filter these possible aspect span candidates.**
51
+ 3. Use a SetFit model to classify the filtered aspect span candidates.
52
+
53
+ ## Model Details
54
+
55
+ ### Model Description
56
+ - **Model Type:** SetFit
57
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
58
+ - **Classification head:** a [SetFitHead](huggingface.co/docs/setfit/reference/main#setfit.SetFitHead) instance
59
+ - **spaCy Model:** en_core_web_trf
60
+ - **SetFitABSA Aspect Model:** [MattiaTintori/Final_aspect_Colab](https://huggingface.co/MattiaTintori/Final_aspect_Colab)
61
+ - **SetFitABSA Polarity Model:** [setfit-absa-polarity](https://huggingface.co/setfit-absa-polarity)
62
+ - **Maximum Sequence Length:** 384 tokens
63
+ - **Number of Classes:** 2 classes
64
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
65
+ <!-- - **Language:** Unknown -->
66
+ <!-- - **License:** Unknown -->
67
+
68
+ ### Model Sources
69
+
70
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
71
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
72
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
73
+
74
+ ### Model Labels
75
+ | Label | Examples |
76
+ |:----------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
77
+ | aspect | <ul><li>'price:The price is reasonable although the service is poor.'</li><li>'service:The price is reasonable although the service is poor.'</li><li>'service:The place is so cool and the service is prompt and curtious.'</li></ul> |
78
+ | no aspect | <ul><li>'stomach:The food was delicious but do not come here on a empty stomach.'</li><li>'place:I grew up eating Dosa and have yet to find a place in NY to satisfy my taste buds.'</li><li>'NY:I grew up eating Dosa and have yet to find a place in NY to satisfy my taste buds.'</li></ul> |
79
+
80
+ ## Evaluation
81
+
82
+ ### Metrics
83
+ | Label | F1 |
84
+ |:--------|:-------|
85
+ | **all** | 0.9231 |
86
+
87
+ ## Uses
88
+
89
+ ### Direct Use for Inference
90
+
91
+ First install the SetFit library:
92
+
93
+ ```bash
94
+ pip install setfit
95
+ ```
96
+
97
+ Then you can load this model and run inference.
98
+
99
+ ```python
100
+ from setfit import AbsaModel
101
+
102
+ # Download from the 🤗 Hub
103
+ model = AbsaModel.from_pretrained(
104
+ "MattiaTintori/Final_aspect_Colab",
105
+ "setfit-absa-polarity",
106
+ )
107
+ # Run inference
108
+ preds = model("The food was great, but the venue is just way too busy.")
109
+ ```
110
+
111
+ <!--
112
+ ### Downstream Use
113
+
114
+ *List how someone could finetune this model on their own dataset.*
115
+ -->
116
+
117
+ <!--
118
+ ### Out-of-Scope Use
119
+
120
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
121
+ -->
122
+
123
+ <!--
124
+ ## Bias, Risks and Limitations
125
+
126
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
127
+ -->
128
+
129
+ <!--
130
+ ### Recommendations
131
+
132
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
133
+ -->
134
+
135
+ ## Training Details
136
+
137
+ ### Training Set Metrics
138
+ | Training set | Min | Median | Max |
139
+ |:-------------|:----|:--------|:----|
140
+ | Word count | 3 | 19.4137 | 62 |
141
+
142
+ | Label | Training Sample Count |
143
+ |:----------|:----------------------|
144
+ | no aspect | 430 |
145
+ | aspect | 711 |
146
+
147
+ ### Training Hyperparameters
148
+ - batch_size: (64, 4)
149
+ - num_epochs: (5, 32)
150
+ - max_steps: -1
151
+ - sampling_strategy: oversampling
152
+ - num_iterations: 10
153
+ - body_learning_rate: (8e-05, 8e-05)
154
+ - head_learning_rate: 0.04
155
+ - loss: CosineSimilarityLoss
156
+ - distance_metric: cosine_distance
157
+ - margin: 0.25
158
+ - end_to_end: False
159
+ - use_amp: True
160
+ - warmup_proportion: 0.1
161
+ - l2_weight: 0.01
162
+ - seed: 42
163
+ - eval_max_steps: -1
164
+ - load_best_model_at_end: True
165
+
166
+ ### Training Results
167
+ | Epoch | Step | Training Loss | Validation Loss |
168
+ |:----------:|:------:|:-------------:|:---------------:|
169
+ | 0.0028 | 1 | 0.2878 | - |
170
+ | 0.0560 | 20 | 0.2409 | 0.2515 |
171
+ | 0.1120 | 40 | 0.2291 | 0.2319 |
172
+ | 0.1681 | 60 | 0.1354 | 0.1835 |
173
+ | **0.2241** | **80** | **0.0654** | **0.1389** |
174
+ | 0.2801 | 100 | 0.0334 | 0.1818 |
175
+ | 0.3361 | 120 | 0.0535 | 0.1408 |
176
+ | 0.3922 | 140 | 0.014 | 0.1564 |
177
+ | 0.4482 | 160 | 0.0119 | 0.1453 |
178
+ | 0.5042 | 180 | 0.0158 | 0.1511 |
179
+ | 0.5602 | 200 | 0.0157 | 0.1393 |
180
+ | 0.6162 | 220 | 0.005 | 0.1536 |
181
+ | 0.6723 | 240 | 0.0002 | 0.1546 |
182
+ | 0.7283 | 260 | 0.0002 | 0.1673 |
183
+ | 0.7843 | 280 | 0.0004 | 0.1655 |
184
+
185
+ * The bold row denotes the saved checkpoint.
186
+ ### Framework Versions
187
+ - Python: 3.10.12
188
+ - SetFit: 1.0.3
189
+ - Sentence Transformers: 3.0.1
190
+ - spaCy: 3.7.6
191
+ - Transformers: 4.39.0
192
+ - PyTorch: 2.3.1+cu121
193
+ - Datasets: 2.21.0
194
+ - Tokenizers: 0.15.2
195
+
196
+ ## Citation
197
+
198
+ ### BibTeX
199
+ ```bibtex
200
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
201
+ doi = {10.48550/ARXIV.2209.11055},
202
+ url = {https://arxiv.org/abs/2209.11055},
203
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
204
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
205
+ title = {Efficient Few-Shot Learning Without Prompts},
206
+ publisher = {arXiv},
207
+ year = {2022},
208
+ copyright = {Creative Commons Attribution 4.0 International}
209
+ }
210
+ ```
211
+
212
+ <!--
213
+ ## Glossary
214
+
215
+ *Clearly define terms in order to be accessible across audiences.*
216
+ -->
217
+
218
+ <!--
219
+ ## Model Card Authors
220
+
221
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
222
+ -->
223
+
224
+ <!--
225
+ ## Model Card Contact
226
+
227
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
228
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "checkpoints/step_80",
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.3.1+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
+ "normalize_embeddings": true,
3
+ "span_context": 0,
4
+ "spacy_model": "en_core_web_trf",
5
+ "labels": [
6
+ "no aspect",
7
+ "aspect"
8
+ ]
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:304273037d570e5959ea60833fa4426a2867bfd0bbf60f59c15c03a82c10d889
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:376e80fe2399b67a3c8df831285467696793c45d3a65552ab38f29d813d327d6
3
+ size 7706
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