Update app.py
Browse files
app.py
CHANGED
@@ -141,7 +141,7 @@ def cross_encode():
|
|
141 |
bi_enc_options = ["multi-qa-mpnet-base-dot-v1", "all-mpnet-base-v2", "multi-qa-MiniLM-L6-cos-v1"]
|
142 |
|
143 |
|
144 |
-
def display_as_table(model, top_k, score='score'):
|
145 |
# Display the df with text and scores as a table
|
146 |
df = pd.DataFrame([(hit[score], passages[hit['corpus_id']]) for hit in model[0:top_k]], columns=['Score', 'Text'])
|
147 |
df['Score'] = round(df['Score'], 2)
|
@@ -155,7 +155,7 @@ st.title("Search with Retrieve & Rerank")
|
|
155 |
|
156 |
|
157 |
# This function will search all wikipedia articles for passages that answer the query
|
158 |
-
def search_func(query, top_k=
|
159 |
global bi_encoder, cross_encoder
|
160 |
|
161 |
st.subheader(f"Search Query: {query}")
|
@@ -251,7 +251,7 @@ if search:
|
|
251 |
|
252 |
with st.spinner(
|
253 |
text="Embedding completed, searching for relevant text for given query and hits..."):
|
254 |
-
search_func(search_query, top_k)
|
255 |
|
256 |
st.markdown("""
|
257 |
""")
|
|
|
141 |
bi_enc_options = ["multi-qa-mpnet-base-dot-v1", "all-mpnet-base-v2", "multi-qa-MiniLM-L6-cos-v1"]
|
142 |
|
143 |
|
144 |
+
def display_as_table(model, top_k=2, score='score'):
|
145 |
# Display the df with text and scores as a table
|
146 |
df = pd.DataFrame([(hit[score], passages[hit['corpus_id']]) for hit in model[0:top_k]], columns=['Score', 'Text'])
|
147 |
df['Score'] = round(df['Score'], 2)
|
|
|
155 |
|
156 |
|
157 |
# This function will search all wikipedia articles for passages that answer the query
|
158 |
+
def search_func(query, top_k=2):
|
159 |
global bi_encoder, cross_encoder
|
160 |
|
161 |
st.subheader(f"Search Query: {query}")
|
|
|
251 |
|
252 |
with st.spinner(
|
253 |
text="Embedding completed, searching for relevant text for given query and hits..."):
|
254 |
+
search_func(search_query, top_k=2)
|
255 |
|
256 |
st.markdown("""
|
257 |
""")
|