nguyennghia0902 commited on
Commit
b336ee6
1 Parent(s): 8821400

Update QuestionAnswering.py

Browse files
Files changed (1) hide show
  1. QuestionAnswering.py +5 -5
QuestionAnswering.py CHANGED
@@ -3,7 +3,7 @@ import streamlit as st
3
  import tensorflow as tf
4
  from transformers import ElectraTokenizerFast, TFElectraForQuestionAnswering
5
 
6
- model_hf = 'nguyennghia0902/bestfailed_electra-small-discriminator_5e-05_16'
7
  tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
8
  reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
9
 
@@ -27,7 +27,7 @@ def main():
27
  col1, col2 = st.columns([2, 1])
28
  col1.title("Question Answering")
29
 
30
- col2.link_button("Explore my model", 'https://huggingface.co/'+model_hf)
31
 
32
  question = st.text_area(
33
  "QUESTION: Please enter a question:",
@@ -42,16 +42,16 @@ def main():
42
 
43
  prediction = ""
44
 
45
- upload_file = st.file_uploader("CONTEXT: Or upload a file with some contexts", type=["txt"])
46
  if upload_file is not None:
47
- text = upload_file.read().decode("utf-8")
48
 
49
  for line in text.splitlines():
50
  line = line.strip()
51
  if not line:
52
  continue
53
 
54
- prediction = predict(question, line)
55
 
56
  st.success(line + "\n\n" + prediction)
57
 
 
3
  import tensorflow as tf
4
  from transformers import ElectraTokenizerFast, TFElectraForQuestionAnswering
5
 
6
+ model_hf = "nguyennghia0902/bestfailed_electra-small-discriminator_5e-05_16"
7
  tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
8
  reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
9
 
 
27
  col1, col2 = st.columns([2, 1])
28
  col1.title("Question Answering")
29
 
30
+ col2.link_button("Explore my model", "https://huggingface.co/"+model_hf)
31
 
32
  question = st.text_area(
33
  "QUESTION: Please enter a question:",
 
42
 
43
  prediction = ""
44
 
45
+ upload_file = st.file_uploader("CONTEXT: Or upload a file with some questions", type=["txt"])
46
  if upload_file is not None:
47
+ question = upload_file.read().decode("utf-8")
48
 
49
  for line in text.splitlines():
50
  line = line.strip()
51
  if not line:
52
  continue
53
 
54
+ prediction = predict(line, text)
55
 
56
  st.success(line + "\n\n" + prediction)
57