|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad') |
|
|
|
|
|
def main(): |
|
st.title("Question Answering Chat App") |
|
|
|
|
|
context = st.text_area("Enter the context:", """ |
|
Extractive Question Answering is the task of extracting an answer from a text given a question. |
|
""") |
|
|
|
|
|
question = st.text_input("Enter your 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() |
|
|