Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -37,10 +37,8 @@ def question_answering(question):
|
|
37 |
query_embedding = st.session_state.model_embedding.encode(query_sentence)
|
38 |
k = 100
|
39 |
D, I = index_loaded.search(query_embedding.astype('float32'), k) # D is distances, I is indices
|
40 |
-
|
41 |
-
|
42 |
-
context = [articles[I[0][i]] for i in range(k)]
|
43 |
-
best_answer = question_answerer(question=query_sentence[0], context= context, max_answer_len = 512)
|
44 |
print(best_answer)
|
45 |
if best_answer['score'] > 0.5:
|
46 |
return best_answer['answer']
|
|
|
37 |
query_embedding = st.session_state.model_embedding.encode(query_sentence)
|
38 |
k = 100
|
39 |
D, I = index_loaded.search(query_embedding.astype('float32'), k) # D is distances, I is indices
|
40 |
+
answer = [question_answerer(question=query_sentence[0], context=articles[I[0][i]], max_answer_len = 512) for i in range(k)]
|
41 |
+
best_answer = max(answer, key=lambda x: x['score'])
|
|
|
|
|
42 |
print(best_answer)
|
43 |
if best_answer['score'] > 0.5:
|
44 |
return best_answer['answer']
|