multimodalart HF staff commited on
Commit
504ac73
β€’
1 Parent(s): a558847

Bring up advanced settings

Browse files
Files changed (1) hide show
  1. app_dialogue.py +69 -71
app_dialogue.py CHANGED
@@ -376,80 +376,78 @@ with gr.Blocks(title="AI Dad Jokes", theme=gr.themes.Base()) as demo:
376
  clear_btn = gr.ClearButton([textbox, imagebox, chatbot], value="🧹 Clear")
377
  regenerate_btn = gr.Button(value="πŸ”„ Regenerate", visible=True)
378
  upload_btn = gr.UploadButton("πŸ“ Upload image", file_types=["image"],visible=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  with gr.Column():
380
  chatbot.render()
381
 
382
- with gr.Row():
383
- with gr.Accordion("Advanced settings", open=False, visible=True) as parameter_row:
384
- system_prompt = gr.Textbox(
385
- value=SYSTEM_PROMPT,
386
- visible=False,
387
- lines=20,
388
- max_lines=50,
389
- interactive=True,
390
- )
391
- max_new_tokens = gr.Slider(
392
- minimum=8,
393
- maximum=256,
394
- value=64,
395
- step=1,
396
- interactive=True,
397
- label="Maximum number of new tokens to generate",
398
- )
399
- repetition_penalty = gr.Slider(
400
- minimum=0.0,
401
- maximum=5.0,
402
- value=1.2,
403
- step=0.01,
404
- interactive=True,
405
- label="Repetition penalty",
406
- info="1.0 is equivalent to no penalty",
407
- )
408
- decoding_strategy = gr.Radio(
409
- [
410
- "Greedy",
411
- "Top P Sampling",
412
- ],
413
- value="Top P Sampling",
414
- label="Decoding strategy",
415
- interactive=True,
416
- info="Higher values is equivalent to sampling more low-probability tokens.",
417
- )
418
- temperature = gr.Slider(
419
- minimum=0.0,
420
- maximum=5.0,
421
- value=0.6,
422
- step=0.1,
423
- interactive=True,
424
- visible=True,
425
- label="Sampling temperature",
426
- info="Higher values will produce more diverse outputs.",
427
- )
428
- decoding_strategy.change(
429
- fn=lambda selection: gr.Slider.update(
430
- visible=(
431
- selection in ["contrastive_sampling", "beam_sampling", "Top P Sampling", "sampling_top_k"]
432
- )
433
- ),
434
- inputs=decoding_strategy,
435
- outputs=temperature,
436
- )
437
- top_p = gr.Slider(
438
- minimum=0.01,
439
- maximum=0.99,
440
- value=0.8,
441
- step=0.01,
442
- interactive=True,
443
- visible=True,
444
- label="Top P",
445
- info="Higher values is equivalent to sampling more low-probability tokens.",
446
- )
447
- decoding_strategy.change(
448
- fn=lambda selection: gr.Slider.update(visible=(selection in ["Top P Sampling"])),
449
- inputs=decoding_strategy,
450
- outputs=top_p,
451
- )
452
-
453
  def model_inference(
454
  model_selector,
455
  system_prompt,
 
376
  clear_btn = gr.ClearButton([textbox, imagebox, chatbot], value="🧹 Clear")
377
  regenerate_btn = gr.Button(value="πŸ”„ Regenerate", visible=True)
378
  upload_btn = gr.UploadButton("πŸ“ Upload image", file_types=["image"],visible=False)
379
+ with gr.Accordion("Advanced settings", open=False, visible=True) as parameter_row:
380
+ system_prompt = gr.Textbox(
381
+ value=SYSTEM_PROMPT,
382
+ visible=False,
383
+ lines=20,
384
+ max_lines=50,
385
+ interactive=True,
386
+ )
387
+ max_new_tokens = gr.Slider(
388
+ minimum=8,
389
+ maximum=256,
390
+ value=64,
391
+ step=1,
392
+ interactive=True,
393
+ label="Maximum number of new tokens to generate",
394
+ )
395
+ repetition_penalty = gr.Slider(
396
+ minimum=0.0,
397
+ maximum=5.0,
398
+ value=1.2,
399
+ step=0.01,
400
+ interactive=True,
401
+ label="Repetition penalty",
402
+ info="1.0 is equivalent to no penalty",
403
+ )
404
+ decoding_strategy = gr.Radio(
405
+ [
406
+ "Greedy",
407
+ "Top P Sampling",
408
+ ],
409
+ value="Top P Sampling",
410
+ label="Decoding strategy",
411
+ interactive=True,
412
+ info="Higher values is equivalent to sampling more low-probability tokens.",
413
+ )
414
+ temperature = gr.Slider(
415
+ minimum=0.0,
416
+ maximum=5.0,
417
+ value=0.6,
418
+ step=0.1,
419
+ interactive=True,
420
+ visible=True,
421
+ label="Sampling temperature",
422
+ info="Higher values will produce more diverse outputs.",
423
+ )
424
+ decoding_strategy.change(
425
+ fn=lambda selection: gr.Slider.update(
426
+ visible=(
427
+ selection in ["contrastive_sampling", "beam_sampling", "Top P Sampling", "sampling_top_k"]
428
+ )
429
+ ),
430
+ inputs=decoding_strategy,
431
+ outputs=temperature,
432
+ )
433
+ top_p = gr.Slider(
434
+ minimum=0.01,
435
+ maximum=0.99,
436
+ value=0.8,
437
+ step=0.01,
438
+ interactive=True,
439
+ visible=True,
440
+ label="Top P",
441
+ info="Higher values is equivalent to sampling more low-probability tokens.",
442
+ )
443
+ decoding_strategy.change(
444
+ fn=lambda selection: gr.Slider.update(visible=(selection in ["Top P Sampling"])),
445
+ inputs=decoding_strategy,
446
+ outputs=top_p,
447
+ )
448
  with gr.Column():
449
  chatbot.render()
450
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  def model_inference(
452
  model_selector,
453
  system_prompt,