Added arXiv link, updated citation, edited pip install line
Browse files
README.md
CHANGED
@@ -1,390 +1,394 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
tags:
|
4 |
-
- sentiment-analysis
|
5 |
-
- text-classification
|
6 |
-
- electra
|
7 |
-
- pytorch
|
8 |
-
- transformers
|
9 |
-
---
|
10 |
-
|
11 |
-
# ELECTRA Large Classifier for Sentiment Analysis
|
12 |
-
|
13 |
-
This is an [ELECTRA large discriminator](https://huggingface.co/google/electra-large-discriminator) fine-tuned for sentiment analysis of reviews. It has a mean pooling layer and a classifier head (2 layers of 1024 dimension) with SwishGLU activation and dropout (0.3). It classifies text into three sentiment categories: 'negative' (0), 'neutral' (1), and 'positive' (2). It was fine-tuned on the [Sentiment Merged](https://huggingface.co/datasets/jbeno/sentiment_merged) dataset, which is a merge of Stanford Sentiment Treebank (SST-3), and DynaSent Rounds 1 and 2.
|
14 |
-
|
15 |
-
|
16 |
-
## Labels
|
17 |
-
|
18 |
-
The model predicts the following labels:
|
19 |
-
|
20 |
-
- `0`: negative
|
21 |
-
- `1`: neutral
|
22 |
-
- `2`: positive
|
23 |
-
|
24 |
-
## How to Use
|
25 |
-
|
26 |
-
### Install package
|
27 |
-
|
28 |
-
This model requires the classes in `electra_classifier.py`. You can download the file, or you can install the package from PyPI.
|
29 |
-
|
30 |
-
```bash
|
31 |
-
pip install electra-classifier
|
32 |
-
```
|
33 |
-
|
34 |
-
### Load classes and model
|
35 |
-
```python
|
36 |
-
# Install the package in a notebook
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
from
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
model
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
-
|
66 |
-
-
|
67 |
-
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
- [jbeno/
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
-
|
90 |
-
-
|
91 |
-
|
92 |
-
-
|
93 |
-
-
|
94 |
-
|
95 |
-
-
|
96 |
-
- **
|
97 |
-
|
98 |
-
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
- **
|
104 |
-
- **
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
(
|
113 |
-
(
|
114 |
-
(
|
115 |
-
(
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
(
|
124 |
-
(
|
125 |
-
(
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
(
|
130 |
-
(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
(
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
(
|
140 |
-
(
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
(
|
148 |
-
|
149 |
-
|
150 |
-
(
|
151 |
-
|
152 |
-
(
|
153 |
-
|
154 |
-
|
155 |
-
(
|
156 |
-
(
|
157 |
-
|
158 |
-
(
|
159 |
-
|
160 |
-
|
161 |
-
(
|
162 |
-
|
163 |
-
|
164 |
-
)
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
self.
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
- `
|
192 |
-
- `
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
- `
|
221 |
-
- `
|
222 |
-
- `
|
223 |
-
- `
|
224 |
-
- `
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
layers
|
232 |
-
layers.append(
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
layers.append(
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
- `
|
252 |
-
- `
|
253 |
-
- `
|
254 |
-
- `
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
}
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
##
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
tags:
|
4 |
+
- sentiment-analysis
|
5 |
+
- text-classification
|
6 |
+
- electra
|
7 |
+
- pytorch
|
8 |
+
- transformers
|
9 |
+
---
|
10 |
+
|
11 |
+
# ELECTRA Large Classifier for Sentiment Analysis
|
12 |
+
|
13 |
+
This is an [ELECTRA large discriminator](https://huggingface.co/google/electra-large-discriminator) fine-tuned for sentiment analysis of reviews. It has a mean pooling layer and a classifier head (2 layers of 1024 dimension) with SwishGLU activation and dropout (0.3). It classifies text into three sentiment categories: 'negative' (0), 'neutral' (1), and 'positive' (2). It was fine-tuned on the [Sentiment Merged](https://huggingface.co/datasets/jbeno/sentiment_merged) dataset, which is a merge of Stanford Sentiment Treebank (SST-3), and DynaSent Rounds 1 and 2.
|
14 |
+
|
15 |
+
|
16 |
+
## Labels
|
17 |
+
|
18 |
+
The model predicts the following labels:
|
19 |
+
|
20 |
+
- `0`: negative
|
21 |
+
- `1`: neutral
|
22 |
+
- `2`: positive
|
23 |
+
|
24 |
+
## How to Use
|
25 |
+
|
26 |
+
### Install package
|
27 |
+
|
28 |
+
This model requires the classes in `electra_classifier.py`. You can download the file, or you can install the package from PyPI.
|
29 |
+
|
30 |
+
```bash
|
31 |
+
pip install electra-classifier
|
32 |
+
```
|
33 |
+
|
34 |
+
### Load classes and model
|
35 |
+
```python
|
36 |
+
# Install the package in a notebook
|
37 |
+
import sys
|
38 |
+
!{sys.executable} -m pip install electra-classifier
|
39 |
+
|
40 |
+
# Import libraries
|
41 |
+
import torch
|
42 |
+
from transformers import AutoTokenizer
|
43 |
+
from electra_classifier import ElectraClassifier
|
44 |
+
|
45 |
+
# Load tokenizer and model
|
46 |
+
model_name = "jbeno/electra-large-classifier-sentiment"
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
48 |
+
model = ElectraClassifier.from_pretrained(model_name)
|
49 |
+
|
50 |
+
# Set model to evaluation mode
|
51 |
+
model.eval()
|
52 |
+
|
53 |
+
# Run inference
|
54 |
+
text = "I love this restaurant!"
|
55 |
+
inputs = tokenizer(text, return_tensors="pt")
|
56 |
+
|
57 |
+
with torch.no_grad():
|
58 |
+
logits = model(**inputs)
|
59 |
+
predicted_class_id = torch.argmax(logits, dim=1).item()
|
60 |
+
predicted_label = model.config.id2label[predicted_class_id]
|
61 |
+
print(f"Predicted label: {predicted_label}")
|
62 |
+
```
|
63 |
+
|
64 |
+
## Requirements
|
65 |
+
- Python 3.7+
|
66 |
+
- PyTorch
|
67 |
+
- Transformers
|
68 |
+
- [electra-classifier](https://pypi.org/project/electra-classifier/) - Install with pip, or download electra_classifier.py
|
69 |
+
|
70 |
+
## Training Details
|
71 |
+
|
72 |
+
### Dataset
|
73 |
+
|
74 |
+
The model was trained on the [Sentiment Merged](https://huggingface.co/datasets/jbeno/sentiment_merged) dataset, which is a mix of Stanford Sentiment Treebank (SST-3), DynaSent Round 1, and DynaSent Round 2.
|
75 |
+
|
76 |
+
### Code
|
77 |
+
|
78 |
+
The code used to train the model can be found on GitHub:
|
79 |
+
- [jbeno/sentiment](https://github.com/jbeno/sentiment)
|
80 |
+
- [jbeno/electra-classifier](https://github.com/jbeno/electra-classifier)
|
81 |
+
|
82 |
+
### Research Paper
|
83 |
+
|
84 |
+
The research paper can be found here: [ELECTRA and GPT-4o: Cost-Effective Partners for Sentiment Analysis](http://arxiv.org/abs/2501.00062) (arXiv:2501.00062)
|
85 |
+
|
86 |
+
### Performance Summary
|
87 |
+
|
88 |
+
- **Merged Dataset**
|
89 |
+
- Macro Average F1: **82.36**
|
90 |
+
- Accuracy: **82.96**
|
91 |
+
- **DynaSent R1**
|
92 |
+
- Macro Average F1: **85.91**
|
93 |
+
- Accuracy: **85.83**
|
94 |
+
- **DynaSent R2**
|
95 |
+
- Macro Average F1: **76.29**
|
96 |
+
- Accuracy: **76.53**
|
97 |
+
- **SST-3**
|
98 |
+
- Macro Average F1: **70.90**
|
99 |
+
- Accuracy: **80.36**
|
100 |
+
|
101 |
+
## Model Architecture
|
102 |
+
|
103 |
+
- **Base Model**: ELECTRA large discriminator (`google/electra-large-discriminator`)
|
104 |
+
- **Pooling Layer**: Custom pooling layer supporting 'cls', 'mean', and 'max' pooling types.
|
105 |
+
- **Classifier**: Custom classifier with configurable hidden dimensions, number of layers, and dropout rate.
|
106 |
+
- **Activation Function**: Custom SwishGLU activation function.
|
107 |
+
|
108 |
+
```
|
109 |
+
ElectraClassifier(
|
110 |
+
(electra): ElectraModel(
|
111 |
+
(embeddings): ElectraEmbeddings(
|
112 |
+
(word_embeddings): Embedding(30522, 1024, padding_idx=0)
|
113 |
+
(position_embeddings): Embedding(512, 1024)
|
114 |
+
(token_type_embeddings): Embedding(2, 1024)
|
115 |
+
(LayerNorm): LayerNorm((1024,), eps=1e-12, elementwise_affine=True)
|
116 |
+
(dropout): Dropout(p=0.1, inplace=False)
|
117 |
+
)
|
118 |
+
(encoder): ElectraEncoder(
|
119 |
+
(layer): ModuleList(
|
120 |
+
(0-23): 24 x ElectraLayer(
|
121 |
+
(attention): ElectraAttention(
|
122 |
+
(self): ElectraSelfAttention(
|
123 |
+
(query): Linear(in_features=1024, out_features=1024, bias=True)
|
124 |
+
(key): Linear(in_features=1024, out_features=1024, bias=True)
|
125 |
+
(value): Linear(in_features=1024, out_features=1024, bias=True)
|
126 |
+
(dropout): Dropout(p=0.1, inplace=False)
|
127 |
+
)
|
128 |
+
(output): ElectraSelfOutput(
|
129 |
+
(dense): Linear(in_features=1024, out_features=1024, bias=True)
|
130 |
+
(LayerNorm): LayerNorm((1024,), eps=1e-12, elementwise_affine=True)
|
131 |
+
(dropout): Dropout(p=0.1, inplace=False)
|
132 |
+
)
|
133 |
+
)
|
134 |
+
(intermediate): ElectraIntermediate(
|
135 |
+
(dense): Linear(in_features=1024, out_features=4096, bias=True)
|
136 |
+
(intermediate_act_fn): GELUActivation()
|
137 |
+
)
|
138 |
+
(output): ElectraOutput(
|
139 |
+
(dense): Linear(in_features=4096, out_features=1024, bias=True)
|
140 |
+
(LayerNorm): LayerNorm((1024,), eps=1e-12, elementwise_affine=True)
|
141 |
+
(dropout): Dropout(p=0.1, inplace=False)
|
142 |
+
)
|
143 |
+
)
|
144 |
+
)
|
145 |
+
)
|
146 |
+
)
|
147 |
+
(custom_pooling): PoolingLayer()
|
148 |
+
(classifier): Classifier(
|
149 |
+
(layers): Sequential(
|
150 |
+
(0): Linear(in_features=1024, out_features=1024, bias=True)
|
151 |
+
(1): SwishGLU(
|
152 |
+
(projection): Linear(in_features=1024, out_features=2048, bias=True)
|
153 |
+
(activation): SiLU()
|
154 |
+
)
|
155 |
+
(2): Dropout(p=0.3, inplace=False)
|
156 |
+
(3): Linear(in_features=1024, out_features=1024, bias=True)
|
157 |
+
(4): SwishGLU(
|
158 |
+
(projection): Linear(in_features=1024, out_features=2048, bias=True)
|
159 |
+
(activation): SiLU()
|
160 |
+
)
|
161 |
+
(5): Dropout(p=0.3, inplace=False)
|
162 |
+
(6): Linear(in_features=1024, out_features=3, bias=True)
|
163 |
+
)
|
164 |
+
)
|
165 |
+
)
|
166 |
+
```
|
167 |
+
|
168 |
+
## Custom Model Components
|
169 |
+
|
170 |
+
### SwishGLU Activation Function
|
171 |
+
|
172 |
+
The SwishGLU activation function combines the Swish activation with a Gated Linear Unit (GLU). It enhances the model's ability to capture complex patterns in the data.
|
173 |
+
|
174 |
+
```python
|
175 |
+
class SwishGLU(nn.Module):
|
176 |
+
def __init__(self, input_dim: int, output_dim: int):
|
177 |
+
super(SwishGLU, self).__init__()
|
178 |
+
self.projection = nn.Linear(input_dim, 2 * output_dim)
|
179 |
+
self.activation = nn.SiLU()
|
180 |
+
|
181 |
+
def forward(self, x):
|
182 |
+
x_proj_gate = self.projection(x)
|
183 |
+
projected, gate = x_proj_gate.tensor_split(2, dim=-1)
|
184 |
+
return projected * self.activation(gate)
|
185 |
+
```
|
186 |
+
|
187 |
+
### PoolingLayer
|
188 |
+
|
189 |
+
The PoolingLayer class allows you to choose between different pooling strategies:
|
190 |
+
|
191 |
+
- `cls`: Uses the representation of the \[CLS\] token.
|
192 |
+
- `mean`: Calculates the mean of the token embeddings.
|
193 |
+
- `max`: Takes the maximum value across token embeddings.
|
194 |
+
|
195 |
+
**'mean'** pooling was used in the fine-tuned model.
|
196 |
+
|
197 |
+
```python
|
198 |
+
class PoolingLayer(nn.Module):
|
199 |
+
def __init__(self, pooling_type='cls'):
|
200 |
+
super().__init__()
|
201 |
+
self.pooling_type = pooling_type
|
202 |
+
|
203 |
+
def forward(self, last_hidden_state, attention_mask):
|
204 |
+
if self.pooling_type == 'cls':
|
205 |
+
return last_hidden_state[:, 0, :]
|
206 |
+
elif self.pooling_type == 'mean':
|
207 |
+
return (last_hidden_state * attention_mask.unsqueeze(-1)).sum(1) / attention_mask.sum(-1).unsqueeze(-1)
|
208 |
+
elif self.pooling_type == 'max':
|
209 |
+
return torch.max(last_hidden_state * attention_mask.unsqueeze(-1), dim=1)[0]
|
210 |
+
else:
|
211 |
+
raise ValueError(f"Unknown pooling method: {self.pooling_type}")
|
212 |
+
```
|
213 |
+
|
214 |
+
### Classifier
|
215 |
+
|
216 |
+
The Classifier class is a customizable feed-forward neural network used for the final classification.
|
217 |
+
|
218 |
+
The fine-tuned model had:
|
219 |
+
|
220 |
+
- `input_dim`: 1024
|
221 |
+
- `num_layers`: 2
|
222 |
+
- `hidden_dim`: 1024
|
223 |
+
- `hidden_activation`: SwishGLU
|
224 |
+
- `dropout_rate`: 0.3
|
225 |
+
- `n_classes`: 3
|
226 |
+
|
227 |
+
```python
|
228 |
+
class Classifier(nn.Module):
|
229 |
+
def __init__(self, input_dim, hidden_dim, hidden_activation, num_layers, n_classes, dropout_rate=0.0):
|
230 |
+
super().__init__()
|
231 |
+
layers = []
|
232 |
+
layers.append(nn.Linear(input_dim, hidden_dim))
|
233 |
+
layers.append(hidden_activation)
|
234 |
+
if dropout_rate > 0:
|
235 |
+
layers.append(nn.Dropout(dropout_rate))
|
236 |
+
|
237 |
+
for _ in range(num_layers - 1):
|
238 |
+
layers.append(nn.Linear(hidden_dim, hidden_dim))
|
239 |
+
layers.append(hidden_activation)
|
240 |
+
if dropout_rate > 0:
|
241 |
+
layers.append(nn.Dropout(dropout_rate))
|
242 |
+
|
243 |
+
layers.append(nn.Linear(hidden_dim, n_classes))
|
244 |
+
self.layers = nn.Sequential(*layers)
|
245 |
+
```
|
246 |
+
|
247 |
+
## Model Configuration
|
248 |
+
|
249 |
+
The model's configuration (config.json) includes custom parameters:
|
250 |
+
|
251 |
+
- `hidden_dim`: Size of the hidden layers in the classifier.
|
252 |
+
- `hidden_activation`: Activation function used in the classifier ('SwishGLU').
|
253 |
+
- `num_layers`: Number of layers in the classifier.
|
254 |
+
- `dropout_rate`: Dropout rate used in the classifier.
|
255 |
+
- `pooling`: Pooling strategy used ('mean').
|
256 |
+
|
257 |
+
## Performance by Dataset
|
258 |
+
|
259 |
+
### Merged Dataset
|
260 |
+
|
261 |
+
```
|
262 |
+
Merged Dataset Classification Report
|
263 |
+
|
264 |
+
precision recall f1-score support
|
265 |
+
|
266 |
+
negative 0.858503 0.843537 0.850954 2352
|
267 |
+
neutral 0.747684 0.750137 0.748908 1829
|
268 |
+
positive 0.864513 0.877395 0.870906 2349
|
269 |
+
|
270 |
+
accuracy 0.829556 6530
|
271 |
+
macro avg 0.823567 0.823690 0.823590 6530
|
272 |
+
weighted avg 0.829626 0.829556 0.829549 6530
|
273 |
+
|
274 |
+
ROC AUC: 0.947247
|
275 |
+
|
276 |
+
Predicted negative neutral positive
|
277 |
+
Actual
|
278 |
+
negative 1984 256 112
|
279 |
+
neutral 246 1372 211
|
280 |
+
positive 81 207 2061
|
281 |
+
|
282 |
+
Macro F1 Score: 0.82
|
283 |
+
```
|
284 |
+
|
285 |
+
### DynaSent Round 1
|
286 |
+
|
287 |
+
```
|
288 |
+
DynaSent Round 1 Classification Report
|
289 |
+
|
290 |
+
precision recall f1-score support
|
291 |
+
|
292 |
+
negative 0.913204 0.824167 0.866404 1200
|
293 |
+
neutral 0.779433 0.915833 0.842146 1200
|
294 |
+
positive 0.905149 0.835000 0.868661 1200
|
295 |
+
|
296 |
+
accuracy 0.858333 3600
|
297 |
+
macro avg 0.865929 0.858333 0.859070 3600
|
298 |
+
weighted avg 0.865929 0.858333 0.859070 3600
|
299 |
+
|
300 |
+
ROC AUC: 0.963133
|
301 |
+
|
302 |
+
Predicted negative neutral positive
|
303 |
+
Actual
|
304 |
+
negative 989 156 55
|
305 |
+
neutral 51 1099 50
|
306 |
+
positive 43 155 1002
|
307 |
+
|
308 |
+
Macro F1 Score: 0.86
|
309 |
+
```
|
310 |
+
|
311 |
+
### DynaSent Round 2
|
312 |
+
|
313 |
+
```
|
314 |
+
DynaSent Round 2 Classification Report
|
315 |
+
|
316 |
+
precision recall f1-score support
|
317 |
+
|
318 |
+
negative 0.764706 0.812500 0.787879 240
|
319 |
+
neutral 0.814815 0.641667 0.717949 240
|
320 |
+
positive 0.731884 0.841667 0.782946 240
|
321 |
+
|
322 |
+
accuracy 0.765278 720
|
323 |
+
macro avg 0.770468 0.765278 0.762924 720
|
324 |
+
weighted avg 0.770468 0.765278 0.762924 720
|
325 |
+
|
326 |
+
ROC AUC: 0.927688
|
327 |
+
|
328 |
+
Predicted negative neutral positive
|
329 |
+
Actual
|
330 |
+
negative 195 19 26
|
331 |
+
neutral 38 154 48
|
332 |
+
positive 22 16 202
|
333 |
+
|
334 |
+
Macro F1 Score: 0.76
|
335 |
+
```
|
336 |
+
|
337 |
+
### Stanford Sentiment Treebank (SST-3)
|
338 |
+
|
339 |
+
```
|
340 |
+
SST-3 Classification Report
|
341 |
+
|
342 |
+
precision recall f1-score support
|
343 |
+
|
344 |
+
negative 0.822199 0.877193 0.848806 912
|
345 |
+
neutral 0.504237 0.305913 0.380800 389
|
346 |
+
positive 0.856144 0.942794 0.897382 909
|
347 |
+
|
348 |
+
accuracy 0.803620 2210
|
349 |
+
macro avg 0.727527 0.708633 0.708996 2210
|
350 |
+
weighted avg 0.780194 0.803620 0.786409 2210
|
351 |
+
|
352 |
+
ROC AUC: 0.904787
|
353 |
+
|
354 |
+
Predicted negative neutral positive
|
355 |
+
Actual
|
356 |
+
negative 800 81 31
|
357 |
+
neutral 157 119 113
|
358 |
+
positive 16 36 857
|
359 |
+
|
360 |
+
Macro F1 Score: 0.71
|
361 |
+
```
|
362 |
+
|
363 |
+
## License
|
364 |
+
|
365 |
+
This model is licensed under the MIT License.
|
366 |
+
|
367 |
+
## Citation
|
368 |
+
|
369 |
+
If you use this model in your work, please cite:
|
370 |
+
|
371 |
+
```bibtex
|
372 |
+
@article{beno-2024-electragpt,
|
373 |
+
title={ELECTRA and GPT-4o: Cost-Effective Partners for Sentiment Analysis},
|
374 |
+
author={James P. Beno},
|
375 |
+
journal={arXiv preprint arXiv:2501.00062},
|
376 |
+
year={2024},
|
377 |
+
eprint={2501.00062},
|
378 |
+
archivePrefix={arXiv},
|
379 |
+
primaryClass={cs.CL},
|
380 |
+
url={https://arxiv.org/abs/2501.00062},
|
381 |
+
}
|
382 |
+
```
|
383 |
+
|
384 |
+
## Contact
|
385 |
+
|
386 |
+
For questions or comments, please open an issue on the repository or contact [Jim Beno](https://huggingface.co/jbeno).
|
387 |
+
|
388 |
+
## Acknowledgments
|
389 |
+
|
390 |
+
- The [Hugging Face Transformers library](https://github.com/huggingface/transformers) for providing powerful tools for model development.
|
391 |
+
- The creators of the [ELECTRA model](https://arxiv.org/abs/2003.10555) for their foundational work.
|
392 |
+
- The authors of the datasets used: [Stanford Sentiment Treebank](https://huggingface.co/datasets/stanfordnlp/sst), [DynaSent](https://huggingface.co/datasets/dynabench/dynasent).
|
393 |
+
- [Stanford Engineering CGOE](https://cgoe.stanford.edu), [Chris Potts](https://stanford.edu/~cgpotts/), and the Course Facilitators of [XCS224U](https://online.stanford.edu/courses/xcs224u-natural-language-understanding)
|
394 |
+
|