kxx-kkk commited on
Commit
4feffcd
1 Parent(s): 9f96f81

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -21,15 +21,17 @@ def question_model():
21
  question_answerer = pipeline("question-answering", model=model, tokenizer=tokenizer)
22
  return question_answerer
23
 
 
24
  def question_answering(context, question):
25
  with st.spinner(text="Loading question model..."):
26
  question_answerer = question_model()
27
  with st.spinner(text="Getting answer..."):
28
  answer = question_answerer(context=context, question=question)
 
29
  answer = answer["answer"]
30
  # display the result in container
31
  container = st.container(border=True)
32
- container.write("<h5><b>Answer:</b></h5>" + answer + "<br>", unsafe_allow_html=True)
33
 
34
  # choose the source with different tabs
35
  tab1, tab2 = st.tabs(["Input text", "Upload File"])
 
21
  question_answerer = pipeline("question-answering", model=model, tokenizer=tokenizer)
22
  return question_answerer
23
 
24
+ # get the answer by passing the context & question to the model
25
  def question_answering(context, question):
26
  with st.spinner(text="Loading question model..."):
27
  question_answerer = question_model()
28
  with st.spinner(text="Getting answer..."):
29
  answer = question_answerer(context=context, question=question)
30
+ answer_score = answer["score"]
31
  answer = answer["answer"]
32
  # display the result in container
33
  container = st.container(border=True)
34
+ container.write("<h5><b>Answer:</b></h5>" + answer + "<br><p>F1 score: " + answer_score + "</p><br>", unsafe_allow_html=True)
35
 
36
  # choose the source with different tabs
37
  tab1, tab2 = st.tabs(["Input text", "Upload File"])