Spaces:
Sleeping
Sleeping
File size: 640 Bytes
df7e06a a07400d 8797167 a07400d cc11973 a07400d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from transformers import AutoModelForQuestionAnswering,AutoTokenizer,pipeline
import streamlit as st
import ast
model_name="deepset/roberta-base-squad2"
pipe=pipeline('question-answering',model=model_name,tokenizer=model_name)
def answer_question(question,context):
text="{"+"'question': '"+question + "','context':'"+context+"'}"
di= ast.literal_eval(text)
response= pipe(di)
return response
st.title("Q&A App")
context = st.text_area("Enter the context:")
question = st.text_input("Enter your question:")
if st.button("Get Answer"):
answer = answer_question(context, question)
st.write(f"Answer: {answer}")
|