Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files482 unmodified lines483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522482 unmodified lines),css=STYLE,) as demo:gr.Markdown("""# <span style='color:var(--primary-500)!important'>Beam Search Visualizer</span>Play with the parameters below to understand how beam search decoding works!Here's GPT2 doing beam search decoding for you.#### <span style='color:var(--primary-500)!important'>Parameters:</span>- **Sentence to decode from** (`inputs`): the input sequence to your decoder.- **Number of steps** (`max_new_tokens`): the number of tokens to generate.- **Number of beams** (`num_beams`): the number of beams to use.- **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.This parameter will not impact the beam search paths, but only influence the choice of sequences in the end towards longer or shorter sequences.- **Number of return sequences** (`num_return_sequences`): the number of sequences to be returned at the end of generation. Should be `<= num_beams`.""")text = gr.Textbox(label="Sentence to decode from",value="Conclusion: thanks a lot. That's all for today",)with gr.Row():n_steps = gr.Slider(label="Number of steps", minimum=1, maximum=12, step=1, value=5)n_beams = gr.Slider(label="Number of beams", minimum=1, maximum=4, step=1, value=4)length_penalty = gr.Slider(label="Length penalty", minimum=-3, maximum=3, step=0.5, value=1)num_return_sequences = gr.Slider(label="Number of return sequences", minimum=1, maximum=4, step=1, value=3)n_beams.change(fn=change_num_return_sequences, inputs=n_beams, outputs=num_return_sequences)482 unmodified lines483484485486487488489490491492493494495496497498482 unmodified lines),css=STYLE,) as demo:text = gr.Textbox(label="Sentence to decode from",value="Hugging Face is",)with gr.Row():n_steps=12n_beams=1length_penalty=1num_return_sequences=3n_beams.change(fn=change_num_return_sequences, inputs=n_beams, outputs=num_return_sequences)
app.py+5-29