Spaces:
Runtime error
Runtime error
decrease markdown density
Browse files
app.py
CHANGED
@@ -482,31 +482,29 @@ if __name__ == "__main__":
|
|
482 |
name_to_path = load_example_filenames(_here / "examples")
|
483 |
logger.info(f"Loaded {len(name_to_path)} examples")
|
484 |
|
485 |
-
demo = gr.Blocks(title="Document Summarization
|
486 |
_examples = list(name_to_path.keys())
|
487 |
logger.info("Starting app instance")
|
488 |
with demo:
|
489 |
-
gr.Markdown("# Document Summarization with Long-Document Transformers")
|
490 |
gr.Markdown(
|
491 |
-
"""
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
497 |
-
</a>
|
498 |
-
<br>
|
499 |
"""
|
500 |
)
|
501 |
with gr.Column():
|
502 |
-
gr.Markdown("
|
503 |
gr.Markdown(
|
504 |
-
"""
|
|
|
|
|
505 |
|
506 |
See [the guide doc](https://gist.github.com/pszemraj/722a7ba443aa3a671b02d87038375519) for details.
|
507 |
"""
|
508 |
)
|
509 |
-
with gr.Row(
|
510 |
with gr.Column(variant="compact"):
|
511 |
model_name = gr.Dropdown(
|
512 |
choices=MODEL_OPTIONS,
|
@@ -541,7 +539,6 @@ if __name__ == "__main__":
|
|
541 |
label="Text to Summarize",
|
542 |
placeholder="Enter text to summarize, the text will be cleaned and truncated on Spaces. Narrative, academic (both papers and lecture transcription), and article text work well. May take a bit to generate depending on the input text :)",
|
543 |
)
|
544 |
-
gr.Markdown("---")
|
545 |
with gr.Column():
|
546 |
gr.Markdown("## Generate Summary")
|
547 |
with gr.Row():
|
@@ -582,9 +579,6 @@ if __name__ == "__main__":
|
|
582 |
)
|
583 |
with gr.Column():
|
584 |
gr.Markdown("### **Aggregate Summary Batches**")
|
585 |
-
gr.Markdown(
|
586 |
-
"_Note: this is an experimental feature. Feedback welcome in the [discussions](https://hf.co/spaces/pszemraj/document-summarization/discussions)!_"
|
587 |
-
)
|
588 |
with gr.Row():
|
589 |
aggregate_button = gr.Button(
|
590 |
"Aggregate!",
|
@@ -605,13 +599,13 @@ if __name__ == "__main__":
|
|
605 |
"\n\n_Aggregate summary is also appended to the bottom of the `.txt` file._"
|
606 |
)
|
607 |
|
608 |
-
gr.Markdown("---")
|
609 |
with gr.Column():
|
610 |
-
gr.Markdown("### Advanced Settings
|
611 |
-
|
612 |
-
|
|
|
613 |
)
|
614 |
-
with gr.Row(
|
615 |
length_penalty = gr.Slider(
|
616 |
minimum=0.3,
|
617 |
maximum=1.1,
|
@@ -626,7 +620,7 @@ if __name__ == "__main__":
|
|
626 |
value=TOKEN_BATCH_OPTIONS[len(TOKEN_BATCH_OPTIONS) // 2],
|
627 |
)
|
628 |
|
629 |
-
with gr.Row(
|
630 |
repetition_penalty = gr.Slider(
|
631 |
minimum=1.0,
|
632 |
maximum=5.0,
|
|
|
482 |
name_to_path = load_example_filenames(_here / "examples")
|
483 |
logger.info(f"Loaded {len(name_to_path)} examples")
|
484 |
|
485 |
+
demo = gr.Blocks(title="Document Summarization")
|
486 |
_examples = list(name_to_path.keys())
|
487 |
logger.info("Starting app instance")
|
488 |
with demo:
|
|
|
489 |
gr.Markdown(
|
490 |
+
"""# Document Summarization with Long-Document Transformers
|
491 |
+
|
492 |
+
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).
|
493 |
+
|
494 |
+
**Want more performance?** Run this demo from a free [Google Colab GPU](https://colab.research.google.com/gist/pszemraj/52f67cf7326e780155812a6a1f9bb724/document-summarization-on-gpu.ipynb)
|
|
|
|
|
|
|
495 |
"""
|
496 |
)
|
497 |
with gr.Column():
|
498 |
+
gr.Markdown("")
|
499 |
gr.Markdown(
|
500 |
+
"""## Load Inputs & Select Parameters
|
501 |
+
|
502 |
+
Enter/paste text below, or upload a file. Pick a model & adjust params (_optional_), and press **Summarize!**
|
503 |
|
504 |
See [the guide doc](https://gist.github.com/pszemraj/722a7ba443aa3a671b02d87038375519) for details.
|
505 |
"""
|
506 |
)
|
507 |
+
with gr.Row():
|
508 |
with gr.Column(variant="compact"):
|
509 |
model_name = gr.Dropdown(
|
510 |
choices=MODEL_OPTIONS,
|
|
|
539 |
label="Text to Summarize",
|
540 |
placeholder="Enter text to summarize, the text will be cleaned and truncated on Spaces. Narrative, academic (both papers and lecture transcription), and article text work well. May take a bit to generate depending on the input text :)",
|
541 |
)
|
|
|
542 |
with gr.Column():
|
543 |
gr.Markdown("## Generate Summary")
|
544 |
with gr.Row():
|
|
|
579 |
)
|
580 |
with gr.Column():
|
581 |
gr.Markdown("### **Aggregate Summary Batches**")
|
|
|
|
|
|
|
582 |
with gr.Row():
|
583 |
aggregate_button = gr.Button(
|
584 |
"Aggregate!",
|
|
|
599 |
"\n\n_Aggregate summary is also appended to the bottom of the `.txt` file._"
|
600 |
)
|
601 |
|
|
|
602 |
with gr.Column():
|
603 |
+
gr.Markdown("""### Advanced Settings
|
604 |
+
|
605 |
+
Refer to [the guide doc](https://gist.github.com/pszemraj/722a7ba443aa3a671b02d87038375519) for what these are, and how they impact _quality_ and _speed_.
|
606 |
+
"""
|
607 |
)
|
608 |
+
with gr.Row():
|
609 |
length_penalty = gr.Slider(
|
610 |
minimum=0.3,
|
611 |
maximum=1.1,
|
|
|
620 |
value=TOKEN_BATCH_OPTIONS[len(TOKEN_BATCH_OPTIONS) // 2],
|
621 |
)
|
622 |
|
623 |
+
with gr.Row():
|
624 |
repetition_penalty = gr.Slider(
|
625 |
minimum=1.0,
|
626 |
maximum=5.0,
|