Spaces:
Sleeping
Sleeping
Commit
·
18ceb3b
1
Parent(s):
a6237f8
Update pages/answers.py
Browse files- pages/answers.py +4 -11
pages/answers.py
CHANGED
@@ -1,14 +1,7 @@
|
|
1 |
import random
|
2 |
import streamlit as st
|
3 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
4 |
-
from streamlit_extras.let_it_rain import rain
|
5 |
|
6 |
-
rain(
|
7 |
-
emoji="❔",
|
8 |
-
font_size=54,
|
9 |
-
falling_speed=5,
|
10 |
-
animation_length="infinite",
|
11 |
-
)
|
12 |
|
13 |
model_name = "deepset/roberta-base-squad2"
|
14 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
@@ -66,16 +59,16 @@ def main():
|
|
66 |
context_placeholder = "Enter the context here..."
|
67 |
question_placeholder = "Enter the question here..."
|
68 |
|
69 |
-
context = st.text_area("**:blue[Context]**", context_placeholder)
|
70 |
-
question = st.text_input("**:blue[Question]**", question_placeholder)
|
71 |
|
72 |
if st.button(":blue[**Random Example**]"):
|
73 |
pair = random.choice(pairs)
|
74 |
context = pair['context']
|
75 |
question = pair['question']
|
76 |
|
77 |
-
st.text_area("**:blue[Context]**", context)
|
78 |
-
st.text_input("**:blue[Question]**", question)
|
79 |
|
80 |
if st.button(":blue[**Get Answer**]"):
|
81 |
if context.strip() == "" or question.strip() == "":
|
|
|
1 |
import random
|
2 |
import streamlit as st
|
3 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
model_name = "deepset/roberta-base-squad2"
|
7 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
|
|
59 |
context_placeholder = "Enter the context here..."
|
60 |
question_placeholder = "Enter the question here..."
|
61 |
|
62 |
+
context = st.text_area("**:blue[Context]**", value=context_placeholder)
|
63 |
+
question = st.text_input("**:blue[Question]**", value=question_placeholder)
|
64 |
|
65 |
if st.button(":blue[**Random Example**]"):
|
66 |
pair = random.choice(pairs)
|
67 |
context = pair['context']
|
68 |
question = pair['question']
|
69 |
|
70 |
+
st.text_area("**:blue[Context]**", value=context)
|
71 |
+
st.text_input("**:blue[Question]**", value=question)
|
72 |
|
73 |
if st.button(":blue[**Get Answer**]"):
|
74 |
if context.strip() == "" or question.strip() == "":
|