text_generation / app.py
Alizhan
change
8deb42a
raw
history blame
789 Bytes
import streamlit as st
from transformers import pipeline
# Initialize the pipeline
st.title("Hugging Face Text Generation")
st.subheader("Model: ai-forever/mGPT-1.3B-kazakh")
# Create the pipeline
@st.cache_resource
def load_pipeline():
return pipeline("text-generation", model="ai-forever/mGPT-1.3B-kazakh")
pipe = load_pipeline()
# User input
prompt = st.text_area("Мәтін енгізіңіз:", value="", height=100)
# Text generation
if st.button("Generate Text"):
if prompt.strip():
with st.spinner("Generating text..."):
result = pipe(prompt, max_length=100, num_return_sequences=1)
st.subheader("Generated Text:")
st.write(result[0]["generated_text"])
else:
st.error("Please enter a prompt to generate text.")