import streamlit as st from transformers import pipeline # Load the QnA pipeline with a chosen model qa_pipeline = pipeline("question-answering", model = 'bert-large-uncased-whole-word-masking-finetuned-squad') # Streamlit UI st.title("Question and Answer System") st.write("Enter a context and ask a question to get an answer.") # Input from the user context = st.text_area("Context:", "") question = st.text_input("Your question:", "") # Generate a response when the button is clicked if st.button("Get Answer"): if context.strip() and question.strip(): result = qa_pipeline(question=question, context=context) st.write("Answer:") st.write(result['answer']) else: st.write("Please enter both context and a question.")