hardik90's picture
Create app.py
8661662 verified
raw
history blame contribute delete
957 Bytes
import streamlit as st
from transformers import pipeline
# Load the question answering pipeline
question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
# Streamlit app
def main():
st.title("Question Answering Chat App")
# Text input for context
context = st.text_area("Enter the context:", """
Extractive Question Answering is the task of extracting an answer from a text given a question.
""")
# Text input for question
question = st.text_input("Enter your question:")
# Answer the question
if st.button("Get Answer"):
result = question_answerer(question=question, context=context)
st.subheader("Answer:")
st.write(result['answer'])
st.subheader("Details:")
st.write(f"Score: {round(result['score'], 4)}")
st.write(f"Start: {result['start']}")
st.write(f"End: {result['end']}")
if __name__ == "__main__":
main()