{"id":17046042,"url":"https://github.com/vzhong/e3","last_synced_at":"2025-04-12T15:31:10.324Z","repository":{"id":40982722,"uuid":"186903615","full_name":"vzhong/e3","owner":"vzhong","description":"Dockerized code for E3: Entailment-driven Extracting and Editing for Conversational Machine Reading.","archived":false,"fork":false,"pushed_at":"2023-07-22T05:49:40.000Z","size":31,"stargazers_count":48,"open_issues_count":4,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T10:04:20.790Z","etag":null,"topics":["deep-learning","machine-learning","nlp"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/1906.05373","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vzhong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-15T21:14:12.000Z","updated_at":"2024-09-05T08:27:56.000Z","dependencies_parsed_at":"2024-11-07T14:02:13.069Z","dependency_job_id":"b8e7aa60-07d7-48a1-9529-b2e2ca01572d","html_url":"https://github.com/vzhong/e3","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/vzhong%2Fe3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhong%2Fe3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhong%2Fe3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhong%2Fe3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vzhong","download_url":"https://codeload.github.com/vzhong/e3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248589422,"owners_count":21129610,"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":["deep-learning","machine-learning","nlp"],"created_at":"2024-10-14T09:44:22.127Z","updated_at":"2025-04-12T15:31:09.963Z","avatar_url":"https://github.com/vzhong.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# E3: Entailment-driven Extracting and Editing for Conversational Machine Reading\n\nThis repository contains the source code for the paper [E3: Entailment-driven Extracting and Editing for Conversational Machine Reading](https://arxiv.org/abs/1906.05373).\nThis work was published at ACL 2019.\nIf you find the paper or this repository helpful in your work, please use the following citation:\n\n```\n@inproceedings{ zhong2019e3,\n  title={ E3: Entailment-driven Extracting and Editing for Conversational Machine Reading },\n  author={ Zhong, Victor and Zettlemoyer, Luke },\n  booktitle={ ACL },\n  year={ 2019 }\n}\n```\n\nThe output results from this codebase have minor differences from those reported in the paper due to library versions.\nThe most consistent way to replicate the experiments is via the Docker instructions.\nOnce ran, inference on the dev set should produce something like the following:\n\n```\n{'bleu_1': 0.6714,\n 'bleu_2': 0.6059,\n 'bleu_3': 0.5646,\n 'bleu_4': 0.5367,\n 'combined': 0.39372312,\n 'macro_accuracy': 0.7336,\n 'micro_accuracy': 0.6802}\n```\n\nIn any event, the model binaries used for our submission are included in the `/opt/save` directory of the docker image `vzhong/e3`.\nFor correspondence, please contact [Victor Zhong](mailto://victor@victorzhong.com).\n\n\n## Non-Docker instructions\n\nIf you have docker, scroll down to the (much shorter) docker instructions.\n\n\n### Setup\n\nFirst we will install the dependencies required.\n\n```bash\npip install -r requirements.txt\n```\n\nNext we'll download the pretrained BERT parameters and vocabulary, word embeddings, and Stanford NLP.\nThis is a big download ~10GB.\n\n```bash\n# StanfordNLP, BERT, and ShARC data\n./download.sh\n\n# Spacy data for evaluator\npython -m spacy download en_core_web_md\n\n# word embeddings\npython -c \"import embeddings as e; e.GloveEmbedding()\"\npython -c \"import embeddings as e; e.KazumaCharEmbedding()\"\n```\n\n\n### Training\n\nThe E3 model is trained in two parts due to data imbalance (there are many more turn examples than full dialogue trees).\nThe first part consists of everything except for the editor.\nThe second part trains the editor alone, because it relies on unique dialogue trees, of which there are few compared to the total number of turn examples.\nWe start by preprocessing the data.\nThis command will print out some statistics from preprocessing the train/dev sets.\n\n```bash\n./preprocess_sharc.py\n```\n\nNow, we will train the model without the editor.\nWith a Titan-X, this takes roughly 2 hours to complete.\nFor more options, check out `python train_sharc.py --help`\n\n```bash\nCUDA_VISIBLE_DEVICES=0 python train_sharc.py\n```\n\nNow, we will train the editor.\nAgain, with a Titan-X, this takes roughly 20 minutes to complete.\nFor more options, check out `python train_editor.py --help`\n\n```bash\n./preprocess_editor_sharc.py\nCUDA_VISIBLE_DEVICES=0 python train_editor.py\n```\n\nTo evaluate the models, run `inference.py`.\nFor more options, check out `python inference.py --help`\n\n```bash\nCUDA_VISIBLE_DEVICES=0 python inference.py --retrieval save/default-entail/best.pt --editor editor_save/default-double/best.pt --verify\n```\n\nIf you want to tune the models, you can also use `list_exp.py` to visualize the experiment results.\nThe model ablations from our paper are found in the `model` directory.\nNamely, `base` is the BERTQA model (referred to in the paper as `E3-{edit,entail,extract}`), `retrieve` is the `E3-{edit,entail}` model, and `entail` is the `E3-{edit}` model.\nYou can choose amongst these models using the `--model` flag in `train_sharc.py`.\n\n\n## Docker instructions\n\nIf you have `docker` (and `nvidia-docker`), then there is no need to install dependencies.\nYou still need to clone this repo and run `download.sh`.\nFor convenience, I've made a wrapper script that pass through your username and mounts the current directory.\nFrom inside the directory, to preprocess and train the model:\n\n```bash\ndocker/wrap.sh python preprocess_sharc.py\nNV_GPU=0 docker/wrap.sh python train_sharc.py\ndocker/wrap.sh python preprocess_editor.py\nNV_GPU=0 docker/wrap.sh python train_editor.py\n```\n\nTo evaluate the model and dump predictions in an output folder:\n\n```bash\nNV_GPU=0 docker/wrap.sh python inference.py --retrieval save/default-entail/best.pt --editor editor_save/default-double/best.pt --verify\n```\n\nTo reproduce our submission results with the included model binaries:\n\n```bash\nNV_GPU=0 docker/wrap.sh python inference.py --retrieval /opt/save/retrieval.pt --editor /opt/save/editor.pt --verify\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvzhong%2Fe3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvzhong%2Fe3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvzhong%2Fe3/lists"}