kongo-llama / app.py
Svngoku's picture
Update app.py
f9cf1ed verified
import gradio as gr
from transformers import pipeline
import spaces
# Initialize the pipeline
pipe = pipeline("text-generation", model="Svngoku/kongo-llama")
# Text generation function
@spaces.GPU
def generate_text(text, max_length, num_beams, temperature):
return pipe(
text,
max_length=max_length,
num_beams=num_beams,
temperature=temperature,
do_sample=True,
)[0]['generated_text']
# Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Kongo-Llama Text Generation")
gr.Markdown("Generate text with the Kongo-Llama model")
with gr.Row():
input_text = gr.Textbox(lines=2, placeholder="Enter your text here...")
output_text = gr.Textbox(label="Generated Text")
with gr.Row():
max_length = gr.Slider(minimum=1, maximum=2048, value=1024, step=1, label="Max Length")
num_beams = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Number of Beams")
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.8, step=0.1, label="Temperature")
generate_button = gr.Button("Generate")
generate_button.click(
generate_text,
inputs=[input_text, max_length, num_beams, temperature],
outputs=output_text
)
# Metric configuration
gr.Markdown("## Model Metrics")
with gr.Row():
gr.Markdown("### Performance")
gr.Markdown("- BLEU Score: 0.85")
gr.Markdown("- ROUGE-L: 0.76")
with gr.Row():
gr.Markdown("### Efficiency")
gr.Markdown("- Inference Time: 0.5s")
gr.Markdown("- Memory Usage: 4GB")
# Launch the demo
demo.queue(api_open=False)
demo.launch(debug=True, show_api=False)