1 Star 1 Fork 0

moerqiang / CogQA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CogQA

Project | arXiv

Source codes for the paper Cognitive Graph for Multi-Hop Reading Comprehension at Scale. (ACL 2019 Oral)

We also have a Chinese blog about CogQA on Zhihu (知乎) besides the paper.

Introduction

CogQA is a novel framework for multi-hop question answering in web-scale documents. Founded on the dual process theory in cognitive science, CogQA gradually builds a cognitive graph in an iterative process by coordinating an implicit extraction module (System 1) and an explicit reasoning module (System 2). While giving accurate answers, our framework further provides explainable reasoning paths.

Preprocess

  1. Download and setup Redis database following https://redis.io/download
  2. Download the dataset, evalute script and fullwiki data (enwiki-20171001-pages-meta-current-withlinks-abstracts) from https://hotpotqa.github.io. Unzip improved_retrieval.zip in this repo.
  3. pip install -r requirements.txt
  4. Run python read_fullwiki.py to load wikipedia documents to redis (check the size of dump.rdb in the redis folder is about 2.4GB).
  5. Run python process_train.py to generate hotpot_train_v1.1_refined.json, which contains edges in gold-only cognitive graphs.
  6. mkdir models

Training

The codes automatic assign tasks on all available devices, each handling batch_size / num_gpu samples. We recommend that each gpu has at least 11GB memory to hold 2 batch.

  1. Run python train.py to train Task #1(span extraction).
  2. Run python train.py --load=True --mode='bundle' to train Task #2(answer prediction).

Evaluation

The cogqa.py is the algorithm to answer questions with a trained model. We split the 1-hop nodes found by another similar model into improved_retrieval.zip for reuse in other algorithm. It can directly improve your result on fullwiki setting by just replacing the original input.

  1. unzip improved_retrieval.zip.

  2. python cogqa.py --data_file='hotpot_dev_fullwiki_v1_merge.json'

  3. python hotpot_evaluate_v1.py hotpot_dev_fullwiki_v1_merge_pred.json hotpot_dev_fullwiki_v1_merge.json

  4. You can check the cognitive graph (reasoning process) in the cg part of the predicted json file.

Notes

  1. The changes of this version from the preview version is mainly about detailed comments.
  2. The relatively sensetive hyperparameters includes the number of negative samples, top K, learning rate of task #2, scale factors between different parts...
  3. If our work is useful to you, please cite our paper or star 🌟 our repo~~
MIT License Copyright (c) 2019 THUDM Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Source code and dataset for ACL 2019 paper "Cognitive Graph for Multi-Hop Reading Comprehension at Scale" 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/moerqiang/CogQA.git
git@gitee.com:moerqiang/CogQA.git
moerqiang
CogQA
CogQA
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891