Spaces:
Runtime error
Runtime error
ariana sutanto
commited on
Commit
·
d2903dd
1
Parent(s):
fe665ce
message
Browse files
app.py
CHANGED
|
@@ -30,38 +30,11 @@ for i in range(0, 20):
|
|
| 30 |
|
| 31 |
def get_score(abstract):
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
inputs = tokenizer(abstract, padding='max_length', truncation=True, return_tensors='pt')
|
| 37 |
-
|
| 38 |
-
with torch.no_grad():
|
| 39 |
-
logits = model(**inputs).logits
|
| 40 |
-
print(logits)
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
outputs = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
| 44 |
-
scores = torch.softmax(outputs.logits, dim=1)[0]
|
| 45 |
-
print(scores)
|
| 46 |
-
probs = F.softmax(scores, dim=0)
|
| 47 |
-
print(probs)
|
| 48 |
-
accept_prob = probs[0].item()
|
| 49 |
-
|
| 50 |
-
print(accept_prob)
|
| 51 |
-
|
| 52 |
-
#return #accept_prob
|
| 53 |
-
|
| 54 |
-
#score = F.softmax(outputs.logits, dim=1)
|
| 55 |
-
#print(score)
|
| 56 |
-
|
| 57 |
-
##accept_prob = probs[0].item()
|
| 58 |
-
#model_name = "arianasutanto/finetuned-distilbert"
|
| 59 |
-
|
| 60 |
-
#classifier = pipeline("text-classification", model=model_name)
|
| 61 |
-
#result = classifier(abstract)
|
| 62 |
|
| 63 |
-
|
| 64 |
-
return logits
|
| 65 |
|
| 66 |
|
| 67 |
|
|
@@ -74,8 +47,4 @@ if st.button("Submit"):
|
|
| 74 |
st.write(predictability)
|
| 75 |
|
| 76 |
|
| 77 |
-
#abstract = abstracts[patent_num]
|
| 78 |
-
#st.write(abstract)
|
| 79 |
-
#claim = claims[patent_num]
|
| 80 |
-
#st.write(claim)
|
| 81 |
|
|
|
|
| 30 |
|
| 31 |
def get_score(abstract):
|
| 32 |
|
| 33 |
+
model_name = "arianasutanto/finetuned-distilbert"
|
| 34 |
+
classifier = pipeline("text-classification", model=model_name)
|
| 35 |
+
result = classifier(abstract)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
return result
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
|
|
|
|
| 47 |
st.write(predictability)
|
| 48 |
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|