Spaces:
Runtime error
Runtime error
samarthagarwal23
commited on
Commit
•
0418be5
1
Parent(s):
c379db0
Update app.py
Browse files
app.py
CHANGED
@@ -51,7 +51,7 @@ def retrieval(query, top_k_retriver, docs, bm25_):
|
|
51 |
|
52 |
return bm25_hits
|
53 |
|
54 |
-
def qa_ranker(query, docs_, top_k_ranker):
|
55 |
ans = []
|
56 |
for doc in docs_:
|
57 |
answer = qa_model(question = query,
|
@@ -91,7 +91,7 @@ def final_qa_pipeline(file, query, model_nm):
|
|
91 |
model = "deepset/"+ str(model_nm))
|
92 |
|
93 |
if len(lvl1) > 0:
|
94 |
-
fnl_rank = qa_ranker(query, [l["docs"] for l in lvl1], top_k_ranker)
|
95 |
top1 = print_colored(fnl_rank[0]['doc'], fnl_rank[0]['start'], fnl_rank[0]['end'], str(np.round(100*fnl_rank[0]["score"],1))+"%")
|
96 |
if len(lvl1)>1:
|
97 |
top2 = print_colored(fnl_rank[1]['doc'], fnl_rank[1]['start'], fnl_rank[1]['end'], str(np.round(100*fnl_rank[1]["score"],1))+"%")
|
|
|
51 |
|
52 |
return bm25_hits
|
53 |
|
54 |
+
def qa_ranker(query, docs_, top_k_ranker, qa_model):
|
55 |
ans = []
|
56 |
for doc in docs_:
|
57 |
answer = qa_model(question = query,
|
|
|
91 |
model = "deepset/"+ str(model_nm))
|
92 |
|
93 |
if len(lvl1) > 0:
|
94 |
+
fnl_rank = qa_ranker(query, [l["docs"] for l in lvl1], top_k_ranker,qa_model)
|
95 |
top1 = print_colored(fnl_rank[0]['doc'], fnl_rank[0]['start'], fnl_rank[0]['end'], str(np.round(100*fnl_rank[0]["score"],1))+"%")
|
96 |
if len(lvl1)>1:
|
97 |
top2 = print_colored(fnl_rank[1]['doc'], fnl_rank[1]['start'], fnl_rank[1]['end'], str(np.round(100*fnl_rank[1]["score"],1))+"%")
|