GithubHelp home page GithubHelp logo

zouhir / bimpm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhiguowang/bimpm

0.0 2.0 0.0 83 KB

BiMPM: Bilateral Multi-Perspective Matching for Natural Language Sentences

License: Apache License 2.0

Python 100.00%

bimpm's Introduction

BiMPM: Bilateral Multi-Perspective Matching for Natural Language Sentences

Updates (Jan 28, 2018)

  • This repository has been updated to tensorflow 1.5
  • The training process speeds up 15+ times without lossing the accuracy.
  • All codes have been re-constructed for better readability and adaptability.

Description

This repository includes the source code for natural language sentence matching. Basically, the program takes two sentences as input, and predict a label for the two input sentences. You can use this program to deal with tasks like paraphrase identification, natural language inference, duplicate questions identification et al. More details about the underneath model can be found in our paper published in IJCAI 2017. Please cite our paper when you use this program! ๐Ÿ˜

Requirements

  • python 2.7
  • tensorflow 1.5

Data format

Both the train and test sets require a tab-separated format. Each line in the train (or test) file corresponds to an instance, and it should be arranged as

label sentence#1 sentence#2 instanceID

For more details about the data format, you can download the SNLI and the Quora Question Pair datasets used in our paper.

Training

You can find the training script at BiMPM/src/SentenceMatchTrainer.py

First, edit the configuration file at ${workspace}/BiMPM/configs/snli.sample.config (or ${workspace}/BiMPM/configs/quora.sample.config ). You need to change the "train_path", "dev_path", "word_vec_path", "model_dir", "suffix" to your own setting.

Second, launch job using the following command line

python ${workspace}/BiMPM/SentenceMatchTrainer.py --config_path ${workspace}/BiMPM/configs/snli.sample.config

Testing

You can find the testing script at BiMPM/src/SentenceMatchDecoder.py

python ${workspace}/BiMPM/src/SentenceMatchDecoder.py --in_path ${your_path_to}/dev.tsv --word_vec_path ${your_path_to}/wordvec.txt --out_path ${your_path_to}/result.json --model_prefix ${model_dir}/SentenceMatch.${suffix}

Where "model_dir" and "suffix" are the variables set in your configuration file.

The output file is a json file with the follwing format.

{
    { 
        "ID": "instanceID",
        "truth": label,
        "sent1": sentence1,
        "sent2": sentence2,
        "prediction": prediciton,
        "probs": probs_for_all_possible_labels
    },
    { 
        "ID": "instanceID",
        "truth": label,
        "sent1": sentence1,
        "sent2": sentence2,
        "prediction": prediciton,
        "probs": probs_for_all_possible_labels
    }
}

Reporting issues

Please let me know, if you encounter any problems.

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.