Update app.py
Browse files
app.py
CHANGED
@@ -532,25 +532,18 @@ class Hit(TypedDict):
|
|
532 |
score: float
|
533 |
text: str
|
534 |
|
535 |
-
# Best b 0.9
|
536 |
-
# Best k1: 0.4
|
537 |
-
best_b = 0.9
|
538 |
-
best_k1 = 0.4
|
539 |
-
sciq = load_sciq()
|
540 |
-
csc_bm25_index = CSCBM25Index.build_from_documents(
|
541 |
-
documents=iter(sciq.corpus),
|
542 |
-
ndocs=12160,
|
543 |
-
show_progress_bar=True,
|
544 |
-
k1=best_k1,
|
545 |
-
b=best_b
|
546 |
-
)
|
547 |
-
csc_bm25_index.save("output/csc_bm25_index")
|
548 |
-
|
549 |
demo: Optional[gr.Interface] = None # Assign your gradio demo to this variable
|
550 |
return_type = List[Hit]
|
551 |
|
552 |
## YOUR_CODE_STARTS_HERE
|
553 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
doc2text = {doc.collection_id: doc.text for doc in sciq.corpus}
|
555 |
|
556 |
def retrieve(query: str) -> List[Hit]:
|
|
|
532 |
score: float
|
533 |
text: str
|
534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
demo: Optional[gr.Interface] = None # Assign your gradio demo to this variable
|
536 |
return_type = List[Hit]
|
537 |
|
538 |
## YOUR_CODE_STARTS_HERE
|
539 |
+
# Use default b, k1
|
540 |
+
csc_bm25_index = CSCBM25Index.build_from_documents(
|
541 |
+
documents=iter(sciq.corpus),
|
542 |
+
ndocs=12160,
|
543 |
+
show_progress_bar=True
|
544 |
+
)
|
545 |
+
csc_bm25_index.save("output/csc_bm25_index_default")
|
546 |
+
csc_bm25_retriever = CSCBM25Retriever(index_dir="output/csc_bm25_index_default")
|
547 |
doc2text = {doc.collection_id: doc.text for doc in sciq.corpus}
|
548 |
|
549 |
def retrieve(query: str) -> List[Hit]:
|