paragon-analytics
commited on
Commit
•
763e962
1
Parent(s):
18724ca
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import tensorflow as tf
|
3 |
+
from transformers import RobertaTokenizer, RobertaModel
|
4 |
+
from transformers import AutoModelForSequenceClassification
|
5 |
+
from transformers import TFAutoModelForSequenceClassification
|
6 |
+
from transformers import AutoTokenizer
|
7 |
+
# tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("paragon-analytics/bert_empathy")
|
9 |
+
model = AutoModelForSequenceClassification.from_pretrained("paragon-analytics/bert_empathy")
|
10 |
+
|
11 |
+
def roberta(x):
|
12 |
+
encoded_input = tokenizer(x, return_tensors='pt')
|
13 |
+
output = model(**encoded_input)
|
14 |
+
scores = output[0][0].detach().numpy()
|
15 |
+
scores = tf.nn.softmax(scores)
|
16 |
+
return scores.numpy()[1]
|