shripadbhat commited on
Commit
37b8d56
·
1 Parent(s): 747926d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  from transformers import pipeline
3
  from sentence_transformers import CrossEncoder
4
 
@@ -17,9 +18,9 @@ def fetch_answers(question, clincal_note ):
17
  top_5_query_paragraph_answer_list = []
18
  for query, passage in top_5_query_paragraph_list:
19
  answer = qa_model(question = query, context = passage)['answer']
20
- top_5_query_paragraph_answer_list.append([query, passage, answer])
21
 
22
- return top_5_query_paragraph_answer_list
23
 
24
  demo = gr.Interface(
25
  fn=fetch_answers,
@@ -27,7 +28,7 @@ demo = gr.Interface(
27
  #clinical note upload as file (.This is an example of simple text. or doc/docx file)
28
  inputs=[gr.Textbox(lines=2, label='Question', show_label=True, placeholder="What is age of patient ?"),
29
  gr.Textbox(lines=10, label='Clinical Note', show_label=True, placeholder="The patient is a 71 year old male...")],
30
- outputs="text",
31
  examples='.',
32
  title='Question Answering System from Clinical Notes for Physicians',
33
  description="""Physicians frequently seek answers to questions from a patient’s EHR to support clinical decision-making.​ It is not too hard to imagine a future where a physician interacts with an EHR system and asks it complex questions and expects precise answers with adequate context from a patient’s past clinical notes. ​Central to such a world is a medical question answering system that processes natural language questions asked by physicians and finds answers to the questions from all sources in a patient’s record."""
 
1
  import gradio as gr
2
+ import pandas as pd
3
  from transformers import pipeline
4
  from sentence_transformers import CrossEncoder
5
 
 
18
  top_5_query_paragraph_answer_list = []
19
  for query, passage in top_5_query_paragraph_list:
20
  answer = qa_model(question = query, context = passage)['answer']
21
+ top_5_query_paragraph_answer_list.append([passage, answer])
22
 
23
+ return pd.DataFrame(data = top_5_query_paragraph_answer_list, columns=['Relevant Paragraph', 'Extracted Answer'])
24
 
25
  demo = gr.Interface(
26
  fn=fetch_answers,
 
28
  #clinical note upload as file (.This is an example of simple text. or doc/docx file)
29
  inputs=[gr.Textbox(lines=2, label='Question', show_label=True, placeholder="What is age of patient ?"),
30
  gr.Textbox(lines=10, label='Clinical Note', show_label=True, placeholder="The patient is a 71 year old male...")],
31
+ outputs="dataframe",
32
  examples='.',
33
  title='Question Answering System from Clinical Notes for Physicians',
34
  description="""Physicians frequently seek answers to questions from a patient’s EHR to support clinical decision-making.​ It is not too hard to imagine a future where a physician interacts with an EHR system and asks it complex questions and expects precise answers with adequate context from a patient’s past clinical notes. ​Central to such a world is a medical question answering system that processes natural language questions asked by physicians and finds answers to the questions from all sources in a patient’s record."""