{"id":13595134,"url":"https://github.com/alibaba-edu/simple-effective-text-matching","last_synced_at":"2025-04-09T10:32:56.687Z","repository":{"id":37864789,"uuid":"188165544","full_name":"alibaba-edu/simple-effective-text-matching","owner":"alibaba-edu","description":"Source code of the ACL2019 paper \"Simple and Effective Text Matching with Richer Alignment Features\".","archived":false,"fork":false,"pushed_at":"2019-10-11T11:40:11.000Z","size":191,"stargazers_count":340,"open_issues_count":3,"forks_count":67,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-06T17:45:54.262Z","etag":null,"topics":["deep-learning","nlp","quora-question-pairs","snli","tensorflow"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alibaba-edu.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-05-23T05:12:27.000Z","updated_at":"2024-10-15T12:01:28.000Z","dependencies_parsed_at":"2022-08-18T07:16:04.878Z","dependency_job_id":null,"html_url":"https://github.com/alibaba-edu/simple-effective-text-matching","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/alibaba-edu%2Fsimple-effective-text-matching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-edu%2Fsimple-effective-text-matching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-edu%2Fsimple-effective-text-matching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-edu%2Fsimple-effective-text-matching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alibaba-edu","download_url":"https://codeload.github.com/alibaba-edu/simple-effective-text-matching/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248020593,"owners_count":21034459,"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","nlp","quora-question-pairs","snli","tensorflow"],"created_at":"2024-08-01T16:01:44.515Z","updated_at":"2025-04-09T10:32:51.669Z","avatar_url":"https://github.com/alibaba-edu.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# RE2\n\nThis is the original Tensorflow implementation of the ACL 2019 paper [Simple and Effective Text Matching with Richer Alignment Features](https://www.aclweb.org/anthology/P19-1465). Pytorch implementation: https://github.com/alibaba-edu/simple-effective-text-matching-pytorch.\n\n## Quick Links\n\n- [About](#simple-and-effective-text-matching)\n- [Setup](#setup)\n- [Usage](#usage)\n\n## Simple and Effective Text Matching\n\nRE2 is a fast and strong neural architecture for general purpose text matching applications. \nIn a text matching task, a model takes two text sequences as input and predicts their relationship.\nThis method aims to explore what is sufficient for strong performance in these tasks. \nIt simplifies or omits many slow components which are previously considered as core building blocks in text matching.\nIt achieves its performance by a simple idea, which is keeping three key features directly available for inter-sequence alignment and fusion: \nprevious aligned features (**R**esidual vectors), original point-wise features (**E**mbedding vectors), and contextual features (**E**ncoder output).\n\nRE2 achieves performance on par with the state of the art on four benchmark datasets: SNLI, SciTail, Quora and WikiQA,\nacross tasks of natural language inference, paraphrase identification and answer selection \nwith no or few task-specific adaptations. It has at least 6 times faster inference speed compared with similarly performed models.\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"figure.png\" /\u003e\u003c/p\u003e\n\nThe following table lists major experiment results. \nThe paper reports the average and standard deviation of 10 runs and the results can be easily reproduced. \nInference time (in seconds) is measured by processing a batch of 8 pairs of length 20 on Intel i7 CPUs.\nThe computation time of POS features used by CSRAN and DIIN is not included.\n\n|Model|SNLI|SciTail|Quora|WikiQA|Inference Time|\n|---|---|---|---|---|---|\n|[BiMPM](https://github.com/zhiguowang/BiMPM)|86.9|-|88.2|0.731|0.05|\n|[ESIM](https://github.com/lukecq1231/nli)|88.0|70.6|-|-|-|\n|[DIIN](https://github.com/YichenGong/Densely-Interactive-Inference-Network)|88.0|-|89.1|-|1.79|\n|[CSRAN](https://github.com/vanzytay/EMNLP2018_NLI)|88.7|86.7|89.2|-|0.28|\n|RE2|88.9±0.1|86.0±0.6|89.2±0.2|0.7618 ±0.0040|0.03~0.05|\n\nRefer to the paper for more details of the components and experiment results.\n\n## Setup\n\n- install python \u003e= 3.6 and pip\n- `pip install -r requirements.txt`\n- install Tensorflow 1.4 or above (the wheel file for Tensorflow 1.4 gpu version under python 3.6 can be found \n[here](https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/tensorflow_gpu-1.4.1-cp36-cp36m-linux_x86_64.whl))\n- Download [GloVe word vectors](https://nlp.stanford.edu/projects/glove/) (glove.840B.300d) to `resources/`\n\nData used in the paper are prepared as follows:\n\n### SNLI\n\n- Download and unzip [SNLI](https://www.dropbox.com/s/0r82spk628ksz70/SNLI.zip?dl=0) \n(pre-processed by [Tay et al.](https://github.com/vanzytay/EMNLP2018_NLI)) to `data/orig`. \n- Unzip all zip files in the \"data/orig/SNLI\" folder. (`cd data/orig/SNLI \u0026\u0026 gunzip *.gz`)\n- `cd data \u0026\u0026 python prepare_snli.py` \n\n### SciTail\n\n- Download and unzip [SciTail](http://data.allenai.org.s3.amazonaws.com/downloads/SciTailV1.1.zip) \ndataset to `data/orig`.\n- `cd data \u0026\u0026 python prepare_scitail.py`\n\n### Quora\n\n- Download and unzip [Quora](https://drive.google.com/file/d/0B0PlTAo--BnaQWlsZl9FZ3l1c28/view?usp=sharing)\ndataset (pre-processed by [Wang et al.](https://github.com/zhiguowang/BiMPM)) to `data/orig`.\n- `cd data \u0026\u0026 python prepare_quora.py`\n\n### WikiQA\n\n- Download and unzip [WikiQA](https://www.microsoft.com/en-us/download/details.aspx?id=52419)\nto `data/orig`.\n- `cd data \u0026\u0026 python prepare_wikiqa.py`\n- Download and unzip [evaluation scripts](http://cs.stanford.edu/people/mengqiu/data/qg-emnlp07-data.tgz). \nUse the `make -B` command to compile the source files in `qg-emnlp07-data/eval/trec_eval-8.0`.\nMove the binary file \"trec_eval\" to `resources/`.\n\n## Usage\n\nTo train a new text matching model, run the following command: \n\n```bash\npython train.py $config_file.json5\n```\n\nExample configuration files are provided in `configs/`:\n\n- `configs/main.json5`: replicate the main experiment result in the paper.\n- `configs/robustness.json5`: robustness checks\n- `configs/ablation.json5`: ablation study\n\nThe instructions to write your own configuration files:\n\n```json5\n[\n    {\n        name: 'exp1', // name of your experiment, can be the same across different data\n        __parents__: [\n            'default', // always put the default on top\n            'data/quora', // data specific configurations in `configs/data`\n            // 'debug', // use \"debug\" to quick debug your code  \n        ],\n        __repeat__: 5,  // how may repetitions you want\n        blocks: 3, // other configurations for this experiment \n    },\n    // multiple configurations are executed sequentially\n    {\n        name: 'exp2', // results under the same name will be overwritten\n        __parents__: [\n            'default', \n            'data/quora',\n        ],\n        __repeat__: 5,  \n        blocks: 4, \n    }\n]\n```\n\nTo check the configurations only, use\n\n```bash\npython train.py $config_file.json5 --dry\n```\n\n## Citation\n\nPlease cite the ACL paper if you use RE2 in your work:\n\n```\n@inproceedings{yang2019simple,\n  title={Simple and Effective Text Matching with Richer Alignment Features},\n  author={Yang, Runqi and Zhang, Jianhai and Gao, Xing and Ji, Feng and Chen, Haiqing},\n  booktitle={Association for Computational Linguistics (ACL)},\n  year={2019}\n}\n```\n\n## License\nRE2 is under Apache License 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba-edu%2Fsimple-effective-text-matching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falibaba-edu%2Fsimple-effective-text-matching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba-edu%2Fsimple-effective-text-matching/lists"}