Spaces:
Runtime error
Runtime error
ariana sutanto
commited on
Commit
•
6e534aa
1
Parent(s):
6ac1f1c
message
Browse files
app.py
CHANGED
@@ -26,21 +26,21 @@ for i in range(0, 20):
|
|
26 |
claims[dataset['patent_number'][i]] = dataset['claims'][i]
|
27 |
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
|
43 |
-
|
44 |
|
45 |
|
46 |
|
@@ -49,7 +49,8 @@ patent_num = st.selectbox("Choose a patent number", options=abstracts.keys())
|
|
49 |
if st.button("Submit"):
|
50 |
abstract = st.text_area(label="Abstract",value=abstracts[patent_num])
|
51 |
claim = st.text_area(label="Claims",value=claims[patent_num])
|
52 |
-
|
|
|
53 |
|
54 |
|
55 |
#abstract = abstracts[patent_num]
|
|
|
26 |
claims[dataset['patent_number'][i]] = dataset['claims'][i]
|
27 |
|
28 |
|
29 |
+
def get_score(abstract):
|
30 |
|
31 |
+
model = AutoModelForSequenceClassification.from_pretrained("arianasutanto/finetuned-distilbert")
|
32 |
+
tokenizer = AutoTokenizer.from_pretrained("arianasutanto/finetuned-distilbert", pad_to_max_length=True)
|
33 |
+
inputs = tokenizer(abstract, max_length=512, padding='max_length', truncation=True, return_tensors='pt')
|
34 |
|
35 |
+
outputs = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
36 |
+
scores = torch.softmax(outputs.logits, dim=1)[0]
|
37 |
|
38 |
+
probs = F.softmax(scores, dim=0)
|
39 |
+
accept_prob = probs[0].item()
|
40 |
|
41 |
+
print(accept_prob)
|
42 |
|
43 |
+
return accept_prob
|
44 |
|
45 |
|
46 |
|
|
|
49 |
if st.button("Submit"):
|
50 |
abstract = st.text_area(label="Abstract",value=abstracts[patent_num])
|
51 |
claim = st.text_area(label="Claims",value=claims[patent_num])
|
52 |
+
predictability = get_score(abstract)
|
53 |
+
st.write(predictability)
|
54 |
|
55 |
|
56 |
#abstract = abstracts[patent_num]
|