Spaces:
Runtime error
Runtime error
update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
@st.cache(allow_output_mutation=True)
|
| 5 |
+
def load_qa_model():
|
| 6 |
+
model = pipeline("question-answering")
|
| 7 |
+
return model
|
| 8 |
+
|
| 9 |
+
qa = load_qa_model()
|
| 10 |
+
st.title("Ask Questions about your Text")
|
| 11 |
+
sentence = st.text_area('Please paste your article :', height=30)
|
| 12 |
+
question = st.text_input("Questions from this article?")
|
| 13 |
+
button = st.button("Get me Answers")
|
| 14 |
+
max = st.sidebar.slider('Select max', 50, 500, step=10, value=150)
|
| 15 |
+
min = st.sidebar.slider('Select min', 10, 450, step=10, value=50)
|
| 16 |
+
do_sample = st.sidebar.checkbox("Do sample", value=False)
|
| 17 |
+
with st.spinner("Discovering Answers.."):
|
| 18 |
+
if button and sentence:
|
| 19 |
+
answers = qa(question=question, context=sentence)
|
| 20 |
+
st.write(answers['answer'])
|