Spaces:
Sleeping
Sleeping
File size: 1,190 Bytes
1d70192 8678a4f 1d70192 50c7e7d c2b0d11 50c7e7d 1d70192 50c7e7d 1d70192 c8b2231 50c7e7d 1d70192 50c7e7d 1d70192 c8b2231 c2b0d11 50c7e7d 416be73 50c7e7d 1d70192 c8b2231 1d70192 c8b2231 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import streamlit as st
from transformers import pipeline
# Define the path to the saved model
model_path = './QAModel' # Path to your fine-tuned model
# Load the question-answering pipeline
qa_pipeline = pipeline("question-answering", model=model_path, tokenizer=model_path)
# Set the title for the Streamlit app
st.title("Movie Trivia Question Answering")
# Text inputs for the user
context = st.text_area("Enter the context (movie-related text):")
question = st.text_area("Enter your question:")
def generate_answer(question, context):
# Perform question answering
result = qa_pipeline(question=question, context=context)
return result['answer']
if st.button("Get Answer"):
if context and question:
generated_answer = generate_answer(question, context)
# Display the generated answer
st.subheader("Answer")
st.write(generated_answer)
else:
st.warning("Please enter both context and question.")
# Optionally, add instructions or information about the app
st.write("""
Enter a movie-related context and a question related to the context above. The model will provide the answer based on the context provided.
""")
|