Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,36 @@
|
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
This BERT was fined-tuned on nuclear energy data from twitter/X. The classification accuracy obtained is 96%. \
|
5 |
-
The number of labels is 3: {0: Negative, 1: Neutral, 2: Positive}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
This BERT was fined-tuned on nuclear energy data from twitter/X. The classification accuracy obtained is 96%. \
|
5 |
+
The number of labels is 3: {0: Negative, 1: Neutral, 2: Positive}
|
6 |
+
|
7 |
+
This is an example to use it
|
8 |
+
```bash
|
9 |
+
from transformers import AutoTokenizer
|
10 |
+
from transformers import pipeline
|
11 |
+
from transformers import AutoModelForSequenceClassification
|
12 |
+
import torch
|
13 |
+
|
14 |
+
checkpoint = 'kumo24/bert-sentiment-nuclear'
|
15 |
+
tokenizer=AutoTokenizer.from_pretrained(checkpoint)
|
16 |
+
id2label = {0: "negative", 1: "neutral", 2: "positive"}
|
17 |
+
label2id = {"negative": 0, "neutral": 1, "positive": 2}
|
18 |
+
|
19 |
+
|
20 |
+
if tokenizer.pad_token is None:
|
21 |
+
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
|
22 |
+
|
23 |
+
model = AutoModelForSequenceClassification.from_pretrained(checkpoint,
|
24 |
+
num_labels=3,
|
25 |
+
id2label=id2label,
|
26 |
+
label2id=label2id)
|
27 |
+
|
28 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
29 |
+
model.to(device)
|
30 |
+
|
31 |
+
|
32 |
+
sentiment_task = pipeline("sentiment-analysis",
|
33 |
+
model=model,
|
34 |
+
tokenizer=tokenizer)
|
35 |
+
|
36 |
+
print(sentiment_task("Michigan Wolverines are Champions, Go Blue!"))
|
37 |
+
```
|