Spaces:
Sleeping
Sleeping
dbleek
commited on
Commit
·
38aee5a
1
Parent(s):
0d30c2b
slight tweaks to code and README
Browse files- README.md +1 -1
- milestone-3.py +3 -5
README.md
CHANGED
|
@@ -11,7 +11,7 @@ pinned: false
|
|
| 11 |
Project for CS-GY-6613 Spring 2023
|
| 12 |
|
| 13 |
# Milestone 3
|
| 14 |
-
USPTO Patentability Classifier:https://huggingface.co/spaces/dbleek/cs-gy-6613-project
|
| 15 |
|
| 16 |
# Milestone 2
|
| 17 |
Sentiment Analysis App:https://huggingface.co/spaces/dbleek/cs-gy-6613-project
|
|
|
|
| 11 |
Project for CS-GY-6613 Spring 2023
|
| 12 |
|
| 13 |
# Milestone 3
|
| 14 |
+
USPTO Patentability Classifier:https://huggingface.co/spaces/dbleek/cs-gy-6613-project-final
|
| 15 |
|
| 16 |
# Milestone 2
|
| 17 |
Sentiment Analysis App:https://huggingface.co/spaces/dbleek/cs-gy-6613-project
|
milestone-3.py
CHANGED
|
@@ -31,7 +31,6 @@ dataset = dataset.sort("patent_number")
|
|
| 31 |
model = torch.load("patent_classifier_v4.pt", map_location=torch.device("cpu"))
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
|
| 33 |
tokenizer_kwargs = {'padding':True,'truncation':True}
|
| 34 |
-
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer, **tokenizer_kwargs)
|
| 35 |
|
| 36 |
def load_data():
|
| 37 |
selected_application = dataset.select([applications[st.session_state.id]])
|
|
@@ -47,11 +46,10 @@ applications = {}
|
|
| 47 |
for ds_index, example in enumerate(dataset):
|
| 48 |
applications.update({example["patent_number"]: ds_index})
|
| 49 |
st.selectbox(
|
| 50 |
-
"Select a sample patent application:", applications, on_change=load_data, key="id"
|
| 51 |
-
)
|
| 52 |
|
| 53 |
# Sample title/decision displayed for additional context only, not used with model
|
| 54 |
-
st.text_input("Sample Title", key="title", value=dataset[0]["title"])
|
| 55 |
st.text_input("Sample Decision", key="decision", value=dataset[0]["decision"])
|
| 56 |
|
| 57 |
# Classifier input form
|
|
@@ -72,7 +70,7 @@ if submitted:
|
|
| 72 |
pred = torch.softmax(logits, dim=1)
|
| 73 |
score = pred[0][1] # index 1 of softmax output is probability that decision = ACCEPTED
|
| 74 |
st.markdown(
|
| 75 |
-
"This application's patentability score is **{}
|
| 76 |
)
|
| 77 |
|
| 78 |
|
|
|
|
| 31 |
model = torch.load("patent_classifier_v4.pt", map_location=torch.device("cpu"))
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
|
| 33 |
tokenizer_kwargs = {'padding':True,'truncation':True}
|
|
|
|
| 34 |
|
| 35 |
def load_data():
|
| 36 |
selected_application = dataset.select([applications[st.session_state.id]])
|
|
|
|
| 46 |
for ds_index, example in enumerate(dataset):
|
| 47 |
applications.update({example["patent_number"]: ds_index})
|
| 48 |
st.selectbox(
|
| 49 |
+
"Select a sample patent application:", applications, on_change=load_data, key="id")
|
|
|
|
| 50 |
|
| 51 |
# Sample title/decision displayed for additional context only, not used with model
|
| 52 |
+
st.text_input("Sample Title", key="title", value=dataset[0]["title"],)
|
| 53 |
st.text_input("Sample Decision", key="decision", value=dataset[0]["decision"])
|
| 54 |
|
| 55 |
# Classifier input form
|
|
|
|
| 70 |
pred = torch.softmax(logits, dim=1)
|
| 71 |
score = pred[0][1] # index 1 of softmax output is probability that decision = ACCEPTED
|
| 72 |
st.markdown(
|
| 73 |
+
"This application's patentability score is **{}**.".format(score)
|
| 74 |
)
|
| 75 |
|
| 76 |
|