Spaces:
Sleeping
Sleeping
Commit
Β·
1c905f8
1
Parent(s):
c129502
upd
Browse files- src/streamlit_app.py +10 -10
src/streamlit_app.py
CHANGED
@@ -3,9 +3,9 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
|
3 |
|
4 |
@st.cache_resource
|
5 |
def load_model():
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
st.set_page_config(page_title="LLM Demo", layout="centered")
|
11 |
st.title("π FLAN-T5 Small - HuggingFace Demo")
|
@@ -15,10 +15,10 @@ pipe = load_model()
|
|
15 |
user_input = st.text_area("Enter your instruction or question:", "")
|
16 |
|
17 |
if st.button("Generate Response"):
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
3 |
|
4 |
@st.cache_resource
|
5 |
def load_model():
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")
|
8 |
+
return pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
9 |
|
10 |
st.set_page_config(page_title="LLM Demo", layout="centered")
|
11 |
st.title("π FLAN-T5 Small - HuggingFace Demo")
|
|
|
15 |
user_input = st.text_area("Enter your instruction or question:", "")
|
16 |
|
17 |
if st.button("Generate Response"):
|
18 |
+
if user_input.strip() == "":
|
19 |
+
st.warning("Please enter some text.")
|
20 |
+
else:
|
21 |
+
with st.spinner("Generating..."):
|
22 |
+
output = pipe(user_input, max_new_tokens=100)[0]["generated_text"]
|
23 |
+
st.success("### Response:")
|
24 |
+
st.write(output)
|