Git Product home page Git Product logo

adversarial-multihopqa's Introduction

Adversarial-MultiHopQA

Dependencies

Run download_data.sh to pull HotpotQA data and GloVe vectors.

  • We tested our code on TF1.3, TF1.8, TF1.11 and TF1.13.
  • See requirements.txt.

1. Preprocess the data using Corenlp

Run:

python3 convert_sp_facts.py corenlp -d dev

to store preprocessed data in data/hotpotqa/dev_corenlp_cache_***.json. This avoids rerunning Corenlp every time we generate an adversarial data. If you want to create the adversarial training data, run:

python3 convert_sp_facts.py corenlp -d train

Warning: preprocessing both the training set and dev set requires a storage space of ~22G.

2. Collect the candidate answer and title set

Run:

python3 convert_sp_facts.py gen-answer-set -d dev

and

python3 convert_sp_facts.py gen-title-set -d dev

This step collect all answers and Wikipedia article titles in the dev set and classify them based on their NER and POS tag.

3. (Optional) Collect all paragraphs appearining in the context

If you want to eliminate the title-balancing bias in the adversarial documents (described in the last paragraph of Sec. 2.2), run:

python3 convert_sp_facts.py gen-all-docs -d dev

4. Generate Adverarial Dev set

To generate the adversarial dev set described in our paper, run:

python3 convert_sp_facts.py dump-addDoc -d dev -b --rule wordnet_dyn_gen --replace_partial_answer --num_new_doc=4 --dont_replace_full_answer --find_nearest_glove --add_doc_incl_adv_title

This will create the adversarial training set in out/hotpot_dev_addDoc.json Note: --add_doc_incl_adv_title can be set only if Step 3 is done.

5. Generate Adverarial Training set

Generating the adversarial training set all at once could take days. Therefore, we divide the training set into 19 batches with the size of 5000, and process each batch in a separate program by running:

python3 convert_sp_facts.py dumpBatch-addDoc -d train -b --rule wordnet_dyn_gen --replace_partial_answer --num_new_doc=4 --dont_replace_full_answer --find_nearest_glove --add_doc_incl_adv_title --batch_idx=0

with batch_idx set to 0~18. After they finish, run:

python3 convert_sp_facts.py merge_files -d train

This will create the adversarial training set in out/hotpot_train_addDoc.json

Citation

@inproceedings{Jiang2019reasoningshortcut, 
	author={Yichen Jiang and Mohit Bansal}, 
	booktitle={Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics}, 
	title={Avoiding Reasoning Shortcuts: Adversarial Evaluation, Training, and Model Development for Multi-Hop QA}, 
	year={2019}, 
}

adversarial-multihopqa's People

Contributors

jiangyctarheel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.