Giter Club home page Giter Club logo

dynamic-clip-attention's Introduction

Dynamic-Clip-Attention

Implementation of A Compare-Aggregate Model with Dynamic-Clip Attention for Answer Selection on TrecQA and WikiQA using Keras

Prerequisites

  • Python 2.x
  • Theano 0.8
  • Keras 1.0

Data

Getting Started

First, you need to install dependencies, then clone this repo:

git clone https://github.com/wjbianjason/Dynamic-Clip-Attention

I have uploaded my prepocess result of WikiQA, you can repeat the procedure as follow:

WikiQA Preprocess

Note: dowload "WikiQACorpus.zip" to the path "./data/raw_data/WikiQA/".

WikiQACorpus.zip download link: https://www.microsoft.com/en-us/download/details.aspx?id=52419

sh preprocess.sh wikiqa

TrecQA Preprocess

Note: If you don't have svn command, you can copy the directory TrecQA_of_CIKM2016_Rao to our path "./data/raw_data/"

sh preprocess.sh trecqa

Because I have uploaded my preprocess data of WikiQA, if you want to cast a glance at our model, you can skip above operations.

Running

usage: main.py [-h] [-t TASK] [-m MODEL] [-d HIDDEN_DIM] [-e EPOCH] [-l LR]
               [-k_q K_VALUE_QUES] [-k_a K_VALUE_ANS] [-b BATCH_SIZE]
               [-p PRE_TRAIN]

WikiQA

Basic approach: listwise

python main.py -t wikiqa -m listwise -d 300 -e 10 -l 0.001 -b 5

Note: k_max and k_threshold need basic approach trained model to init weights. So please running basic approach first.
Second approach: k_max

python main.py -t wikiqa -m k_max -d 300 -e 5 -l 0.001 -b 5 -k_q 5 -k_a 10 -p 5

Third approach: k_threshold

python main.py -t wikiqa -m k_threshold -d 300 -e 4 -l 0.001 -b 6 -k_q 0.08 -k_a 0.08 -p 1

TrecQA

Basic approach: listwise

python main.py -t trecqa -m listwise -d 300 -e 15 -l 0.001 -b 3 

Note: k_max and k_threshold need basic approach trained model to init weights. So please running basic approach first.
Second approach: k_max

python main.py -t trecqa -m k_max -d 300 -e 5 -l 0.001 -b 3 -k_q 3 -k_a 16 -p 5

Third approach: k_threshold
Note: -1 represents the reciprocal of answer length

python main.py -t trecqa -m k_threshold -d 300 -e 5 -l 0.001 -b 3 -k_q -1 -k_a 0.06

Results

In all experiments, we selected training models that obtain the best MAP scores on the development set for testing.
You should be able to reproduce some scores close to the numbers in the experiment table of our paper.
If you want to reproduce the same score, you need to use the following command:

THEANO_FLAGS="dnn.conv.algo_bwd_filter=deterministic,dnn.conv.algo_bwd_data=deterministic" python

which makes the cuDNN's backward pass is deterministic. This is a reproduce problem for Theano, not our trick.

Copyright

All Rights Reserved.

dynamic-clip-attention's People

Contributors

wjbianjason 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.