xlr8harder commited on
Commit
f5bae26
·
1 Parent(s): 16b5cfc

add max tokens slider and set default repetition penalty to 0.1

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -11,14 +11,14 @@ client = OpenAI(
11
  api_key=api_key,
12
  )
13
 
14
- def generate_completion(prompt, temperature, repetition_penalty, stop_phrase):
15
  try:
16
  completion = client.completions.create(
17
  model="meta-llama/Meta-Llama-3.1-405B-FP8",
18
  prompt=prompt,
19
  temperature=temperature,
20
  frequency_penalty=repetition_penalty,
21
- max_tokens=2000,
22
  stop=[stop_phrase] if stop_phrase else None
23
  )
24
  return completion.choices[0].text.strip()
@@ -40,20 +40,20 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
40
  prompt_input = gr.Textbox(label="Prompt", lines=6, value="The best thing about being a cat is")
41
  with gr.Column(scale=1):
42
  temperature_slider = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature")
43
- repetition_penalty_slider = gr.Slider(minimum=0, maximum=2, value=1.1, step=0.1, label="Repetition Penalty")
 
44
  stop_phrase_input = gr.Textbox(label="Stop Phrase", placeholder="Enter stop phrase (optional)")
45
 
46
  with gr.Row():
47
  generate_button = gr.Button("Generate Completion")
48
  append_button = gr.Button("Append Completion to Prompt")
49
  clear_button = gr.Button("Clear All Fields")
50
-
51
 
52
  output_text = gr.Textbox(label="Generated Completion", lines=10)
53
 
54
  generate_button.click(
55
- generate_completion,
56
- inputs=[prompt_input, temperature_slider, repetition_penalty_slider, stop_phrase_input],
57
  outputs=output_text
58
  )
59
 
@@ -62,16 +62,16 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
62
  inputs=[prompt_input, output_text],
63
  outputs=[prompt_input, output_text]
64
  )
65
-
66
  clear_button.click(
67
  clear_fields,
68
  outputs=[prompt_input, output_text]
69
  )
70
 
71
  gr.Markdown("""
72
- ---
73
- This interface is powered by the Llama 3.1 405B base model, served by [Hyperbolic](https://hyperbolic.xyz), The Open Access AI Cloud.
 
 
74
 
75
- Thank you to Hyperbolic for making this base model available!
76
- """)
77
  iface.launch(share=True)
 
11
  api_key=api_key,
12
  )
13
 
14
+ def generate_completion(prompt, temperature, repetition_penalty, stop_phrase, max_tokens):
15
  try:
16
  completion = client.completions.create(
17
  model="meta-llama/Meta-Llama-3.1-405B-FP8",
18
  prompt=prompt,
19
  temperature=temperature,
20
  frequency_penalty=repetition_penalty,
21
+ max_tokens=max_tokens,
22
  stop=[stop_phrase] if stop_phrase else None
23
  )
24
  return completion.choices[0].text.strip()
 
40
  prompt_input = gr.Textbox(label="Prompt", lines=6, value="The best thing about being a cat is")
41
  with gr.Column(scale=1):
42
  temperature_slider = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature")
43
+ repetition_penalty_slider = gr.Slider(minimum=0, maximum=2, value=0.1, step=0.1, label="Repetition Penalty")
44
+ max_tokens_slider = gr.Slider(minimum=1, maximum=4000, value=250, step=1, label="Max Tokens")
45
  stop_phrase_input = gr.Textbox(label="Stop Phrase", placeholder="Enter stop phrase (optional)")
46
 
47
  with gr.Row():
48
  generate_button = gr.Button("Generate Completion")
49
  append_button = gr.Button("Append Completion to Prompt")
50
  clear_button = gr.Button("Clear All Fields")
 
51
 
52
  output_text = gr.Textbox(label="Generated Completion", lines=10)
53
 
54
  generate_button.click(
55
+ generate_completion,
56
+ inputs=[prompt_input, temperature_slider, repetition_penalty_slider, stop_phrase_input, max_tokens_slider],
57
  outputs=output_text
58
  )
59
 
 
62
  inputs=[prompt_input, output_text],
63
  outputs=[prompt_input, output_text]
64
  )
65
+
66
  clear_button.click(
67
  clear_fields,
68
  outputs=[prompt_input, output_text]
69
  )
70
 
71
  gr.Markdown("""
72
+ ---
73
+ This interface is powered by the Llama 3.1 405B base model, served by [Hyperbolic](https://hyperbolic.xyz), The Open Access AI Cloud.
74
+ Thank you to Hyperbolic for making this base model available!
75
+ """)
76
 
 
 
77
  iface.launch(share=True)