Spaces:
Sleeping
Sleeping
nguyennghia0902
commited on
Commit
•
042b4ce
1
Parent(s):
12d5d83
Update QuestionAnswering.py
Browse files- QuestionAnswering.py +7 -4
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/
|
7 |
tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
|
8 |
reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
|
9 |
|
@@ -32,12 +32,12 @@ def main():
|
|
32 |
question = st.text_area(
|
33 |
"QUESTION: Please enter a question:",
|
34 |
placeholder="Enter your question here",
|
35 |
-
height=
|
36 |
)
|
37 |
text = st.text_area(
|
38 |
"CONTEXT: Please enter a context:",
|
39 |
placeholder="Enter your context here",
|
40 |
-
height=
|
41 |
)
|
42 |
|
43 |
prediction = ""
|
@@ -69,7 +69,10 @@ def main():
|
|
69 |
return
|
70 |
|
71 |
prediction = predict(stripped_question, stripped_text)
|
72 |
-
|
|
|
|
|
|
|
73 |
|
74 |
if __name__ == "__main__":
|
75 |
main()
|
|
|
3 |
import tensorflow as tf
|
4 |
from transformers import ElectraTokenizerFast, TFElectraForQuestionAnswering
|
5 |
|
6 |
+
model_hf = "nguyennghia0902/electra-small-discriminator_0.0005_32"
|
7 |
tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
|
8 |
reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
|
9 |
|
|
|
32 |
question = st.text_area(
|
33 |
"QUESTION: Please enter a question:",
|
34 |
placeholder="Enter your question here",
|
35 |
+
height=5,
|
36 |
)
|
37 |
text = st.text_area(
|
38 |
"CONTEXT: Please enter a context:",
|
39 |
placeholder="Enter your context here",
|
40 |
+
height=200,
|
41 |
)
|
42 |
|
43 |
prediction = ""
|
|
|
69 |
return
|
70 |
|
71 |
prediction = predict(stripped_question, stripped_text)
|
72 |
+
if prediction == "":
|
73 |
+
st.error(prediction)
|
74 |
+
else:
|
75 |
+
st.success(prediction)
|
76 |
|
77 |
if __name__ == "__main__":
|
78 |
main()
|