ronalhung commited on
Commit
8a110ba
·
verified ·
1 Parent(s): 4695e29

Add SetFit ABSA model

Browse files
1_Pooling/config.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "word_embedding_dimension": 384,
3
  "pooling_mode_cls_token": false,
4
  "pooling_mode_mean_tokens": true,
5
  "pooling_mode_max_tokens": false,
 
1
  {
2
+ "word_embedding_dimension": 768,
3
  "pooling_mode_cls_token": false,
4
  "pooling_mode_mean_tokens": true,
5
  "pooling_mode_max_tokens": false,
README.md CHANGED
@@ -27,9 +27,9 @@ metrics:
27
  pipeline_tag: text-classification
28
  library_name: setfit
29
  inference: false
30
- base_model: sentence-transformers/all-MiniLM-L6-v2
31
  model-index:
32
- - name: SetFit Polarity Model with sentence-transformers/all-MiniLM-L6-v2
33
  results:
34
  - task:
35
  type: text-classification
@@ -40,34 +40,34 @@ model-index:
40
  split: test
41
  metrics:
42
  - type: accuracy
43
- value: 0.6956390066626287
44
  name: Accuracy
45
  - type: f1_micro
46
- value: 0.6956390066626287
47
  name: F1_Micro
48
  - type: f1_macro
49
- value: 0.4329017416100218
50
  name: F1_Macro
51
  - type: f1_weighted
52
- value: 0.6632256738950839
53
  name: F1_Weighted
54
  - type: precision_micro
55
- value: 0.6956390066626287
56
  name: Precision_Micro
57
  - type: precision_macro
58
- value: 0.45635478257069084
59
  name: Precision_Macro
60
  - type: recall_micro
61
- value: 0.6956390066626287
62
  name: Recall_Micro
63
  - type: recall_macro
64
- value: 0.43398523441592457
65
  name: Recall_Macro
66
  ---
67
 
68
- # SetFit Polarity Model with sentence-transformers/all-MiniLM-L6-v2
69
 
70
- 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-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) 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. In particular, this model is in charge of classifying aspect polarities.
71
 
72
  The model has been trained using an efficient few-shot learning technique that involves:
73
 
@@ -84,12 +84,12 @@ This model was trained within the context of a larger system for ABSA, which loo
84
 
85
  ### Model Description
86
  - **Model Type:** SetFit
87
- - **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
88
  - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
89
- - **spaCy Model:** en_core_web_lg
90
  - **SetFitABSA Aspect Model:** [ronalhung/setfit-absa-restaurants-aspect](https://huggingface.co/ronalhung/setfit-absa-restaurants-aspect)
91
  - **SetFitABSA Polarity Model:** [ronalhung/setfit-absa-restaurants-polarity](https://huggingface.co/ronalhung/setfit-absa-restaurants-polarity)
92
- - **Maximum Sequence Length:** 256 tokens
93
  - **Number of Classes:** 4 classes
94
  <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
95
  <!-- - **Language:** Unknown -->
@@ -114,7 +114,7 @@ This model was trained within the context of a larger system for ABSA, which loo
114
  ### Metrics
115
  | Label | Accuracy | F1_Micro | F1_Macro | F1_Weighted | Precision_Micro | Precision_Macro | Recall_Micro | Recall_Macro |
116
  |:--------|:---------|:---------|:---------|:------------|:----------------|:----------------|:-------------|:-------------|
117
- | **all** | 0.6956 | 0.6956 | 0.4329 | 0.6632 | 0.6956 | 0.4564 | 0.6956 | 0.4340 |
118
 
119
  ## Uses
120
 
@@ -179,7 +179,7 @@ preds = model("The food was great, but the venue is just way too busy.")
179
  | positive | 169 |
180
 
181
  ### Training Hyperparameters
182
- - batch_size: (128, 128)
183
  - num_epochs: (5, 5)
184
  - max_steps: -1
185
  - sampling_strategy: oversampling
@@ -199,14 +199,16 @@ preds = model("The food was great, but the venue is just way too busy.")
199
  ### Training Results
200
  | Epoch | Step | Training Loss | Validation Loss |
201
  |:------:|:----:|:-------------:|:---------------:|
202
- | 0.0039 | 1 | 0.3102 | - |
203
- | 0.1946 | 50 | 0.272 | 0.2236 |
204
- | 0.3891 | 100 | 0.1589 | 0.2166 |
205
- | 0.5837 | 150 | 0.0554 | 0.2199 |
206
- | 0.7782 | 200 | 0.0267 | 0.2241 |
207
- | 0.9728 | 250 | 0.0191 | 0.2276 |
208
- | 1.1673 | 300 | 0.0095 | 0.2284 |
209
- | 1.3619 | 350 | 0.0045 | 0.2320 |
 
 
210
 
211
  ### Framework Versions
212
  - Python: 3.11.13
 
27
  pipeline_tag: text-classification
28
  library_name: setfit
29
  inference: false
30
+ base_model: sentence-transformers/all-mpnet-base-v2
31
  model-index:
32
+ - name: SetFit Polarity Model with sentence-transformers/all-mpnet-base-v2
33
  results:
34
  - task:
35
  type: text-classification
 
40
  split: test
41
  metrics:
42
  - type: accuracy
43
+ value: 0.7401574803149606
44
  name: Accuracy
45
  - type: f1_micro
46
+ value: 0.7401574803149606
47
  name: F1_Micro
48
  - type: f1_macro
49
+ value: 0.49431392855326756
50
  name: F1_Macro
51
  - type: f1_weighted
52
+ value: 0.7257118530125051
53
  name: F1_Weighted
54
  - type: precision_micro
55
+ value: 0.7401574803149606
56
  name: Precision_Micro
57
  - type: precision_macro
58
+ value: 0.493835965235845
59
  name: Precision_Macro
60
  - type: recall_micro
61
+ value: 0.7401574803149606
62
  name: Recall_Micro
63
  - type: recall_macro
64
+ value: 0.5050369958093243
65
  name: Recall_Macro
66
  ---
67
 
68
+ # SetFit Polarity Model with sentence-transformers/all-mpnet-base-v2
69
 
70
+ 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 [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 classifying aspect polarities.
71
 
72
  The model has been trained using an efficient few-shot learning technique that involves:
73
 
 
84
 
85
  ### Model Description
86
  - **Model Type:** SetFit
87
+ - **Sentence Transformer body:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
88
  - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
89
+ - **spaCy Model:** en_core_web_trf
90
  - **SetFitABSA Aspect Model:** [ronalhung/setfit-absa-restaurants-aspect](https://huggingface.co/ronalhung/setfit-absa-restaurants-aspect)
91
  - **SetFitABSA Polarity Model:** [ronalhung/setfit-absa-restaurants-polarity](https://huggingface.co/ronalhung/setfit-absa-restaurants-polarity)
92
+ - **Maximum Sequence Length:** 384 tokens
93
  - **Number of Classes:** 4 classes
94
  <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
95
  <!-- - **Language:** Unknown -->
 
114
  ### Metrics
115
  | Label | Accuracy | F1_Micro | F1_Macro | F1_Weighted | Precision_Micro | Precision_Macro | Recall_Micro | Recall_Macro |
116
  |:--------|:---------|:---------|:---------|:------------|:----------------|:----------------|:-------------|:-------------|
117
+ | **all** | 0.7402 | 0.7402 | 0.4943 | 0.7257 | 0.7402 | 0.4938 | 0.7402 | 0.5050 |
118
 
119
  ## Uses
120
 
 
179
  | positive | 169 |
180
 
181
  ### Training Hyperparameters
182
+ - batch_size: (64, 64)
183
  - num_epochs: (5, 5)
184
  - max_steps: -1
185
  - sampling_strategy: oversampling
 
199
  ### Training Results
200
  | Epoch | Step | Training Loss | Validation Loss |
201
  |:------:|:----:|:-------------:|:---------------:|
202
+ | 0.0019 | 1 | 0.2601 | - |
203
+ | 0.0975 | 50 | 0.2588 | 0.2241 |
204
+ | 0.1949 | 100 | 0.1555 | 0.1764 |
205
+ | 0.2924 | 150 | 0.0436 | 0.1602 |
206
+ | 0.3899 | 200 | 0.0213 | 0.1544 |
207
+ | 0.4873 | 250 | 0.0097 | 0.1627 |
208
+ | 0.5848 | 300 | 0.0037 | 0.1749 |
209
+ | 0.6823 | 350 | 0.0012 | 0.2009 |
210
+ | 0.7797 | 400 | 0.0006 | 0.1869 |
211
+ | 0.8772 | 450 | 0.0011 | 0.1804 |
212
 
213
  ### Framework Versions
214
  - Python: 3.11.13
config.json CHANGED
@@ -1,25 +1,23 @@
1
  {
2
  "architectures": [
3
- "BertModel"
4
  ],
5
  "attention_probs_dropout_prob": 0.1,
6
- "classifier_dropout": null,
7
- "gradient_checkpointing": false,
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": 6,
18
- "pad_token_id": 0,
19
- "position_embedding_type": "absolute",
20
  "torch_dtype": "float32",
21
  "transformers_version": "4.52.4",
22
- "type_vocab_size": 2,
23
- "use_cache": true,
24
- "vocab_size": 30522
25
  }
 
1
  {
2
  "architectures": [
3
+ "MPNetModel"
4
  ],
5
  "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "eos_token_id": 2,
8
  "hidden_act": "gelu",
9
  "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
  "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-05,
14
+ "max_position_embeddings": 514,
15
+ "model_type": "mpnet",
16
  "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 1,
19
+ "relative_attention_num_buckets": 32,
20
  "torch_dtype": "float32",
21
  "transformers_version": "4.52.4",
22
+ "vocab_size": 30527
 
 
23
  }
config_setfit.json CHANGED
@@ -1,11 +1,11 @@
1
  {
 
 
2
  "normalize_embeddings": false,
3
  "labels": [
4
  "conflict",
5
  "negative",
6
  "neutral",
7
  "positive"
8
- ],
9
- "spacy_model": "en_core_web_lg",
10
- "span_context": 3
11
  }
 
1
  {
2
+ "spacy_model": "en_core_web_trf",
3
+ "span_context": 3,
4
  "normalize_embeddings": false,
5
  "labels": [
6
  "conflict",
7
  "negative",
8
  "neutral",
9
  "positive"
10
+ ]
 
 
11
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3e0b83e777578291820c332350637200bef46c737f18c4d369adb775ac1c5a66
3
- size 90864192
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:751c6b9fbfc279267a4948042ba89985aa7d2272ce712b6f5dad079d81916555
3
+ size 437967672
model_head.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e1094f805f1b8676e0c432024f7143e780d71c3f72e2a10280f4817ec9ed7b10
3
- size 13287
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb2173c537259d51f82ef9a3f5f66e8964a7f24581f78380f1ce73232e37b25b
3
+ size 25575
sentence_bert_config.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "max_seq_length": 256,
3
  "do_lower_case": false
4
  }
 
1
  {
2
+ "max_seq_length": 384,
3
  "do_lower_case": false
4
  }
special_tokens_map.json CHANGED
@@ -1,27 +1,41 @@
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,
 
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,
tokenizer.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
@@ -1,64 +1,72 @@
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": false,
45
- "cls_token": "[CLS]",
46
- "do_basic_tokenize": true,
47
  "do_lower_case": true,
 
48
  "extra_special_tokens": {},
49
- "mask_token": "[MASK]",
50
  "max_length": 128,
51
- "model_max_length": 256,
52
- "never_split": null,
53
  "pad_to_multiple_of": null,
54
- "pad_token": "[PAD]",
55
  "pad_token_type_id": 0,
56
  "padding_side": "right",
57
- "sep_token": "[SEP]",
58
  "stride": 0,
59
  "strip_accents": null,
60
  "tokenize_chinese_chars": true,
61
- "tokenizer_class": "BertTokenizer",
62
  "truncation_side": "right",
63
  "truncation_strategy": "longest_first",
64
  "unk_token": "[UNK]"
 
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": false,
54
+ "cls_token": "<s>",
 
55
  "do_lower_case": true,
56
+ "eos_token": "</s>",
57
  "extra_special_tokens": {},
58
+ "mask_token": "<mask>",
59
  "max_length": 128,
60
+ "model_max_length": 384,
 
61
  "pad_to_multiple_of": null,
62
+ "pad_token": "<pad>",
63
  "pad_token_type_id": 0,
64
  "padding_side": "right",
65
+ "sep_token": "</s>",
66
  "stride": 0,
67
  "strip_accents": null,
68
  "tokenize_chinese_chars": true,
69
+ "tokenizer_class": "MPNetTokenizer",
70
  "truncation_side": "right",
71
  "truncation_strategy": "longest_first",
72
  "unk_token": "[UNK]"
vocab.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  [PAD]
2
  [unused0]
3
  [unused1]
@@ -30520,3 +30524,4 @@ necessitated
30520
  ##:
30521
  ##?
30522
  ##~
 
 
1
+ <s>
2
+ <pad>
3
+ </s>
4
+ <unk>
5
  [PAD]
6
  [unused0]
7
  [unused1]
 
30524
  ##:
30525
  ##?
30526
  ##~
30527
+ <mask>