Spaces:
Sleeping
Sleeping
import streamlit as st | |
import torch | |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline | |
# Load the question answering pipeline | |
question_answerer = pipeline("question-answering", model="finetuning_squad/checkpoint-16000") | |
# Streamlit app | |
st.title("Question Answering App") | |
# Text box for context | |
context = st.text_area("Enter Context", "") | |
# Text box for question | |
question = st.text_input("Enter Question", "") | |
# Button to find the answer | |
if st.button("Find Answer"): | |
if context and question: | |
# Perform question answering | |
answer = question_answerer(context=context, question=question) | |
# Display the answer | |
st.subheader("Answer:") | |
st.write(answer) | |
else: | |
st.warning("Please enter both context and question.") |