File size: 1,041 Bytes
6f82200 e873794 c74d313 c55adbf 546a17c 6f82200 e873794 07bdc43 c74d313 c55adbf 07bdc43 6f82200 c74d313 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 25 26 27 28 29 30 |
from transformers import pipeline
import gradio as gr
import spaces
# 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']
# Define a function to generate text based on user input
@spaces.GPU
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 SakanaAI/EvoLLM-JP-v1-7B",
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() |