Spaces:
Runtime error
Runtime error
ariana sutanto
commited on
Commit
•
24a6037
1
Parent(s):
3f8d355
message
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from datasets import load_dataset
|
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
4 |
import torch.nn.functional as F
|
5 |
import torch
|
|
|
6 |
|
7 |
dataset_dict = load_dataset('HUPD/hupd',
|
8 |
name='sample',
|
@@ -37,11 +38,22 @@ for i in range(0, 20):
|
|
37 |
|
38 |
def get_score(abstract):
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
return
|
45 |
|
46 |
|
47 |
|
|
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
4 |
import torch.nn.functional as F
|
5 |
import torch
|
6 |
+
import numpy as np
|
7 |
|
8 |
dataset_dict = load_dataset('HUPD/hupd',
|
9 |
name='sample',
|
|
|
38 |
|
39 |
def get_score(abstract):
|
40 |
|
41 |
+
model = AutoModelForSequenceClassification.from_pretrained("arianasutanto/finetuned-distilbert")
|
42 |
+
tokenizer = AutoTokenizer.from_pretrained("arianasutanto/finetuned-distilbert", pad_to_max_length=True)
|
43 |
+
|
44 |
+
inputs = tokenizer(abstract, padding='max_length', truncation=True, return_tensors='pt')
|
45 |
+
|
46 |
+
with torch.no_grad():
|
47 |
+
logits = model(**inputs).logits
|
48 |
+
print(logits)
|
49 |
+
|
50 |
+
predictions = F.softmax(logits, 0)
|
51 |
+
idk = np.argmax(predictions, 0)
|
52 |
+
print(predictions)
|
53 |
+
print(idk)
|
54 |
+
|
55 |
|
56 |
+
return logits
|
57 |
|
58 |
|
59 |
|