Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ if st.button('Run semantic question answering'):
|
|
28 |
top_5_text = [{'text': hit['_source']['content'][:500],
|
29 |
'confidence': hit['_score']} for hit in top_5_hits ]
|
30 |
top_3_para = [hit['_source']['content'][:5000] for hit in top_5_hits[:3]]
|
31 |
-
top_5_para = [hit['_source']['content'][:5000] for hit in top_5_hits]
|
32 |
|
33 |
DPR_MODEL = "deepset/roberta-base-squad2" #, model="distilbert-base-cased-distilled-squad"
|
34 |
pipe_exqa = pipeline("question-answering", model=DPR_MODEL)
|
@@ -43,7 +43,7 @@ if st.button('Run semantic question answering'):
|
|
43 |
start_par, stop_para = max(0, qa_result["start"]-86), min(qa_result["end"]+90, len(paragraph))
|
44 |
answer_context = paragraph[start_par:stop_para].replace(answer_span, f'**{answer_span}**')
|
45 |
st.write(f'Answer context (and score): ... _{answer_context}_ ...')
|
46 |
-
color_string = 'green' if answer_score > 0.65 else '
|
47 |
# st.markdown("""This text is :red[colored red]""")
|
48 |
st.markdown(f'(answer confidence: :{color_string}[{format(answer_score, ".3f")}])')
|
49 |
|
|
|
28 |
top_5_text = [{'text': hit['_source']['content'][:500],
|
29 |
'confidence': hit['_score']} for hit in top_5_hits ]
|
30 |
top_3_para = [hit['_source']['content'][:5000] for hit in top_5_hits[:3]]
|
31 |
+
# top_5_para = [hit['_source']['content'][:5000] for hit in top_5_hits]
|
32 |
|
33 |
DPR_MODEL = "deepset/roberta-base-squad2" #, model="distilbert-base-cased-distilled-squad"
|
34 |
pipe_exqa = pipeline("question-answering", model=DPR_MODEL)
|
|
|
43 |
start_par, stop_para = max(0, qa_result["start"]-86), min(qa_result["end"]+90, len(paragraph))
|
44 |
answer_context = paragraph[start_par:stop_para].replace(answer_span, f'**{answer_span}**')
|
45 |
st.write(f'Answer context (and score): ... _{answer_context}_ ...')
|
46 |
+
color_string = 'green' if answer_score > 0.65 else 'orange' if answer_score > 0.45 else 'red'
|
47 |
# st.markdown("""This text is :red[colored red]""")
|
48 |
st.markdown(f'(answer confidence: :{color_string}[{format(answer_score, ".3f")}])')
|
49 |
|