kumo24 commited on
Commit
9796c83
·
verified ·
1 Parent(s): e57f677

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -3
README.md CHANGED
@@ -1,3 +1,37 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ This BERT was fined-tuned on +672k tweets from twitter/X. The classification accuracy obtained is 98%. \
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'
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
+ ```