Spaces:
Runtime error
Runtime error
Commit
·
7daebfc
1
Parent(s):
bbf7aff
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ _patent_id = st.selectbox(
|
|
29 |
|
30 |
|
31 |
# display abstract and claim
|
32 |
-
@st.
|
33 |
def get_abs_claim(_patent_id):
|
34 |
# get abstract and claim corresponding to this patent id
|
35 |
_abstract = dataset_dict["train"][["patent_number"] == _patent_id]["abstract"]
|
@@ -38,20 +38,28 @@ def get_abs_claim(_patent_id):
|
|
38 |
|
39 |
|
40 |
_abstract, _claim = get_abs_claim(_patent_id)
|
41 |
-
st.write(_abstract)
|
42 |
-
st.write(_claim)
|
43 |
|
44 |
-
input_text = _abstract + _claim
|
45 |
|
46 |
# model and tokenizer initialization
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
inputs = tokenizer(
|
49 |
input_text,
|
50 |
truncation=True,
|
51 |
padding=True,
|
52 |
return_tensors="pt",
|
53 |
)
|
54 |
-
model = AutoModelForSequenceClassification.from_pretrained(language_model_path)
|
55 |
|
56 |
# get predictions
|
57 |
id2label = {0: "REJECTED", 1: "ACCEPTED"}
|
|
|
29 |
|
30 |
|
31 |
# display abstract and claim
|
32 |
+
@st.cache_data
|
33 |
def get_abs_claim(_patent_id):
|
34 |
# get abstract and claim corresponding to this patent id
|
35 |
_abstract = dataset_dict["train"][["patent_number"] == _patent_id]["abstract"]
|
|
|
38 |
|
39 |
|
40 |
_abstract, _claim = get_abs_claim(_patent_id)
|
41 |
+
st.write(_abstract) # display abstract
|
42 |
+
st.write(_claim) # display claims
|
43 |
|
|
|
44 |
|
45 |
# model and tokenizer initialization
|
46 |
+
@st.cache_resource
|
47 |
+
def load_model(language_model_path):
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained(language_model_path)
|
49 |
+
model = AutoModelForSequenceClassification.from_pretrained(language_model_path)
|
50 |
+
return tokenizer, model
|
51 |
+
|
52 |
+
|
53 |
+
tokenizer, model = load_model(language_model_path)
|
54 |
+
# input to our model
|
55 |
+
input_text = _abstract + _claim
|
56 |
+
# get tokens
|
57 |
inputs = tokenizer(
|
58 |
input_text,
|
59 |
truncation=True,
|
60 |
padding=True,
|
61 |
return_tensors="pt",
|
62 |
)
|
|
|
63 |
|
64 |
# get predictions
|
65 |
id2label = {0: "REJECTED", 1: "ACCEPTED"}
|