Spaces:
Runtime error
Runtime error
File size: 884 Bytes
4f7e359 |
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 |
'''Hugging Face'''
import streamlit as st
from transformers import pipeline
if __name__ == "__main__":
# Define the title of the and its description
st.title("Answering questions using NLP through Streamlit interface")
st.write("Pose questions, get answers")
# Load file
raw_text = st.text_area(label="Enter a text here")
if raw_text != None and raw_text != '':
# Display text
with st.expander("Show question"):
st.write(raw_text)
# Conduct question answering using the pipeline
question_answerer = pipeline('question-answering')
answer = ''
question = st.text_input('Ask a question')
if question != '' and raw_text != '':
answer = question_answerer({
'question': question,
'context': raw_text
})
st.write(answer)
|