{"id":18439480,"url":"https://github.com/idiap/sentence-planner","last_synced_at":"2025-04-07T21:32:33.135Z","repository":{"id":50716177,"uuid":"412067897","full_name":"idiap/sentence-planner","owner":"idiap","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-06T12:33:31.000Z","size":13283,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-23T01:01:56.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-30T13:05:45.000Z","updated_at":"2023-07-01T02:20:38.000Z","dependencies_parsed_at":"2022-08-22T23:20:55.629Z","dependency_job_id":null,"html_url":"https://github.com/idiap/sentence-planner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fsentence-planner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fsentence-planner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fsentence-planner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fsentence-planner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiap","download_url":"https://codeload.github.com/idiap/sentence-planner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247732696,"owners_count":20986905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T06:24:55.518Z","updated_at":"2025-04-07T21:32:28.122Z","avatar_url":"https://github.com/idiap.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sentence-planner\n\nThis is the code for the paper [Sentence-level Planning for Especially Abstractive Summarization](https://aclanthology.org/2021.newsum-1.1.pdf) presented at the *New Frontiers in Summarization* workshop at EMNLP 2021.\n\nThe repository is a fork of the [PreSumm](https://github.com/nlpyang/PreSumm) repository. Changed and added source files are marked in their header comment, others are left untouched. \n\n## Contents\n1. [Data](#data)\n2. [Installation](#installation)\n3. [Training](#training)\n4. [Evaluation](#evaluation)\n5. [Citation](#citation)\n\n## Data\nFor CNN/DM, download the preprocessed data or follow the instructions in the [PreSumm](https://github.com/nlpyang/PreSumm) repository.\n\nFor Curation Corpus, follow the instructions over at the [Curation Corpus](https://github.com/CurationCorp/curation-corpus) repository to download the articles. Then follow the instructions in Appendix B of our paper for the preprocessing. If you have trouble reconstructing the dataset, do not hesitate to contact us.\n\n## Installation\nFirst, get a working installation of conda, e.g. [Miniconda](https://docs.conda.io/en/latest/miniconda.html).\nThen, recreate the environment from inside this directory by running:\n\n```shell\nconda env create -f environment.yml\nconda activate presumm\n```\n\n## Training\nThe model can be trained with:\n\n```shell\npython src/train.py \\\n--model sentsumm \\\n--sentplan_loss_weight 1 \\\n--mode train \\\n--bert_data_path \u003cpath_to_data_dir\u003e/curation \\\n--result_path \u003cpath_to_result_dir\u003e/curation \\\n--model_path \u003cpath_to_model_dir\u003e \\\n--log_file train.log\n```\n\nA few things to note:\n* Data paths consist of the path to the data directory and the prefix of the preprocessed data files (in our case, this is \"cnndm\" or \"curation\").\n* The same holds for result paths.\n\n## Evaluation\n### Validation\nSimilar to training, the model is validated as follows:\n\n```shell\npython src/train.py \\\n--model sentsumm \\\n--sentplan_loss_weight 1 \\\n--mode validate \\\n--bert_data_path \u003cpath_to_data_dir\u003e/curation \\\n--result_path \u003cpath_to_result_dir\u003e/curation \\\n--model_path \u003cpath_to_model_dir\u003e \\\n--log_file validate.log \\\n--test_all\n```\n\nBy looking at the results in the log file, you can select the best checkpoint to keep and discard the rest.\n\nValidation also generates candidate-reference summary pairs, each in their respective files in the results directory. These are used in the evaluations below.\n\n### ROUGE\nThe official Perl implementation can be called with a helper script like:\n```shell\npython src/perl_rouge.py \\\n--candidates_path \u003cpath_to_result_dir\u003e/\u003cname_of_candidate_summaries_file\u003e \\\n--references_path \u003cpath_to_result_dir\u003e/\u003cname_of_reference_summaries_file\u003e\n```\n\nInstallation instructions for the Perl ROUGE script can be found at the [PreSumm](https://github.com/nlpyang/PreSumm) repository.\n\n### Novel bigrams, sentences, words\nThere is a short evaluation script for each of these, and they all work the same:\n```shell\npython src/eval/novel_bigrams.py --eval_dir \u003cpath_to_result_dir\u003e\n```\n\n### Attribution\nTo compute the attribution to the sentence representation (Section 4.2), use the `src/gxa.py` for the Integrated Gradients algorithm, or `src/conductance.py` for the Conductance algorithm.\nExample usage:\n```shell\npython src/gxa.py \\\n--model_path \u003cpath_to_model_dir\u003e \\\n--result_path \u003cpath_to_result_dir\u003e \\\n--bert_data_path \u003cpath_to_data_dir\u003e/curation \\\n--share_word_enc \\\n--use_dec_src_attn \\\n--use_sent_cond \\\n--see_past_sents \\\n--num_examples 100 \\\n--num_ig_steps 50 \\\n--baseline zero\n```\n\n### Corefs\nThe Corefs evaluation tests the number of coreference links across sentence boundaries. The evaluation comes with a separate conda environment. Additionally, you have to download a spacy model, in our case `en_core_web_lg`.\nRun it with:\n```shell\nconda env create -f coref.yml\nconda activate coref\npython -m spacy download en_core_web_lg\npython src/eval/coref.py --eval_dir \u003cpath_to_result_dir\u003e\n```\n\n## Citation\nIf you use this code, please cite us.\n```\n@inproceedings{marfurt-henderson-2021-sentence,\n    title = \"Sentence-level Planning for Especially Abstractive Summarization\",\n    author = \"Marfurt, Andreas  and\n      Henderson, James\",\n    booktitle = \"Proceedings of the Third Workshop on New Frontiers in Summarization\",\n    month = nov,\n    year = \"2021\",\n    address = \"Online and in Dominican Republic\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://aclanthology.org/2021.newsum-1.1\",\n    doi = \"10.18653/v1/2021.newsum-1.1\",\n    pages = \"1--14\",\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Fsentence-planner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiap%2Fsentence-planner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Fsentence-planner/lists"}