File size: 827 Bytes
6f82200 e873794 11eb020 c55adbf 546a17c 6f82200 e873794 07bdc43 c55adbf 07bdc43 6f82200 c55adbf 07bdc43 6f82200 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from transformers import pipeline
import gradio as gr
# Initialize the text generation pipeline with optimizations
pipe = pipeline("text-generation", model="SakanaAI/EvoLLM-JP-v1-7B")
# Define a function to generate text based on user input
def generate_text(prompt):
result = pipe(prompt, max_length=50, num_return_sequences=1)
return result[0]['generated_text']
# Create a Gradio interface with batching enabled
iface = gr.Interface(
fn=generate_text,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
outputs="text",
title="Text Generation with DiscoPOP-zephyr-7b-gemma",
description="Enter a prompt and the model will generate a continuation of the text.",
batch=True,
max_batch_size=4
)
# Launch the interface
if __name__ == "__main__":
iface.launch() |