tamatwi commited on
Commit
c55adbf
·
verified ·
1 Parent(s): 6f82200

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,21 +1,23 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- # Initialize the text generation pipeline
5
- pipe = pipeline("text-generation", model="SakanaAI/DiscoPOP-zephyr-7b-gemma")
6
 
7
  # Define a function to generate text based on user input
8
  def generate_text(prompt):
9
  result = pipe(prompt, max_length=50, num_return_sequences=1)
10
  return result[0]['generated_text']
11
 
12
- # Create a Gradio interface
13
  iface = gr.Interface(
14
  fn=generate_text,
15
  inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
16
  outputs="text",
17
  title="Text Generation with DiscoPOP-zephyr-7b-gemma",
18
- description="Enter a prompt and the model will generate a continuation of the text."
 
 
19
  )
20
 
21
  # Launch the interface
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # Initialize the text generation pipeline with optimizations
5
+ pipe = pipeline("text-generation", model="SakanaAI/DiscoPOP-zephyr-7b-gemma", torch_dtype=torch.float16, low_cpu_mem_usage=True)
6
 
7
  # Define a function to generate text based on user input
8
  def generate_text(prompt):
9
  result = pipe(prompt, max_length=50, num_return_sequences=1)
10
  return result[0]['generated_text']
11
 
12
+ # Create a Gradio interface with batching enabled
13
  iface = gr.Interface(
14
  fn=generate_text,
15
  inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
16
  outputs="text",
17
  title="Text Generation with DiscoPOP-zephyr-7b-gemma",
18
+ description="Enter a prompt and the model will generate a continuation of the text.",
19
+ batch=True,
20
+ max_batch_size=4
21
  )
22
 
23
  # Launch the interface