-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT5.py
20 lines (18 loc) · 774 Bytes
/
T5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streamlit as st
from transformers import pipeline
@st.cache(allow_output_mutation=True)
def load_qa_model():
model = pipeline("question-answering")
return model
qa = load_qa_model()
st.title("Ask Questions about your Text")
sentence = st.text_area('Please paste your article :', height=30)
question = st.text_input("Questions from this article?")
button = st.button("Get me Answers")
max = st.sidebar.slider('Select max', 50, 500, step=10, value=150)
min = st.sidebar.slider('Select min', 10, 450, step=10, value=50)
do_sample = st.sidebar.checkbox("Do sample", value=False)
with st.spinner("Discovering Answers.."):
if button and sentence:
answers = qa(question=question, context=sentence)
st.write(answers['answer'])