Spaces:
Runtime error
Runtime error
File size: 1,306 Bytes
d5030e7 752965a d5030e7 752965a d0cd232 d5030e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import streamlit as st
import os
# st.title('Ask Me Anything π')
st.markdown("<h1 style='text-align: center; color: white;'>Ask Me Anything π</h1>", unsafe_allow_html=True)
st.markdown('')
st.markdown('')
st.session_state['new']=True
# if st.session_state.new==True:
# os.system('!pip install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio===0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html')
# os.system('!pip install transformers')
# st.session_state.new=False
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
form = st.form(key='my_form')
# creating the q/a pipeline
nlp = pipeline('question-answering', model='deepset/roberta-base-squad2', tokenizer='deepset/roberta-base-squad2')
text = form.text_area('Gimme Stuff To Study π')
submit_button = form.form_submit_button(label='Study This')
st.markdown('---')
ques=st.text_input('Ask Me Anything From The Information You Have Given')
#forming a question directory
ques_dict = {
'question':ques,
'context':text
}
butt = st.button('Ask π€·π»')
if butt==True:
results = nlp(ques_dict)
st.markdown('---')
st.subheader('Here Is Your Answer')
st.success(results['answer'])
st.balloons()
|