File size: 611 Bytes
67448d5
 
bc75555
 
67448d5
 
 
 
bc75555
67448d5
 
bc75555
 
67448d5
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import streamlit as st
from transformers import pipeline

# Create a text2text-generation pipeline with the "google/flan-t5-base" model
pipe = pipeline("text2text-generation", model="google/flan-t5-base")

st.title("Question-Answer Generator")
user_question = st.text_input("Ask a question:")

if st.button("Generate Answer"):
    if user_question:
        # Use the T5 model to generate a more precise answer
        answer = pipe(user_question, max_length=100, do_sample=False)[0]["generated_text"]
        st.write("Answer:")
        st.write(answer)
    else:
        st.warning("Please enter a question.")