kumo24 commited on
Commit
70da1c1
·
verified ·
1 Parent(s): fabbd0a

Update README.md

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