Spaces:
Runtime error
Runtime error
ivan-savchuk
commited on
Commit
β’
cbd24a5
1
Parent(s):
c6434b5
some upgrades and downgrades to test app
Browse files
app.py
CHANGED
@@ -45,20 +45,18 @@ class DocumentSearch:
|
|
45 |
return sorted(results, key=lambda x: x['score'], reverse=True)[:k]
|
46 |
|
47 |
|
48 |
-
enc_path = "ivan-savchuk/msmarco-distilbert-dot-v5-tuned-full-v1"
|
49 |
-
idx_path = "idx_vectors.index"
|
50 |
-
cross_enc_path = "ivan-savchuk/cross-encoder-ms-marco-MiniLM-L-12-v2-tuned_mediqa-v1"
|
51 |
-
docs_path = "docs.json"
|
52 |
-
# get instance of DocumentSearch class
|
53 |
-
surfer = DocumentSearch(
|
54 |
-
labels_path=docs_path,
|
55 |
-
encoder_path=enc_path,
|
56 |
-
index_path=idx_path,
|
57 |
-
cross_encoder_path=cross_enc_path
|
58 |
-
)
|
59 |
-
|
60 |
-
|
61 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
# streamlit part starts here with title
|
63 |
st.title('Medical Search')
|
64 |
# here we have input space
|
@@ -79,13 +77,50 @@ if __name__ == "__main__":
|
|
79 |
with st.container():
|
80 |
# show which query was entered, and what was searching time
|
81 |
st.write(f"**Results Related to:** {query} ({elapsed_time} sec.)")
|
82 |
-
#
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
return sorted(results, key=lambda x: x['score'], reverse=True)[:k]
|
46 |
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
if __name__ == "__main__":
|
49 |
+
enc_path = "ivan-savchuk/msmarco-distilbert-dot-v5-tuned-full-v1"
|
50 |
+
idx_path = "idx_vectors.index"
|
51 |
+
cross_enc_path = "ivan-savchuk/cross-encoder-ms-marco-MiniLM-L-12-v2-tuned_mediqa-v1"
|
52 |
+
docs_path = "docs.json"
|
53 |
+
# get instance of DocumentSearch class
|
54 |
+
surfer = DocumentSearch(
|
55 |
+
labels_path=docs_path,
|
56 |
+
encoder_path=enc_path,
|
57 |
+
index_path=idx_path,
|
58 |
+
cross_encoder_path=cross_enc_path
|
59 |
+
)
|
60 |
# streamlit part starts here with title
|
61 |
st.title('Medical Search')
|
62 |
# here we have input space
|
|
|
77 |
with st.container():
|
78 |
# show which query was entered, and what was searching time
|
79 |
st.write(f"**Results Related to:** {query} ({elapsed_time} sec.)")
|
80 |
+
# answer starts with header
|
81 |
+
st.subheader(f"Answer 1")
|
82 |
+
# cropped answer
|
83 |
+
doc = results[0]["doc"][:150] + "..."
|
84 |
+
# and url to the full answer
|
85 |
+
url = answer[0]["url"]
|
86 |
+
# then we display it
|
87 |
+
st.markdown(f"{doc}\n[<span style=\"color:blue\">**Read More**</span>]({url})\n")
|
88 |
+
|
89 |
+
# answer starts with header
|
90 |
+
st.subheader(f"Answer 2")
|
91 |
+
# cropped answer
|
92 |
+
doc = results[1]["doc"][:150] + "..."
|
93 |
+
# and url to the full answer
|
94 |
+
url = answer[1]["url"]
|
95 |
+
# then we display it
|
96 |
+
st.markdown(f"{doc}\n[<span style=\"color:blue\">**Read More**</span>]({url})\n")
|
97 |
+
|
98 |
+
# answer starts with header
|
99 |
+
st.subheader(f"Answer 3")
|
100 |
+
# cropped answer
|
101 |
+
doc = results[2]["doc"][:150] + "..."
|
102 |
+
# and url to the full answer
|
103 |
+
url = answer[2]["url"]
|
104 |
+
# then we display it
|
105 |
+
st.markdown(f"{doc}\n[<span style=\"color:blue\">**Read More**</span>]({url})\n")
|
106 |
+
|
107 |
+
# answer starts with header
|
108 |
+
st.subheader(f"Answer 4")
|
109 |
+
# cropped answer
|
110 |
+
doc = results[3]["doc"][:150] + "..."
|
111 |
+
# and url to the full answer
|
112 |
+
url = answer[3]["url"]
|
113 |
+
# then we display it
|
114 |
+
st.markdown(f"{doc}\n[<span style=\"color:blue\">**Read More**</span>]({url})\n")
|
115 |
+
|
116 |
+
# answer starts with header
|
117 |
+
st.subheader(f"Answer 5")
|
118 |
+
# cropped answer
|
119 |
+
doc = results[4]["doc"][:150] + "..."
|
120 |
+
# and url to the full answer
|
121 |
+
url = answer[4]["url"]
|
122 |
+
# then we display it
|
123 |
+
st.markdown(f"{doc}\n[<span style=\"color:blue\">**Read More**</span>]({url})\n")
|
124 |
+
|
125 |
+
st.markdown("---")
|
126 |
+
st.markdown("Author: Ivan Savchuk. 2022")
|