{"id":19731644,"url":"https://github.com/clovaai/focusseq2seq","last_synced_at":"2025-10-06T16:30:47.895Z","repository":{"id":52878945,"uuid":"205110214","full_name":"clovaai/FocusSeq2Seq","owner":"clovaai","description":"[EMNLP 2019] Mixture Content Selection for Diverse Sequence Generation (Question Generation / Abstractive Summarization)","archived":false,"fork":false,"pushed_at":"2021-04-15T11:14:41.000Z","size":1839,"stargazers_count":113,"open_issues_count":5,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T21:51:09.449Z","etag":null,"topics":["emnlp2019","generation","nlp","pytorch","question-generation","summarization"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/1909.01953","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clovaai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-29T07:51:18.000Z","updated_at":"2025-01-17T13:11:55.000Z","dependencies_parsed_at":"2022-08-23T12:31:14.703Z","dependency_job_id":null,"html_url":"https://github.com/clovaai/FocusSeq2Seq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clovaai/FocusSeq2Seq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FFocusSeq2Seq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FFocusSeq2Seq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FFocusSeq2Seq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FFocusSeq2Seq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clovaai","download_url":"https://codeload.github.com/clovaai/FocusSeq2Seq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FFocusSeq2Seq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278643325,"owners_count":26021085,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["emnlp2019","generation","nlp","pytorch","question-generation","summarization"],"created_at":"2024-11-12T00:22:23.235Z","updated_at":"2025-10-06T16:30:45.557Z","avatar_url":"https://github.com/clovaai.png","language":"Python","readme":"## Mixture Content Selection for Diverse Sequence Generation\n\n* Authors: [Jaemin Cho](https://j-min.io), [Minjoon Seo](https://seominjoon.github.io), [Hannaneh Hajishirzi](https://homes.cs.washington.edu/~hannaneh/)\n* [Paper](https://arxiv.org/abs/1909.01953) (To appear in [EMNLP 2019](https://emnlp-ijcnlp2019.org))\n* [Poster](_imgs/EMNLP19_Focus_portrait_v3.pdf)\n\nWe explicitly separate **diversification** from **generation** using a mixture-of-experts content selection module (called **Selector**) that guides an encoder-decoder model.\n\n![methods_figure](_imgs/methods_horizontal.png)\n\n1. **Diverse Content Selection (one-to-many)**: Selector samples different binary masks (called **focus**; m1, m2, and m3 in the figure) on a source sequence.\n\n2. **Focused Generation (one-to-one)**: an encoder-decoder model generates different sequences from the source sequence guided by different masks.\n\nNot only does this improve **diversity** of the generated sequences, but also improves **accuracy** (high fidelity) of them, since conventional models often learn suboptimal mapping that is in the middle of the targets but not near any of them.\n\n# Prerequisites\n\n## 1) Hardware\n* All experiments in paper were conducted with single P40 GPU (24GB).\n* You might want to adjust the size of batch and models for your memory size.\n\n## 2) Software\n* Ubuntu 16.04 or 18.04 (Not tested with other versions, but might work)\n* Python 3.6+\n  - `pip install -r requirements.txt` or manually install the packages below.\n  ```\n  torch==1.1\n  nltk\n  pandas\n  tqdm\n  pyyaml\n  git+git://github.com/bheinzerling/pyrouge\n  ```\n* ROUGE-1.5.5 (for CNN-DM evaluation)\n  ```sh\n  # From https://github.com/falcondai/pyrouge/tree/9cdbfbda8b8d96e7c2646ffd048743ddcf417ed9\n  wget https://www.dropbox.com/s/dl/zqhvtgfg40h3g3l/rouge_1.5.5.zip\n  unzip rouge_1.5.5.zip\n  mv RELEASE-1.5.5 utils/rouge\n  ```\n\n## 3) Data\n\n```sh\n# Download preprocessed data at ./squad/, ./cnndm/ and ./glove/ respectively\nwget https://www.dropbox.com/s/dl/0gtz5ckh3ie55oq/emnlp2019focus_redistribute.zip\nunzip emnlp2019focus_redistribute.zip\n\n# Generate train_df.pkl, val_df.pkl, test_df.pkl and vocab.pkl at ./squad_out/\npython QG_data_loader.py\n\n# Generate train_df.pkl, val_df.pkl, test_df.pkl and vocab.pkl at ./cnndm_out/\npython CNNDM_data_loader.py\n```\nDetails of dataset source are at [Dataset_details.md](Dataset_details.md)\n\n# Run\nYou can see more configurations in [configs.py](configs.py)\n\n## Train\n1) Question Generation\n```sh\npython train.py --task=QG --model=NQG --load_glove=True --feature_rich --data=squad \\\n    --rnn=GRU --dec_hidden_size=512 --dropout=0.5 \\\n    --batch_size=64 --eval_batch_size=64 \\\n    --use_focus=True --n_mixture=3 --decoding=greedy\n```\n\n2) Abstract Summrization\n```sh\npython train.py --task=SM --model=PG --load_glove=False --data=cnndm \\\n    --rnn=LSTM --dec_hidden_size=512 \\\n    --batch_size=16 --eval_batch_size=64 \\\n    --use_focus=True --n_mixture=3 --decoding=greedy\n```\n\n## Evaluation\n`--load_ckpt (integer; 5 for example)` and `--eval_only` options need to be added.\n\n1) Question Generation\n```sh\npython evaluate.py --task=QG --model=NQG --load_glove=True --feature_rich --data=squad \\\n    --rnn=GRU --dec_hidden_size=512 --dropout=0.5 \\\n    --batch_size=64 --eval_batch_size=64 \\\n    --use_focus=True --n_mixture=3 --decoding=greedy \\\n    --load_ckpt=5 --eval_only\n```\n\n2) Abstract Summrization\n```sh\npython evaluate.py --task=SM --model=PG --load_glove=False --data=cnndm \\\n    --rnn=LSTM --dec_hidden_size=512 \\\n    --batch_size=16 --eval_batch_size=64 \\\n    --use_focus=True --n_mixture=3 --decoding=greedy \\\n    --load_ckpt=5 --eval_only\n```\n\n\n# Reference\nIf you use this code or model as part of any published research, please refer the following paper.\n```BibTex\n@inproceedings{cho2019focus,\n  title     = {Mixture Content Selection for Diverse Sequence Generation},\n  author    = {Cho, Jaemin and Seo, Minjoon and Hajishirzi, Hannaneh},\n  booktitle = {EMNLP},\n  year      = {2019}\n}\n```\n\n# License\n\n```\nCopyright (c) 2019-present NAVER Corp.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclovaai%2Ffocusseq2seq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclovaai%2Ffocusseq2seq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclovaai%2Ffocusseq2seq/lists"}