Spaces:
Sleeping
Sleeping
Update pages/answers.py
Browse files- pages/answers.py +15 -6
pages/answers.py
CHANGED
|
@@ -1,7 +1,15 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
|
|
@@ -13,15 +21,16 @@ def get_answer(context, question):
|
|
| 13 |
return answer
|
| 14 |
|
| 15 |
def main():
|
| 16 |
-
st.title("Question Answering App")
|
| 17 |
-
st.
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
-
context = st.text_area("Context", "Enter the context here...")
|
| 21 |
-
question = st.text_input("Question", "Enter the question here...")
|
| 22 |
|
| 23 |
|
| 24 |
-
if st.button("Get Answer"):
|
| 25 |
|
| 26 |
if context.strip() == "" or question.strip() == "":
|
| 27 |
st.warning("Please enter the context and question.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
| 3 |
+
from streamlit_extras.let_it_rain import rain
|
| 4 |
|
| 5 |
+
rain(
|
| 6 |
+
emoji="❔",
|
| 7 |
+
font_size=54,
|
| 8 |
+
falling_speed=5,
|
| 9 |
+
animation_length="infinite",
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
model_name = "deepset/roberta-base-squad2"
|
| 13 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
| 14 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 15 |
|
|
|
|
| 21 |
return answer
|
| 22 |
|
| 23 |
def main():
|
| 24 |
+
st.title("Question Answering App :robot_face:")
|
| 25 |
+
st.divider()
|
| 26 |
+
st.markdown("### **Enter the context and question, then click on ':blue[Get Answer]' to retrieve the answer:**")
|
| 27 |
|
| 28 |
|
| 29 |
+
context = st.text_area("**:blue[Context]**", "Enter the context here...")
|
| 30 |
+
question = st.text_input("**:blue[Question]**", "Enter the question here...")
|
| 31 |
|
| 32 |
|
| 33 |
+
if st.button(":blue[**Get Answer**]"):
|
| 34 |
|
| 35 |
if context.strip() == "" or question.strip() == "":
|
| 36 |
st.warning("Please enter the context and question.")
|