MeetJivani commited on
Commit
7431b40
1 Parent(s): f5dd57f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -35
app.py CHANGED
@@ -228,7 +228,7 @@ def proc_submission(
228
  "repetition_penalty": float(repetition_penalty),
229
  "no_repeat_ngram_size": int(no_repeat_ngram_size),
230
  "encoder_no_repeat_ngram_size": 4,
231
- "num_beams": int(num_beams),
232
  "min_length": 4,
233
  "max_length": int(token_batch_length // 4),
234
  "early_stopping": True,
@@ -488,53 +488,59 @@ if __name__ == "__main__":
488
  logger.info("Starting app instance")
489
  with demo:
490
  with gr.Column():
491
- gr.Markdown("# Document Summarization with Long-Document Transformers")
492
- gr.Markdown(
493
- """An example use case for fine-tuned long document transformers. Model(s) are trained on [book summaries](https://hf.co/datasets/kmfoda/booksum). Architectures [in this demo](https://hf.co/spaces/pszemraj/document-summarization) are [LongT5-base](https://hf.co/pszemraj/long-t5-tglobal-base-16384-book-summary) and [Pegasus-X-Large](https://hf.co/pszemraj/pegasus-x-large-book-summary).
494
 
495
- **Want more performance? Run this demo from a free Google Colab GPU:**.
496
- <br>
497
- <a href="https://colab.research.google.com/gist/pszemraj/52f67cf7326e780155812a6a1f9bb724/document-summarization-on-gpu.ipynb">
498
- <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
499
- </a>
500
- <br>
501
- """
502
- )
503
  gr.Markdown("## Load Inputs & Select Parameters")
504
  gr.Markdown(
505
  """Enter/paste text below, or upload a file. Pick a model & adjust params (_optional_), and press **Summarize!**
506
 
507
- See [the guide doc](https://gist.github.com/pszemraj/722a7ba443aa3a671b02d87038375519) for details.
508
  """
509
  )
510
  with gr.Row(variant="compact"):
511
- with gr.Column(scale=0.5, variant="compact"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  model_name = gr.Dropdown(
513
  choices=MODEL_OPTIONS,
514
  value=MODEL_OPTIONS[0],
515
  label="Model Name",
516
  )
517
- num_beams = gr.Radio(
518
- choices=BEAM_OPTIONS,
519
- value=BEAM_OPTIONS[len(BEAM_OPTIONS) // 2],
520
- label="Beam Search: # of Beams",
521
- )
522
- load_examples_button = gr.Button(
523
- "Load Example in Dropdown",
524
- )
525
- load_file_button = gr.Button("Upload & Process File")
526
- with gr.Column(variant="compact"):
527
- example_name = gr.Dropdown(
528
- _examples,
529
- label="Examples",
530
- value=random.choice(_examples),
531
- )
532
  uploaded_file = gr.File(
533
  label="File Upload",
534
  file_count="single",
535
  file_types=[".txt", ".md", ".pdf"],
536
  type="file",
537
  )
 
538
  with gr.Row():
539
  input_text = gr.Textbox(
540
  lines=4,
@@ -544,16 +550,16 @@ if __name__ == "__main__":
544
  )
545
  gr.Markdown("---")
546
  with gr.Column():
547
- gr.Markdown("## Generate Summary")
548
  with gr.Row():
549
  summarize_button = gr.Button(
550
- "Summarize!",
551
  variant="primary",
552
  )
553
- gr.Markdown(
554
- "_Summarization should take ~1-2 minutes for most settings, but may extend up to 5-10 minutes in some scenarios._"
555
- )
556
- output_text = gr.HTML("<p><em>Output will appear below:</em></p>")
557
  with gr.Column():
558
  gr.Markdown("### Results & Scores")
559
  with gr.Row():
 
228
  "repetition_penalty": float(repetition_penalty),
229
  "no_repeat_ngram_size": int(no_repeat_ngram_size),
230
  "encoder_no_repeat_ngram_size": 4,
231
+ "num_beams": 3,
232
  "min_length": 4,
233
  "max_length": int(token_batch_length // 4),
234
  "early_stopping": True,
 
488
  logger.info("Starting app instance")
489
  with demo:
490
  with gr.Column():
491
+ gr.Markdown("# Anushandhan Mitra")
492
+ # gr.Markdown(
493
+ # """An example use case for fine-tuned long document transformers. Model(s) are trained on [book summaries](https://hf.co/datasets/kmfoda/booksum). Architectures [in this demo](https://hf.co/spaces/pszemraj/document-summarization) are [LongT5-base](https://hf.co/pszemraj/long-t5-tglobal-base-16384-book-summary) and [Pegasus-X-Large](https://hf.co/pszemraj/pegasus-x-large-book-summary).
494
 
495
+ # **Want more performance? Run this demo from a free Google Colab GPU:**.
496
+ # <br>
497
+ # <a href="https://colab.research.google.com/gist/pszemraj/52f67cf7326e780155812a6a1f9bb724/document-summarization-on-gpu.ipynb">
498
+ # <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
499
+ # </a>
500
+ # <br>
501
+ # """
502
+ # )
503
  gr.Markdown("## Load Inputs & Select Parameters")
504
  gr.Markdown(
505
  """Enter/paste text below, or upload a file. Pick a model & adjust params (_optional_), and press **Summarize!**
506
 
507
+ # See [the guide doc](https://gist.github.com/pszemraj/722a7ba443aa3a671b02d87038375519) for details.
508
  """
509
  )
510
  with gr.Row(variant="compact"):
511
+ # with gr.Column(scale=0.5, variant="compact"):
512
+ # model_name = gr.Dropdown(
513
+ # choices=MODEL_OPTIONS,
514
+ # value=MODEL_OPTIONS[0],
515
+ # label="Model Name",
516
+ # )
517
+ # num_beams = gr.Radio(
518
+ # choices=BEAM_OPTIONS,
519
+ # value=BEAM_OPTIONS[len(BEAM_OPTIONS) // 2],
520
+ # label="Beam Search: # of Beams",
521
+ # )
522
+ # load_examples_button = gr.Button(
523
+ # "Load Example in Dropdown",
524
+ # )
525
+ # load_file_button = gr.Button("Upload & Process File")
526
+ with gr.Column(variant="compact"):
527
  model_name = gr.Dropdown(
528
  choices=MODEL_OPTIONS,
529
  value=MODEL_OPTIONS[0],
530
  label="Model Name",
531
  )
532
+ # example_name = gr.Dropdown(
533
+ # _examples,
534
+ # label="Examples",
535
+ # value=random.choice(_examples),
536
+ # )
 
 
 
 
 
 
 
 
 
 
537
  uploaded_file = gr.File(
538
  label="File Upload",
539
  file_count="single",
540
  file_types=[".txt", ".md", ".pdf"],
541
  type="file",
542
  )
543
+ load_file_button = gr.Button("Upload & Process File")
544
  with gr.Row():
545
  input_text = gr.Textbox(
546
  lines=4,
 
550
  )
551
  gr.Markdown("---")
552
  with gr.Column():
553
+ # gr.Markdown("## Generate Summary")
554
  with gr.Row():
555
  summarize_button = gr.Button(
556
+ "Generate Summary!",
557
  variant="primary",
558
  )
559
+ # gr.Markdown(
560
+ # "_Summarization should take ~1-2 minutes for most settings, but may extend up to 5-10 minutes in some scenarios._"
561
+ # )
562
+ output_text = gr.HTML("<p><em>_Summarization should take ~1-2 minutes for most settings, but may extend up to 5-10 minutes in some scenarios._</em></p>")
563
  with gr.Column():
564
  gr.Markdown("### Results & Scores")
565
  with gr.Row():