Alanhau commited on
Commit
5d6dc63
1 Parent(s): da7fbc7

[New] model test code

Browse files
Files changed (1) hide show
  1. model-test.py +11 -0
model-test.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import BertTokenizer, BertForSequenceClassification
2
+ from transformers import pipeline
3
+
4
+ finbert = BertForSequenceClassification.from_pretrained('yiyanghkust/finbert-tone',num_labels=3)
5
+ tokenizer = BertTokenizer.from_pretrained('yiyanghkust/finbert-tone')
6
+
7
+ nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
8
+
9
+ sentences = ["Shit, Limit down!"]
10
+ results = nlp(sentences)
11
+ print(results) #LABEL_0: neutral; LABEL_1: positive; LABEL_2: negative