Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,7 +65,7 @@ with open(embedding_cache_path, "rb") as fIn:
|
|
| 65 |
# This function will search all wikipedia articles for passages that
|
| 66 |
# answer the query
|
| 67 |
def search(query):
|
| 68 |
-
st.
|
| 69 |
##### Sematic Search #####
|
| 70 |
# Encode the query using the bi-encoder and find potentially relevant passages
|
| 71 |
query_embedding = bi_encoder.encode(query, convert_to_tensor=True)
|
|
@@ -82,18 +82,18 @@ def search(query):
|
|
| 82 |
hits[idx]['cross-score'] = cross_scores[idx]
|
| 83 |
|
| 84 |
# Output of top-10 hits from bi-encoder
|
| 85 |
-
st.
|
| 86 |
-
st.
|
| 87 |
hits = sorted(hits, key=lambda x: x['score'], reverse=True)
|
| 88 |
for hit in hits[0:10]:
|
| 89 |
-
st.
|
| 90 |
|
| 91 |
# Output of top-10 hits from re-ranker
|
| 92 |
-
st.
|
| 93 |
-
st.
|
| 94 |
hits = sorted(hits, key=lambda x: x['cross-score'], reverse=True)
|
| 95 |
for hit in hits[0:10]:
|
| 96 |
-
st.
|
| 97 |
|
| 98 |
st.write("## Results:")
|
| 99 |
if st.button('Generate Sentence'):
|
|
|
|
| 65 |
# This function will search all wikipedia articles for passages that
|
| 66 |
# answer the query
|
| 67 |
def search(query):
|
| 68 |
+
st.write("Input question:", query)
|
| 69 |
##### Sematic Search #####
|
| 70 |
# Encode the query using the bi-encoder and find potentially relevant passages
|
| 71 |
query_embedding = bi_encoder.encode(query, convert_to_tensor=True)
|
|
|
|
| 82 |
hits[idx]['cross-score'] = cross_scores[idx]
|
| 83 |
|
| 84 |
# Output of top-10 hits from bi-encoder
|
| 85 |
+
st.write("\n-------------------------\n")
|
| 86 |
+
st.write("Top-10 Bi-Encoder Retrieval hits")
|
| 87 |
hits = sorted(hits, key=lambda x: x['score'], reverse=True)
|
| 88 |
for hit in hits[0:10]:
|
| 89 |
+
st.write("\t{:.3f}\t{}".format(hit['score'], passages[hit['corpus_id']].replace("\n", " ")))
|
| 90 |
|
| 91 |
# Output of top-10 hits from re-ranker
|
| 92 |
+
st.write("\n-------------------------\n")
|
| 93 |
+
st.write("Top-10 Cross-Encoder Re-ranker hits")
|
| 94 |
hits = sorted(hits, key=lambda x: x['cross-score'], reverse=True)
|
| 95 |
for hit in hits[0:10]:
|
| 96 |
+
st.write("\t{:.3f}\t{}".format(hit['cross-score'], passages[hit['corpus_id']].replace("\n", " ")))
|
| 97 |
|
| 98 |
st.write("## Results:")
|
| 99 |
if st.button('Generate Sentence'):
|