awacke1's picture
Create app.py
a63d286
raw
history blame contribute delete
No virus
581 Bytes
import streamlit as st
from transformers import pipeline
st.title("Question Answering with Hugging Face")
model_name = "distilbert-base-cased-distilled-squad"
nlp = pipeline("question-answering", model=model_name)
context = st.text_area("Enter the context here:")
if not context:
st.warning("Please enter a context.")
else:
question = st.text_input("Enter your question here:")
if not question:
st.warning("Please enter a question.")
else:
answer = nlp({"question": question, "context": context})
st.write(f"Answer: {answer['answer']}")