ronalhung commited on
Commit
4af83dc
·
verified ·
1 Parent(s): abd895e

Add SetFit ABSA model

Browse files
README.md CHANGED
@@ -6,17 +6,19 @@ tags:
6
  - text-classification
7
  - generated_from_setfit_trainer
8
  widget:
9
- - text: food:What is even better, is that the prices are very affordable as well,
10
- and the food is really good.
11
- - text: 'soups:An oasis of refinement: Food, though somewhat uneven, often reaches
12
- the pinnacles of new American fine cuisine - chef''s passion (and kitchen''s precise
13
- execution) is most evident in the fish dishes and soups.'
14
- - text: lobster sandwich:We had the lobster sandwich and it was FANTASTIC.
15
- - text: back waiters:I understand the area and folks you need not come here for the
16
- romantic, alluring ambiance or the five star service featuring a sommlier and
17
- a complicated maze of captain and back waiters - you come for the authentic foods,
18
- the tastes, the experiance.
19
- - text: dining experience:The entire dining experience was wonderful!
 
 
20
  metrics:
21
  - accuracy
22
  pipeline_tag: text-classification
@@ -24,7 +26,7 @@ library_name: setfit
24
  inference: false
25
  base_model: sentence-transformers/all-MiniLM-L6-v2
26
  model-index:
27
- - name: SetFit Aspect Model with sentence-transformers/all-MiniLM-L6-v2
28
  results:
29
  - task:
30
  type: text-classification
@@ -35,13 +37,13 @@ model-index:
35
  split: test
36
  metrics:
37
  - type: accuracy
38
- value: 0.8407079646017699
39
  name: Accuracy
40
  ---
41
 
42
- # SetFit Aspect Model with sentence-transformers/all-MiniLM-L6-v2
43
 
44
- 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 filtering aspect span candidates.
45
 
46
  The model has been trained using an efficient few-shot learning technique that involves:
47
 
@@ -51,8 +53,8 @@ The model has been trained using an efficient few-shot learning technique that i
51
  This model was trained within the context of a larger system for ABSA, which looks like so:
52
 
53
  1. Use a spaCy model to select possible aspect span candidates.
54
- 2. **Use this SetFit model to filter these possible aspect span candidates.**
55
- 3. Use a SetFit model to classify the filtered aspect span candidates.
56
 
57
  ## Model Details
58
 
@@ -61,10 +63,10 @@ This model was trained within the context of a larger system for ABSA, which loo
61
  - **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
62
  - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
63
  - **spaCy Model:** en_core_web_lg
64
- - **SetFitABSA Aspect Model:** [ronalhung/setfit-absa-restaurants-polarity](https://huggingface.co/ronalhung/setfit-absa-restaurants-polarity)
65
- - **SetFitABSA Polarity Model:** [setfit-absa-polarity](https://huggingface.co/setfit-absa-polarity)
66
  - **Maximum Sequence Length:** 256 tokens
67
- - **Number of Classes:** 2 classes
68
  <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
69
  <!-- - **Language:** Unknown -->
70
  <!-- - **License:** Unknown -->
@@ -76,17 +78,19 @@ This model was trained within the context of a larger system for ABSA, which loo
76
  - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
77
 
78
  ### Model Labels
79
- | Label | Examples |
80
- |:----------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
81
- | aspect | <ul><li>'staff:But the staff was so horrible to us.'</li><li>"food:To be completely fair, the only redeeming factor was the food, which was above average, but couldn't make up for all the other deficiencies of Teodora."</li><li>"food:The food is uniformly exceptional, with a very capable kitchen which will proudly whip up whatever you feel like eating, whether it's on the menu or not."</li></ul> |
82
- | no aspect | <ul><li>"factor:To be completely fair, the only redeeming factor was the food, which was above average, but couldn't make up for all the other deficiencies of Teodora."</li><li>"deficiencies:To be completely fair, the only redeeming factor was the food, which was above average, but couldn't make up for all the other deficiencies of Teodora."</li><li>"Teodora:To be completely fair, the only redeeming factor was the food, which was above average, but couldn't make up for all the other deficiencies of Teodora."</li></ul> |
 
 
83
 
84
  ## Evaluation
85
 
86
  ### Metrics
87
  | Label | Accuracy |
88
  |:--------|:---------|
89
- | **all** | 0.8407 |
90
 
91
  ## Uses
92
 
@@ -105,8 +109,8 @@ from setfit import AbsaModel
105
 
106
  # Download from the 🤗 Hub
107
  model = AbsaModel.from_pretrained(
 
108
  "ronalhung/setfit-absa-restaurants-polarity",
109
- "setfit-absa-polarity",
110
  )
111
  # Run inference
112
  preds = model("The food was great, but the venue is just way too busy.")
@@ -141,12 +145,14 @@ preds = model("The food was great, but the venue is just way too busy.")
141
  ### Training Set Metrics
142
  | Training set | Min | Median | Max |
143
  |:-------------|:----|:--------|:----|
144
- | Word count | 4 | 17.9296 | 37 |
145
 
146
- | Label | Training Sample Count |
147
- |:----------|:----------------------|
148
- | no aspect | 71 |
149
- | aspect | 128 |
 
 
150
 
151
  ### Training Hyperparameters
152
  - batch_size: (128, 128)
@@ -169,27 +175,23 @@ preds = model("The food was great, but the venue is just way too busy.")
169
  ### Training Results
170
  | Epoch | Step | Training Loss | Validation Loss |
171
  |:------:|:----:|:-------------:|:---------------:|
172
- | 0.0015 | 1 | 0.3852 | - |
173
- | 0.0740 | 50 | 0.2999 | 0.2943 |
174
- | 0.0059 | 1 | 0.2573 | - |
175
- | 0.2959 | 50 | 0.2516 | 0.2540 |
176
- | 0.5917 | 100 | 0.1633 | 0.2385 |
177
- | 0.8876 | 150 | 0.015 | 0.2334 |
178
- | 1.1834 | 200 | 0.0025 | 0.2396 |
179
- | 1.4793 | 250 | 0.0013 | 0.2452 |
180
- | 1.7751 | 300 | 0.0009 | 0.2491 |
181
- | 2.0710 | 350 | 0.0007 | 0.2449 |
182
- | 2.3669 | 400 | 0.0005 | 0.2372 |
183
 
184
  ### Framework Versions
185
- - Python: 3.11.11
186
  - SetFit: 1.1.2
187
  - Sentence Transformers: 3.4.1
188
- - spaCy: 3.7.5
189
- - Transformers: 4.48.3
190
- - PyTorch: 2.5.1+cu124
191
  - Datasets: 3.5.0
192
- - Tokenizers: 0.21.0
193
 
194
  ## Citation
195
 
 
6
  - text-classification
7
  - generated_from_setfit_trainer
8
  widget:
9
+ - text: '- they use fresh mozzarella instead of the:The pizza is delicious - they
10
+ use fresh mozzarella instead of the cheap, frozen, shredded cheese common to most
11
+ pizzaria''s.'
12
+ - text: 'refinement: Food, though somewhat:An oasis of refinement: Food, though
13
+ somewhat uneven, often reaches the pinnacles of new American fine cuisine - chef''s
14
+ passion (and kitchen''s precise execution) is most evident in the fish dishes
15
+ and soups.'
16
+ - text: We had the lobster sandwich and it was:We had the lobster sandwich and it
17
+ was FANTASTIC.
18
+ - text: The fish is fresh but:The fish is fresh but the variety of fish is nothing
19
+ out of ordinary.
20
+ - text: with classic upscale Italian decor.:Nice restaurant overall, with classic
21
+ upscale Italian decor.
22
  metrics:
23
  - accuracy
24
  pipeline_tag: text-classification
 
26
  inference: false
27
  base_model: sentence-transformers/all-MiniLM-L6-v2
28
  model-index:
29
+ - name: SetFit Polarity Model with sentence-transformers/all-MiniLM-L6-v2
30
  results:
31
  - task:
32
  type: text-classification
 
37
  split: test
38
  metrics:
39
  - type: accuracy
40
+ value: 0.7244094488188977
41
  name: Accuracy
42
  ---
43
 
44
+ # SetFit Polarity Model with sentence-transformers/all-MiniLM-L6-v2
45
 
46
+ 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.
47
 
48
  The model has been trained using an efficient few-shot learning technique that involves:
49
 
 
53
  This model was trained within the context of a larger system for ABSA, which looks like so:
54
 
55
  1. Use a spaCy model to select possible aspect span candidates.
56
+ 2. Use a SetFit model to filter these possible aspect span candidates.
57
+ 3. **Use this SetFit model to classify the filtered aspect span candidates.**
58
 
59
  ## Model Details
60
 
 
63
  - **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
64
  - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
65
  - **spaCy Model:** en_core_web_lg
66
+ - **SetFitABSA Aspect Model:** [ronalhung/setfit-absa-restaurants-aspect](https://huggingface.co/ronalhung/setfit-absa-restaurants-aspect)
67
+ - **SetFitABSA Polarity Model:** [ronalhung/setfit-absa-restaurants-polarity](https://huggingface.co/ronalhung/setfit-absa-restaurants-polarity)
68
  - **Maximum Sequence Length:** 256 tokens
69
+ - **Number of Classes:** 4 classes
70
  <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
71
  <!-- - **Language:** Unknown -->
72
  <!-- - **License:** Unknown -->
 
78
  - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
79
 
80
  ### Model Labels
81
+ | Label | Examples |
82
+ |:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
83
+ | negative | <ul><li>'But the staff was so horrible:But the staff was so horrible to us.'</li><li>', forgot our toast, left out:They did not have mayonnaise, forgot our toast, left out ingredients (ie cheese in an omelet), below hot temperatures and the bacon was so over cooked it crumbled on the plate when you touched it.'</li><li>'did not have mayonnaise, forgot our:They did not have mayonnaise, forgot our toast, left out ingredients (ie cheese in an omelet), below hot temperatures and the bacon was so over cooked it crumbled on the plate when you touched it.'</li></ul> |
84
+ | positive | <ul><li>"factor was the food, which was:To be completely fair, the only redeeming factor was the food, which was above average, but couldn't make up for all the other deficiencies of Teodora."</li><li>"The food is uniformly exceptional:The food is uniformly exceptional, with a very capable kitchen which will proudly whip up whatever you feel like eating, whether it's on the menu or not."</li><li>"a very capable kitchen which will proudly:The food is uniformly exceptional, with a very capable kitchen which will proudly whip up whatever you feel like eating, whether it's on the menu or not."</li></ul> |
85
+ | neutral | <ul><li>"'s on the menu or not.:The food is uniformly exceptional, with a very capable kitchen which will proudly whip up whatever you feel like eating, whether it's on the menu or not."</li><li>'to sample both meats).:Our agreed favorite is the orrechiete with sausage and chicken (usually the waiters are kind enough to split the dish in half so you get to sample both meats).'</li><li>'to split the dish in half so:Our agreed favorite is the orrechiete with sausage and chicken (usually the waiters are kind enough to split the dish in half so you get to sample both meats).'</li></ul> |
86
+ | conflict | <ul><li>'The food was delicious but:The food was delicious but do not come here on a empty stomach.'</li><li>"The service varys from day:The service varys from day to day- sometimes they're very nice, and sometimes not."</li></ul> |
87
 
88
  ## Evaluation
89
 
90
  ### Metrics
91
  | Label | Accuracy |
92
  |:--------|:---------|
93
+ | **all** | 0.7244 |
94
 
95
  ## Uses
96
 
 
109
 
110
  # Download from the 🤗 Hub
111
  model = AbsaModel.from_pretrained(
112
+ "ronalhung/setfit-absa-restaurants-aspect",
113
  "ronalhung/setfit-absa-restaurants-polarity",
 
114
  )
115
  # Run inference
116
  preds = model("The food was great, but the venue is just way too busy.")
 
145
  ### Training Set Metrics
146
  | Training set | Min | Median | Max |
147
  |:-------------|:----|:--------|:----|
148
+ | Word count | 6 | 21.3594 | 43 |
149
 
150
+ | Label | Training Sample Count |
151
+ |:---------|:----------------------|
152
+ | conflict | 2 |
153
+ | negative | 19 |
154
+ | neutral | 25 |
155
+ | positive | 82 |
156
 
157
  ### Training Hyperparameters
158
  - batch_size: (128, 128)
 
175
  ### Training Results
176
  | Epoch | Step | Training Loss | Validation Loss |
177
  |:------:|:----:|:-------------:|:---------------:|
178
+ | 0.0147 | 1 | 0.2928 | - |
179
+ | 0.7353 | 50 | 0.1985 | 0.2185 |
180
+ | 1.4706 | 100 | 0.0538 | 0.2563 |
181
+ | 2.2059 | 150 | 0.0219 | 0.2624 |
182
+ | 2.9412 | 200 | 0.0101 | 0.2634 |
183
+ | 3.6765 | 250 | 0.0046 | 0.2726 |
184
+ | 4.4118 | 300 | 0.0033 | 0.2721 |
 
 
 
 
185
 
186
  ### Framework Versions
187
+ - Python: 3.11.12
188
  - SetFit: 1.1.2
189
  - Sentence Transformers: 3.4.1
190
+ - spaCy: 3.8.5
191
+ - Transformers: 4.51.3
192
+ - PyTorch: 2.6.0+cu124
193
  - Datasets: 3.5.0
194
+ - Tokenizers: 0.21.1
195
 
196
  ## Citation
197
 
config.json CHANGED
@@ -1,5 +1,4 @@
1
  {
2
- "_name_or_path": "sentence-transformers/all-MiniLM-L6-v2",
3
  "architectures": [
4
  "BertModel"
5
  ],
@@ -19,7 +18,7 @@
19
  "pad_token_id": 0,
20
  "position_embedding_type": "absolute",
21
  "torch_dtype": "float32",
22
- "transformers_version": "4.48.3",
23
  "type_vocab_size": 2,
24
  "use_cache": true,
25
  "vocab_size": 30522
 
1
  {
 
2
  "architectures": [
3
  "BertModel"
4
  ],
 
18
  "pad_token_id": 0,
19
  "position_embedding_type": "absolute",
20
  "torch_dtype": "float32",
21
+ "transformers_version": "4.51.3",
22
  "type_vocab_size": 2,
23
  "use_cache": true,
24
  "vocab_size": 30522
config_sentence_transformers.json CHANGED
@@ -1,8 +1,8 @@
1
  {
2
  "__version__": {
3
  "sentence_transformers": "3.4.1",
4
- "transformers": "4.48.3",
5
- "pytorch": "2.5.1+cu124"
6
  },
7
  "prompts": {},
8
  "default_prompt_name": null,
 
1
  {
2
  "__version__": {
3
  "sentence_transformers": "3.4.1",
4
+ "transformers": "4.51.3",
5
+ "pytorch": "2.6.0+cu124"
6
  },
7
  "prompts": {},
8
  "default_prompt_name": null,
config_setfit.json CHANGED
@@ -1,9 +1,11 @@
1
  {
 
2
  "labels": [
3
- "no aspect",
4
- "aspect"
 
 
5
  ],
6
  "spacy_model": "en_core_web_lg",
7
- "normalize_embeddings": false,
8
- "span_context": 0
9
  }
 
1
  {
2
+ "span_context": 3,
3
  "labels": [
4
+ "conflict",
5
+ "negative",
6
+ "neutral",
7
+ "positive"
8
  ],
9
  "spacy_model": "en_core_web_lg",
10
+ "normalize_embeddings": false
 
11
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d7f22811b51b41fc1dc5941afe286dcc3db2bfdb45833898b8a67440c38d48df
3
  size 90864192
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c29cedb2dd1612b46ef46356912347fec1d7be96d95cfad3ce2514aedfdbcbc9
3
  size 90864192
model_head.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:bbed4aa053d3a68620daf4411fe1596e6deee17a02f31cb5da5ef55ec0a34a8a
3
- size 3919
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4cfd7d3053ab9623988c3b9b73e34f52fdfcd8cdd4a977b36af33acbf795dac4
3
+ size 13287