Tonic commited on
Commit
6cbc4c5
1 Parent(s): 486b2ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -21,7 +21,7 @@ model = AutoModelForCausalLM.from_pretrained(model_path, device_map='cuda', quan
21
  def generate_text(prompt, custom_prompt, temperature, max_length):
22
  structured_input = f"[[[Title]]]: {prompt}\n[[[Content]]]: {custom_prompt}"
23
  inputs = tokenizer(structured_input, return_tensors='pt').to('cuda')
24
- generated_ids = model.generate(**inputs, max_new_tokens=max_length, temperature=temperature, do_sample=True).split(tokenizer.eos_token)[0])
25
  generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=False)
26
  return generated_text
27
 
@@ -29,8 +29,8 @@ def generate_text(prompt, custom_prompt, temperature, max_length):
29
  def gradio_app():
30
  with gr.Blocks() as demo:
31
  gr.Markdown(title)
32
- prompt = gr.Textbox(label="WordPhrases", value=examplecofee, lines=5)
33
- custom_prompt = gr.Textbox(label="Title", value="Cortado", lines=1)
34
  with gr.Row():
35
  temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature")
36
  max_length = gr.Slider(minimum=250, maximum=1024, step=10, value=450, label="Generate Length")
 
21
  def generate_text(prompt, custom_prompt, temperature, max_length):
22
  structured_input = f"[[[Title]]]: {prompt}\n[[[Content]]]: {custom_prompt}"
23
  inputs = tokenizer(structured_input, return_tensors='pt').to('cuda')
24
+ generated_ids = model.generate(**inputs, max_new_tokens=max_length, temperature=temperature, do_sample=True).split(tokenizer.eos_token)[0]
25
  generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=False)
26
  return generated_text
27
 
 
29
  def gradio_app():
30
  with gr.Blocks() as demo:
31
  gr.Markdown(title)
32
+ custom_prompt = gr.Textbox(label="WordPhrases", value=examplecofee, lines=5)
33
+ prompt = gr.Textbox(label="Title", value="Cortado", lines=1)
34
  with gr.Row():
35
  temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature")
36
  max_length = gr.Slider(minimum=250, maximum=1024, step=10, value=450, label="Generate Length")