Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 5 |
+
|
| 6 |
+
def generate_answer(question):
|
| 7 |
+
"""Generates an answer to a question using the T5 language model."""
|
| 8 |
+
|
| 9 |
+
answer = pipe(question, max_length=100, num_return_sequences=1)[0]
|
| 10 |
+
return answer
|
| 11 |
+
|
| 12 |
+
st.set_page_bg_image("BK.jpg")
|
| 13 |
+
|
| 14 |
+
st.title("Question Answering App")
|
| 15 |
+
|
| 16 |
+
question = st.text_input("Ask me a question:")
|
| 17 |
+
|
| 18 |
+
if question:
|
| 19 |
+
answer = generate_answer(question)
|
| 20 |
+
|
| 21 |
+
st.markdown(f"**Answer:** {answer}")
|
| 22 |
+
|
| 23 |
+
else:
|
| 24 |
+
st.markdown("Please ask me a question.")
|