| import streamlit as st |
| from transformers import pipeline |
|
|
| pipe = pipeline("text2text-generation", model="google/flan-t5-base") |
|
|
| def generate_answer(question): |
| """Generates an answer to a question using the T5 language model.""" |
|
|
| answer = pipe(question, max_length=100, num_return_sequences=1)[0] |
| return answer |
|
|
| st.markdown( |
| f""" |
| <style> |
| body {{ |
| background-image: url("BK.jpg"); |
| background-size: cover; |
| }} |
| </style> |
| """, |
| unsafe_allow_html=True, |
| ) |
|
|
|
|
| st.title("Question Answering App") |
|
|
| question = st.text_input("Ask me a question:") |
|
|
| if question: |
| answer = generate_answer(question) |
|
|
| st.markdown(f"**Answer:** {answer}") |
|
|
| else: |
| st.markdown("Please ask me a question.") |
|
|