Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -318,33 +318,26 @@ bm25_retriever = BM25Retriever(index_dir="output/bm25_index_b")
|
|
318 |
|
319 |
corpus_dict = {doc.collection_id: doc.text for doc in sciq.corpus}
|
320 |
|
321 |
-
|
322 |
-
def search(query: str) -> List[Hit]:
|
323 |
-
# Replace the following placeholder with actual retrieval logic
|
324 |
results = bm25_retriever.retrieve(query)
|
325 |
hits = [
|
326 |
{
|
327 |
"cid": cid,
|
328 |
"score": score,
|
329 |
-
"text": corpus_dict[cid]
|
330 |
}
|
331 |
for cid, score in results.items()
|
332 |
]
|
333 |
return hits
|
334 |
|
335 |
-
|
336 |
-
|
337 |
-
return results
|
338 |
-
|
339 |
-
|
340 |
demo = gr.Interface(
|
341 |
-
fn=
|
342 |
-
inputs=gr.Textbox(label="Enter your
|
343 |
-
outputs=gr.Textbox(label="
|
344 |
-
title="BM25
|
345 |
-
description="Enter your search query to get the results from the SciQ dataset." # Description
|
346 |
)
|
347 |
-
|
348 |
-
|
349 |
-
demo.launch(debug=True)
|
350 |
|
|
|
318 |
|
319 |
corpus_dict = {doc.collection_id: doc.text for doc in sciq.corpus}
|
320 |
|
321 |
+
def get_query(query):
|
|
|
|
|
322 |
results = bm25_retriever.retrieve(query)
|
323 |
hits = [
|
324 |
{
|
325 |
"cid": cid,
|
326 |
"score": score,
|
327 |
+
"text": corpus_dict[cid]
|
328 |
}
|
329 |
for cid, score in results.items()
|
330 |
]
|
331 |
return hits
|
332 |
|
333 |
+
|
334 |
+
|
|
|
|
|
|
|
335 |
demo = gr.Interface(
|
336 |
+
fn=get_query,
|
337 |
+
inputs=gr.Textbox(label="Enter your query"),
|
338 |
+
outputs=gr.Textbox(label="Results", lines=20, interactive=False),
|
339 |
+
title="BM25 Query Engine"
|
|
|
340 |
)
|
341 |
+
## YOUR_CODE_ENDS_HERE
|
342 |
+
demo.launch()
|
|
|
343 |
|