Update README.md
Browse files
README.md
CHANGED
@@ -7,4 +7,37 @@ metrics:
|
|
7 |
library_name: transformers
|
8 |
pipeline_tag: text-classification
|
9 |
---
|
10 |
-
This GPT-2 model was fine-tuned using +
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
library_name: transformers
|
8 |
pipeline_tag: text-classification
|
9 |
---
|
10 |
+
This GPT-2 model was fine-tuned using +400k nuclear energy tweets from twitter/X. The classification accuracy is 95%.
|
11 |
+
|
12 |
+
The number of labels is 3: {0: Negative, 1: Neutral, 2: Positive}
|
13 |
+
|
14 |
+
This is an example to use it
|
15 |
+
```bash
|
16 |
+
from transformers import AutoTokenizer
|
17 |
+
from transformers import pipeline
|
18 |
+
from transformers import AutoModelForSequenceClassification
|
19 |
+
import torch
|
20 |
+
|
21 |
+
checkpoint = 'kumo24/gpt2-sentiment-nuclear'
|
22 |
+
tokenizer=AutoTokenizer.from_pretrained(checkpoint)
|
23 |
+
id2label = {0: "negative", 1: "neutral", 2: "positive"}
|
24 |
+
label2id = {"negative": 0, "neutral": 1, "positive": 2}
|
25 |
+
|
26 |
+
|
27 |
+
if tokenizer.pad_token is None:
|
28 |
+
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
|
29 |
+
|
30 |
+
model = AutoModelForSequenceClassification.from_pretrained(checkpoint,
|
31 |
+
num_labels=3,
|
32 |
+
id2label=id2label,
|
33 |
+
label2id=label2id)
|
34 |
+
|
35 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
36 |
+
model.to(device)
|
37 |
+
|
38 |
+
|
39 |
+
sentiment_task = pipeline("sentiment-analysis",
|
40 |
+
model=model,
|
41 |
+
tokenizer=tokenizer)
|
42 |
+
|
43 |
+
print(sentiment_task("Michigan Wolverines are Champions, Go Blue!"))
|