Commit
·
bbe3b79
1
Parent(s):
8a521c3
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("paragon-analytics/ADRv1")
|
9 |
+
model = AutoModelForSequenceClassification.from_pretrained("paragon-analytics/ADRv1")
|
10 |
+
|
11 |
+
def adr_predict(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]
|
17 |
+
|
18 |
+
sentence = "I have severe pain."
|
19 |
+
|
20 |
+
adr_predict(sentence)
|