ColeGuion commited on
Commit
1811e61
1 Parent(s): dd8c189

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -13,7 +13,7 @@ def correct_text(text, genConfig):
13
  corrected_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
  return corrected_text
15
 
16
- def respond(text, max_new_tokens, min_new_tokens, num_beams, num_beam_groups, temperature, top_k, top_p):
17
  config = GenerationConfig(
18
  max_new_tokens=max_new_tokens,
19
  min_new_tokens=min_new_tokens,
@@ -25,6 +25,9 @@ def respond(text, max_new_tokens, min_new_tokens, num_beams, num_beam_groups, te
25
  early_stopping=True,
26
  do_sample=True
27
  )
 
 
 
28
 
29
  corrected = correct_text(text, config)
30
  yield corrected
@@ -57,9 +60,8 @@ with gr.Blocks() as demo:
57
  temperature = gr.Slider(minimum=0.1, maximum=100.0, value=0.7, step=0.1, label="Temperature")
58
  top_k = gr.Slider(minimum=0, maximum=200, value=50, step=1, label="Top-k")
59
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=1.0, step=0.05, label="Top-p (nucleus sampling)")
 
60
 
61
-
62
-
63
- submitBtn.click(respond, [prompt_box, max_tokens, min_tokens, num_beams, beam_groups, temperature, top_k, top_p], output_box)
64
 
65
  demo.launch()
 
13
  corrected_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
  return corrected_text
15
 
16
+ def respond(text, max_new_tokens, min_new_tokens, num_beams, num_beam_groups, temperature, top_k, top_p, guidance_scale):
17
  config = GenerationConfig(
18
  max_new_tokens=max_new_tokens,
19
  min_new_tokens=min_new_tokens,
 
25
  early_stopping=True,
26
  do_sample=True
27
  )
28
+
29
+ if guidance_scale > 0:
30
+ config.guidance_scale = float(guidance_scale)
31
 
32
  corrected = correct_text(text, config)
33
  yield corrected
 
60
  temperature = gr.Slider(minimum=0.1, maximum=100.0, value=0.7, step=0.1, label="Temperature")
61
  top_k = gr.Slider(minimum=0, maximum=200, value=50, step=1, label="Top-k")
62
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=1.0, step=0.05, label="Top-p (nucleus sampling)")
63
+ guideScale = gr.Slider(minimum=0.1, maximum=50.0, value=1.0, step=1, label="Guidance Scale")
64
 
65
+ submitBtn.click(respond, [prompt_box, max_tokens, min_tokens, num_beams, beam_groups, temperature, top_k, top_p, guideScale], output_box)
 
 
66
 
67
  demo.launch()