Jofthomas HF staff commited on
Commit
b6c7280
·
verified ·
1 Parent(s): 7f74b65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -29
app.py CHANGED
@@ -483,40 +483,16 @@ with gr.Blocks(
483
  ),
484
  css=STYLE,
485
  ) as demo:
486
- gr.Markdown(
487
- """# <span style='color:var(--primary-500)!important'>Beam Search Visualizer</span>
488
 
489
- Play with the parameters below to understand how beam search decoding works!
490
-
491
- Here's GPT2 doing beam search decoding for you.
492
-
493
- #### <span style='color:var(--primary-500)!important'>Parameters:</span>
494
- - **Sentence to decode from** (`inputs`): the input sequence to your decoder.
495
- - **Number of steps** (`max_new_tokens`): the number of tokens to generate.
496
- - **Number of beams** (`num_beams`): the number of beams to use.
497
- - **Length penalty** (`length_penalty`): the length penalty to apply to outputs. `length_penalty` > 0.0 promotes longer sequences, while `length_penalty` < 0.0 encourages shorter sequences.
498
- This parameter will not impact the beam search paths, but only influence the choice of sequences in the end towards longer or shorter sequences.
499
- - **Number of return sequences** (`num_return_sequences`): the number of sequences to be returned at the end of generation. Should be `<= num_beams`.
500
- """
501
- )
502
  text = gr.Textbox(
503
  label="Sentence to decode from",
504
- value="Conclusion: thanks a lot. That's all for today",
505
  )
506
  with gr.Row():
507
- n_steps = gr.Slider(
508
- label="Number of steps", minimum=1, maximum=12, step=1, value=5
509
- )
510
- n_beams = gr.Slider(
511
- label="Number of beams", minimum=1, maximum=4, step=1, value=4
512
- )
513
- length_penalty = gr.Slider(
514
- label="Length penalty", minimum=-3, maximum=3, step=0.5, value=1
515
- )
516
- num_return_sequences = gr.Slider(
517
- label="Number of return sequences", minimum=1, maximum=4, step=1, value=3
518
- )
519
-
520
  n_beams.change(
521
  fn=change_num_return_sequences, inputs=n_beams, outputs=num_return_sequences
522
  )
 
483
  ),
484
  css=STYLE,
485
  ) as demo:
 
 
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  text = gr.Textbox(
488
  label="Sentence to decode from",
489
+ value="Hugging Face is",
490
  )
491
  with gr.Row():
492
+ n_steps=12
493
+ n_beams=1
494
+ length_penalty=1
495
+ num_return_sequences=3
 
 
 
 
 
 
 
 
 
496
  n_beams.change(
497
  fn=change_num_return_sequences, inputs=n_beams, outputs=num_return_sequences
498
  )