jetri20 commited on
Commit
d5fe9ef
1 Parent(s): ce8eae6

Add SetFit ABSA model

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,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - absa
6
+ - sentence-transformers
7
+ - text-classification
8
+ - generated_from_setfit_trainer
9
+ metrics:
10
+ - accuracy
11
+ widget:
12
+ - text: level:game bagus banget sumpah udah nyelesain level 1 sampe level 8 gak sengaja
13
+ kehapus download save level 1 level 2 level 3 sampe level 8 gak save
14
+ - text: update:game nya bagus sih 1 bug error bermain geometry nya meloncat loncat
15
+ tau wi fi potato kasih game robtop 4 bintang semoga update diperbaiki d
16
+ - text: lagu:game nya bgs seru game nya gk susah pake offline cmn 1 kekurangannya
17
+ gk game trs gk ganti lagu jd nya dimatiin lgu dri nya trs pake lagu sekian ulasan
18
+ terima kasih
19
+ - text: kali:game nya seru kali mainin muncul iklan mohon ya iklannya dikurangin yg
20
+ install sabar ya main nya susah
21
+ - text: kekurangannya:game nya bgs seru game nya gk susah pake offline cmn 1 kekurangannya
22
+ gk game trs gk ganti lagu jd nya dimatiin lgu dri nya trs pake lagu sekian ulasan
23
+ terima kasih
24
+ pipeline_tag: text-classification
25
+ inference: false
26
+ ---
27
+
28
+ # SetFit Aspect Model
29
+
30
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Aspect Based Sentiment Analysis (ABSA). A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification. In particular, this model is in charge of filtering aspect span candidates.
31
+
32
+ The model has been trained using an efficient few-shot learning technique that involves:
33
+
34
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
35
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
36
+
37
+ This model was trained within the context of a larger system for ABSA, which looks like so:
38
+
39
+ 1. Use a spaCy model to select possible aspect span candidates.
40
+ 2. **Use this SetFit model to filter these possible aspect span candidates.**
41
+ 3. Use a SetFit model to classify the filtered aspect span candidates.
42
+
43
+ ## Model Details
44
+
45
+ ### Model Description
46
+ - **Model Type:** SetFit
47
+ <!-- - **Sentence Transformer:** [Unknown](https://huggingface.co/unknown) -->
48
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
49
+ - **spaCy Model:** id_core_news_trf
50
+ - **SetFitABSA Aspect Model:** [jetri20/ABSA_review_game_geometry-aspect](https://huggingface.co/jetri20/ABSA_review_game_geometry-aspect)
51
+ - **SetFitABSA Polarity Model:** [jetri20/ABSA_review_game_geometry-polarity](https://huggingface.co/jetri20/ABSA_review_game_geometry-polarity)
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
+ | aspect | <ul><li>'level:sih game level nya sulit banget level clutter funk susah nya ampun level 11 nya level sulit nya level 10 sulit menyerah sabar banting hp saking sulit nya ya geometri dash kebanyakan level nya sulit mah geometri dash game stress saking susah nya'</li><li>'iklan:iklan emang sih level iklan muncul masuk level mending kayak mah'</li><li>'game:game apasih sampe strees gitu final boss level the tower susahnya ampun kenapasih kalo hijau pas udah nya jatuh mati sih cube nya cuman 1 hp ya ngeselin sih'</li></ul> |
68
+ | no aspect | <ul><li>'sih game level:sih game level nya sulit banget level clutter funk susah nya ampun level 11 nya level sulit nya level 10 sulit menyerah sabar banting hp saking sulit nya ya geometri dash kebanyakan level nya sulit mah geometri dash game stress saking susah nya'</li><li>'level clutter funk:sih game level nya sulit banget level clutter funk susah nya ampun level 11 nya level sulit nya level 10 sulit menyerah sabar banting hp saking sulit nya ya geometri dash kebanyakan level nya sulit mah geometri dash game stress saking susah nya'</li><li>'level:sih game level nya sulit banget level clutter funk susah nya ampun level 11 nya level sulit nya level 10 sulit menyerah sabar banting hp saking sulit nya ya geometri dash kebanyakan level nya sulit mah geometri dash game stress saking susah nya'</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 AbsaModel
84
+
85
+ # Download from the 🤗 Hub
86
+ model = AbsaModel.from_pretrained(
87
+ "jetri20/ABSA_review_game_geometry-aspect",
88
+ "jetri20/ABSA_review_game_geometry-polarity",
89
+ )
90
+ # Run inference
91
+ preds = model("The food was great, but the venue is just way too busy.")
92
+ ```
93
+
94
+ <!--
95
+ ### Downstream Use
96
+
97
+ *List how someone could finetune this model on their own dataset.*
98
+ -->
99
+
100
+ <!--
101
+ ### Out-of-Scope Use
102
+
103
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
104
+ -->
105
+
106
+ <!--
107
+ ## Bias, Risks and Limitations
108
+
109
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
110
+ -->
111
+
112
+ <!--
113
+ ### Recommendations
114
+
115
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
116
+ -->
117
+
118
+ ## Training Details
119
+
120
+ ### Training Set Metrics
121
+ | Training set | Min | Median | Max |
122
+ |:-------------|:----|:--------|:----|
123
+ | Word count | 2 | 23.5963 | 67 |
124
+
125
+ | Label | Training Sample Count |
126
+ |:----------|:----------------------|
127
+ | no aspect | 754 |
128
+ | aspect | 321 |
129
+
130
+ ### Training Hyperparameters
131
+ - batch_size: (4, 4)
132
+ - num_epochs: (1, 1)
133
+ - max_steps: -1
134
+ - sampling_strategy: oversampling
135
+ - num_iterations: 5
136
+ - body_learning_rate: (2e-05, 1e-05)
137
+ - head_learning_rate: 0.01
138
+ - loss: CosineSimilarityLoss
139
+ - distance_metric: cosine_distance
140
+ - margin: 0.25
141
+ - end_to_end: False
142
+ - use_amp: False
143
+ - warmup_proportion: 0.1
144
+ - seed: 42
145
+ - eval_max_steps: -1
146
+ - load_best_model_at_end: False
147
+
148
+ ### Training Results
149
+ | Epoch | Step | Training Loss | Validation Loss |
150
+ |:------:|:----:|:-------------:|:---------------:|
151
+ | 0.0004 | 1 | 0.3713 | - |
152
+ | 0.0186 | 50 | 0.2045 | - |
153
+ | 0.0372 | 100 | 0.1548 | - |
154
+ | 0.0558 | 150 | 0.3116 | - |
155
+ | 0.0744 | 200 | 0.2066 | - |
156
+ | 0.0930 | 250 | 0.2932 | - |
157
+ | 0.1116 | 300 | 0.3138 | - |
158
+ | 0.1302 | 350 | 0.1258 | - |
159
+ | 0.1488 | 400 | 0.3442 | - |
160
+ | 0.1674 | 450 | 0.0558 | - |
161
+ | 0.1860 | 500 | 0.2819 | - |
162
+ | 0.2046 | 550 | 0.2211 | - |
163
+ | 0.2232 | 600 | 0.1269 | - |
164
+ | 0.2418 | 650 | 0.0098 | - |
165
+ | 0.2604 | 700 | 0.2395 | - |
166
+ | 0.2790 | 750 | 0.4382 | - |
167
+ | 0.2976 | 800 | 0.488 | - |
168
+ | 0.3162 | 850 | 0.6662 | - |
169
+ | 0.3348 | 900 | 0.1811 | - |
170
+ | 0.3534 | 950 | 0.2431 | - |
171
+ | 0.3720 | 1000 | 0.2032 | - |
172
+ | 0.3906 | 1050 | 0.0475 | - |
173
+ | 0.4092 | 1100 | 0.177 | - |
174
+ | 0.4278 | 1150 | 0.0556 | - |
175
+ | 0.4464 | 1200 | 0.3048 | - |
176
+ | 0.4650 | 1250 | 0.0015 | - |
177
+ | 0.4836 | 1300 | 0.0841 | - |
178
+ | 0.5022 | 1350 | 0.0105 | - |
179
+ | 0.5208 | 1400 | 0.0036 | - |
180
+ | 0.5394 | 1450 | 0.2296 | - |
181
+ | 0.5580 | 1500 | 0.0045 | - |
182
+ | 0.5766 | 1550 | 0.0134 | - |
183
+ | 0.5952 | 1600 | 0.0367 | - |
184
+ | 0.6138 | 1650 | 0.0044 | - |
185
+ | 0.6324 | 1700 | 0.0068 | - |
186
+ | 0.6510 | 1750 | 0.1408 | - |
187
+ | 0.6696 | 1800 | 0.0092 | - |
188
+ | 0.6882 | 1850 | 0.1926 | - |
189
+ | 0.7068 | 1900 | 0.0014 | - |
190
+ | 0.7254 | 1950 | 0.0003 | - |
191
+ | 0.7440 | 2000 | 0.2094 | - |
192
+ | 0.7626 | 2050 | 0.0329 | - |
193
+ | 0.7812 | 2100 | 0.0028 | - |
194
+ | 0.7999 | 2150 | 0.0144 | - |
195
+ | 0.8185 | 2200 | 0.1555 | - |
196
+ | 0.8371 | 2250 | 0.0005 | - |
197
+ | 0.8557 | 2300 | 0.0067 | - |
198
+ | 0.8743 | 2350 | 0.1485 | - |
199
+ | 0.8929 | 2400 | 0.0034 | - |
200
+ | 0.9115 | 2450 | 0.0044 | - |
201
+ | 0.9301 | 2500 | 0.2752 | - |
202
+ | 0.9487 | 2550 | 0.1342 | - |
203
+ | 0.9673 | 2600 | 0.0108 | - |
204
+ | 0.9859 | 2650 | 0.0106 | - |
205
+ | 1.0 | 2688 | - | 0.2236 |
206
+
207
+ ### Framework Versions
208
+ - Python: 3.10.13
209
+ - SetFit: 1.0.3
210
+ - Sentence Transformers: 3.0.1
211
+ - spaCy: 3.7.5
212
+ - Transformers: 4.36.2
213
+ - PyTorch: 2.1.2
214
+ - Datasets: 2.19.2
215
+ - Tokenizers: 0.15.2
216
+
217
+ ## Citation
218
+
219
+ ### BibTeX
220
+ ```bibtex
221
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
222
+ doi = {10.48550/ARXIV.2209.11055},
223
+ url = {https://arxiv.org/abs/2209.11055},
224
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
225
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
226
+ title = {Efficient Few-Shot Learning Without Prompts},
227
+ publisher = {arXiv},
228
+ year = {2022},
229
+ copyright = {Creative Commons Attribution 4.0 International}
230
+ }
231
+ ```
232
+
233
+ <!--
234
+ ## Glossary
235
+
236
+ *Clearly define terms in order to be accessible across audiences.*
237
+ -->
238
+
239
+ <!--
240
+ ## Model Card Authors
241
+
242
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
243
+ -->
244
+
245
+ <!--
246
+ ## Model Card Contact
247
+
248
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
249
+ -->
config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "firqaaa/indo-setfit-absa-bert-base-restaurants-aspect",
3
+ "_num_labels": 5,
4
+ "architectures": [
5
+ "BertModel"
6
+ ],
7
+ "attention_probs_dropout_prob": 0.1,
8
+ "classifier_dropout": null,
9
+ "directionality": "bidi",
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "LABEL_0",
15
+ "1": "LABEL_1",
16
+ "2": "LABEL_2",
17
+ "3": "LABEL_3",
18
+ "4": "LABEL_4"
19
+ },
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 3072,
22
+ "label2id": {
23
+ "LABEL_0": 0,
24
+ "LABEL_1": 1,
25
+ "LABEL_2": 2,
26
+ "LABEL_3": 3,
27
+ "LABEL_4": 4
28
+ },
29
+ "layer_norm_eps": 1e-12,
30
+ "max_position_embeddings": 512,
31
+ "model_type": "bert",
32
+ "num_attention_heads": 12,
33
+ "num_hidden_layers": 12,
34
+ "output_past": true,
35
+ "pad_token_id": 0,
36
+ "pooler_fc_size": 768,
37
+ "pooler_num_attention_heads": 12,
38
+ "pooler_num_fc_layers": 3,
39
+ "pooler_size_per_head": 128,
40
+ "pooler_type": "first_token_transform",
41
+ "position_embedding_type": "absolute",
42
+ "torch_dtype": "float32",
43
+ "transformers_version": "4.36.2",
44
+ "type_vocab_size": 2,
45
+ "use_cache": true,
46
+ "vocab_size": 50000
47
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.0.1",
4
+ "transformers": "4.36.2",
5
+ "pytorch": "2.1.2"
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": "id_core_news_trf",
8
+ "normalize_embeddings": false
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b89ea466602ba0f5c2c11074cd4475b749d3b3cf42d39a6c16d515df28e11d4
3
+ size 497787752
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5de6040ed919d10d03acb453e580f233eb9923b6cc853a823b8fc1769f93274
3
+ size 6991
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": 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
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
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": 512,
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