Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
# Initialize question-answering pipeline | |
qa_model = pipeline("question-answering", model="distilbert-base-cased-distilled-squad") | |
st.title("Question-Answering System") | |
st.write("Provide a paragraph and ask a question to get an answer.") | |
context = st.text_area("Enter the context paragraph:", placeholder="Paste your context here...") | |
question = st.text_input("Enter your question:", placeholder="Ask something about the context...") | |
if st.button("Get Answer"): | |
if not context.strip() or not question.strip(): | |
st.error("Please provide both a context and a question.") | |
else: | |
with st.spinner("Finding the answer..."): | |
answer = qa_model(question=question, context=context) | |
st.subheader("Answer:") | |
st.write(answer["answer"]) | |