MatthiasC commited on
Commit
0e6b382
β€’
1 Parent(s): eba16a4

Disable summary generation at the end

Browse files
Files changed (1) hide show
  1. app.py +79 -78
app.py CHANGED
@@ -470,84 +470,85 @@ if summarize_button:
470
  for current_drawing_list in total_unmatched_deps:
471
  render_dependency_parsing(current_drawing_list)
472
 
473
- # OUTRO/CONCLUSION
474
- st.header("🀝 Bringing it together")
475
- st.markdown("We have presented 2 methods that try to detect errors in summaries via post-processing steps. Entity "
476
- "matching can be used to solve hallucinations, while dependency comparison can be used to filter out "
477
- "some bad sentences (and thus worse summaries). These methods highlight the possibilities of "
478
- "post-processing AI-made summaries, but are only a first introduction. As the methods were "
479
- "empirically tested they are definitely not sufficiently robust for general use-cases.")
480
- st.markdown("####")
481
- st.markdown(
482
- "Below we generate 3 different kind of summaries, and based on the two discussed methods, their errors are "
483
- "detected to estimate a factualness score. Based on this basic approach, "
484
- "the best summary (read: the one that a human would prefer or indicate as the best one) "
485
- "will hopefully be at the top. Summaries with the same scores will get the same rank displayed.")
486
- st.markdown("####")
487
-
488
- with st.spinner("Calculating more summaries and scoring them, this might take a minute or two..."):
489
- summaries_list = []
490
- deduction_points = []
491
- # ENTITIES
492
- _, amount_unmatched = get_and_compare_entities(False)
493
-
494
- # DEPS
495
- summary_deps = check_dependency(False)
496
- article_deps = check_dependency(True)
497
- total_unmatched_deps = []
498
- for summ_dep in summary_deps:
499
- if not any(summ_dep['identifier'] in art_dep['identifier'] for art_dep in article_deps):
500
- total_unmatched_deps.append(summ_dep)
501
-
502
- summaries_list.append(st.session_state.summary_output)
503
- deduction_points.append(len(amount_unmatched) + len(total_unmatched_deps))
504
-
505
- # FOR NEW GENERATED SUMMARY
506
- st.session_state.summary_output = generate_abstractive_summary(st.session_state.article_text,
507
- type="beam",
508
- do_sample=True, num_beams=15,
509
- no_repeat_ngram_size=5)
510
- _, amount_unmatched = get_and_compare_entities(False)
511
-
512
- summary_deps = check_dependency(False)
513
- article_deps = check_dependency(True)
514
- total_unmatched_deps = []
515
- for summ_dep in summary_deps:
516
- if not any(summ_dep['identifier'] in art_dep['identifier'] for art_dep in article_deps):
517
- total_unmatched_deps.append(summ_dep)
518
-
519
- summaries_list.append(st.session_state.summary_output)
520
- deduction_points.append(len(amount_unmatched) + len(total_unmatched_deps))
521
-
522
- # FOR NEW GENERATED SUMMARY
523
- st.session_state.summary_output = generate_abstractive_summary(st.session_state.article_text,
524
- type="top_p",
525
- do_sample=True,
526
- no_repeat_ngram_size=5)
527
- _, amount_unmatched = get_and_compare_entities(False)
528
-
529
- summary_deps = check_dependency(False)
530
- article_deps = check_dependency(True)
531
- total_unmatched_deps = []
532
- for summ_dep in summary_deps:
533
- if not any(summ_dep['identifier'] in art_dep['identifier'] for art_dep in article_deps):
534
- total_unmatched_deps.append(summ_dep)
535
-
536
- summaries_list.append(st.session_state.summary_output)
537
- deduction_points.append(len(amount_unmatched) + len(total_unmatched_deps))
538
-
539
- # RANKING AND SHOWING THE SUMMARIES
540
- deduction_points, summaries_list = (list(t) for t in zip(*sorted(zip(deduction_points, summaries_list))))
541
-
542
- cur_rank = 1
543
- rank_downgrade = 0
544
- for i in range(len(deduction_points)):
545
- st.write(f'πŸ† Rank {cur_rank} summary: πŸ†', display_summary(summaries_list[i]), unsafe_allow_html=True)
546
- if i < len(deduction_points) - 1:
547
- rank_downgrade += 1
548
- if not deduction_points[i + 1] == deduction_points[i]:
549
- cur_rank += rank_downgrade
550
- rank_downgrade = 0
 
551
 
552
  # session = SessionState.get(code=print("TEST"))
553
  # a = st.radio("Edit or show", ['Edit', 'Show'], 1)
 
470
  for current_drawing_list in total_unmatched_deps:
471
  render_dependency_parsing(current_drawing_list)
472
 
473
+ # CURRENTLY DISABLED
474
+ # # OUTRO/CONCLUSION
475
+ # st.header("🀝 Bringing it together")
476
+ # st.markdown("We have presented 2 methods that try to detect errors in summaries via post-processing steps. Entity "
477
+ # "matching can be used to solve hallucinations, while dependency comparison can be used to filter out "
478
+ # "some bad sentences (and thus worse summaries). These methods highlight the possibilities of "
479
+ # "post-processing AI-made summaries, but are only a first introduction. As the methods were "
480
+ # "empirically tested they are definitely not sufficiently robust for general use-cases.")
481
+ # st.markdown("####")
482
+ # st.markdown(
483
+ # "Below we generate 3 different kind of summaries, and based on the two discussed methods, their errors are "
484
+ # "detected to estimate a factualness score. Based on this basic approach, "
485
+ # "the best summary (read: the one that a human would prefer or indicate as the best one) "
486
+ # "will hopefully be at the top. Summaries with the same scores will get the same rank displayed.")
487
+ # st.markdown("####")
488
+ #
489
+ # with st.spinner("Calculating more summaries and scoring them, this might take a minute or two..."):
490
+ # summaries_list = []
491
+ # deduction_points = []
492
+ # # ENTITIES
493
+ # _, amount_unmatched = get_and_compare_entities(False)
494
+ #
495
+ # # DEPS
496
+ # summary_deps = check_dependency(False)
497
+ # article_deps = check_dependency(True)
498
+ # total_unmatched_deps = []
499
+ # for summ_dep in summary_deps:
500
+ # if not any(summ_dep['identifier'] in art_dep['identifier'] for art_dep in article_deps):
501
+ # total_unmatched_deps.append(summ_dep)
502
+ #
503
+ # summaries_list.append(st.session_state.summary_output)
504
+ # deduction_points.append(len(amount_unmatched) + len(total_unmatched_deps))
505
+ #
506
+ # # FOR NEW GENERATED SUMMARY
507
+ # st.session_state.summary_output = generate_abstractive_summary(st.session_state.article_text,
508
+ # type="beam",
509
+ # do_sample=True, num_beams=15,
510
+ # no_repeat_ngram_size=5)
511
+ # _, amount_unmatched = get_and_compare_entities(False)
512
+ #
513
+ # summary_deps = check_dependency(False)
514
+ # article_deps = check_dependency(True)
515
+ # total_unmatched_deps = []
516
+ # for summ_dep in summary_deps:
517
+ # if not any(summ_dep['identifier'] in art_dep['identifier'] for art_dep in article_deps):
518
+ # total_unmatched_deps.append(summ_dep)
519
+ #
520
+ # summaries_list.append(st.session_state.summary_output)
521
+ # deduction_points.append(len(amount_unmatched) + len(total_unmatched_deps))
522
+ #
523
+ # # FOR NEW GENERATED SUMMARY
524
+ # st.session_state.summary_output = generate_abstractive_summary(st.session_state.article_text,
525
+ # type="top_p",
526
+ # do_sample=True,
527
+ # no_repeat_ngram_size=5)
528
+ # _, amount_unmatched = get_and_compare_entities(False)
529
+ #
530
+ # summary_deps = check_dependency(False)
531
+ # article_deps = check_dependency(True)
532
+ # total_unmatched_deps = []
533
+ # for summ_dep in summary_deps:
534
+ # if not any(summ_dep['identifier'] in art_dep['identifier'] for art_dep in article_deps):
535
+ # total_unmatched_deps.append(summ_dep)
536
+ #
537
+ # summaries_list.append(st.session_state.summary_output)
538
+ # deduction_points.append(len(amount_unmatched) + len(total_unmatched_deps))
539
+ #
540
+ # # RANKING AND SHOWING THE SUMMARIES
541
+ # deduction_points, summaries_list = (list(t) for t in zip(*sorted(zip(deduction_points, summaries_list))))
542
+ #
543
+ # cur_rank = 1
544
+ # rank_downgrade = 0
545
+ # for i in range(len(deduction_points)):
546
+ # st.write(f'πŸ† Rank {cur_rank} summary: πŸ†', display_summary(summaries_list[i]), unsafe_allow_html=True)
547
+ # if i < len(deduction_points) - 1:
548
+ # rank_downgrade += 1
549
+ # if not deduction_points[i + 1] == deduction_points[i]:
550
+ # cur_rank += rank_downgrade
551
+ # rank_downgrade = 0
552
 
553
  # session = SessionState.get(code=print("TEST"))
554
  # a = st.radio("Edit or show", ['Edit', 'Show'], 1)