ColeGuion commited on
Commit
73ca0b1
1 Parent(s): 5df676a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -13,10 +13,10 @@ 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_length, min_length, max_new_tokens, min_new_tokens, num_beams, num_beam_groups, temperature, top_k, top_p):
17
  config = GenerationConfig(
18
- max_length=max_length,
19
- min_length=min_length,
20
  num_beams=num_beams,
21
  num_beam_groups=num_beam_groups,
22
  temperature=float(temperature),
@@ -25,12 +25,6 @@ def respond(text, max_length, min_length, max_new_tokens, min_new_tokens, num_be
25
  early_stopping=True,
26
  do_sample=True
27
  )
28
-
29
- # Add max/min new tokens if they are there
30
- if max_new_tokens > 0:
31
- config.max_new_tokens = max_new_tokens
32
- if min_new_tokens > 0:
33
- config.min_new_tokens = min_new_tokens
34
 
35
  corrected = correct_text(text, config)
36
  yield corrected
@@ -56,8 +50,6 @@ with gr.Blocks() as demo:
56
  submitBtn = gr.Button("Submit")
57
 
58
  with gr.Accordion("Generation Parameters:", open=False):
59
- max_length = gr.Slider(minimum=1, maximum=256, value=80, step=1, label="Max Length")
60
- min_length = gr.Slider(minimum=1, maximum=256, value=0, step=1, label="Min Length")
61
  max_tokens = gr.Slider(minimum=0, maximum=256, value=0, step=1, label="Max New Tokens")
62
  min_tokens = gr.Slider(minimum=0, maximum=256, value=0, step=1, label="Min New Tokens")
63
  num_beams = gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Num Beams")
@@ -68,6 +60,6 @@ with gr.Blocks() as demo:
68
 
69
 
70
 
71
- submitBtn.click(respond, [prompt_box, max_length, min_length, max_tokens, min_tokens, num_beams, beam_groups, temperature, top_k, top_p], output_box)
72
 
73
  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):
17
  config = GenerationConfig(
18
+ max_new_tokens=max_new_tokens,
19
+ min_new_tokens=min_new_tokens,
20
  num_beams=num_beams,
21
  num_beam_groups=num_beam_groups,
22
  temperature=float(temperature),
 
25
  early_stopping=True,
26
  do_sample=True
27
  )
 
 
 
 
 
 
28
 
29
  corrected = correct_text(text, config)
30
  yield corrected
 
50
  submitBtn = gr.Button("Submit")
51
 
52
  with gr.Accordion("Generation Parameters:", open=False):
 
 
53
  max_tokens = gr.Slider(minimum=0, maximum=256, value=0, step=1, label="Max New Tokens")
54
  min_tokens = gr.Slider(minimum=0, maximum=256, value=0, step=1, label="Min New Tokens")
55
  num_beams = gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Num Beams")
 
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()