Code Monkey home page Code Monkey logo

quora_duplicate's Introduction

quora_duplicate

Implementation of semantic question matching with deep learning approaches mentioned in the blog of Quora.

Description

This project includes 4 RNN models mentioned in the blog of quora. These models have a common structure, which can be summarised as a series steps:

  • First generate word embeddings for each sentence.
  • Second represent each word by using RNN network (could be LSTM or GRU or bidirectional RNN) which captures context of each sentence.
  • Third use computational operations (simple concatenate or attend mechanisms or other ops) to combine several timesteps context vectors into a single vector. This step differentiate the 4 models in this project.
  • At last use dense feed forward neural networks for the final classification.

models/basic_rnn.py - implements basic RNN, the first approach in quora blog.

models/res_distance.py - implements the second approach in quora blog.

models/decomposable_attention.py - implements an attention-based approach from [2], the third approach in quora blog

models/compare_aggregate.py - implements another attention-based approach from [3].

models/layers.py - other layers, word embedding layers, context layer, etc.

train_model.py - train and test models. You could change model_name in main() to train different model.

data_util.py - data processing.

config.py - hyper-parameters.

I also implement BiMPM [4] model, however the matching operations are very complicated which result in a very slow training time. You could find the codes from here.

If you find any bugs, please create an issue, thanks.

Requirements

  • python 2.7
  • tensorflow 1.1.0
  • keras 2.0.3
  • numpy 1.12.1
  • pandas 0.19.2
  • nltk 3.2.2
  • gensim 1.0.1

References

[1] Lili Jiang, Shuo Chang, and Nikhil Dandekar. "Semantic Question Matching with Deep Learning."

[2] Ankur P Parikh, Oscar Tackstrom, Dipanjan Das, and Jakob Uszkoreit. "A decomposable atten- tion model for natural language inference."

[3] Shuohang Wang and Jing Jiang. "A compare-aggregate model for matching text sequences."

[4] Zhiguo Wang, Wael Hamza and Radu Florian. "Bilateral Multi-Perspective Matching for Natural Language Sentences."

quora_duplicate's People

Contributors

ijinmao avatar

Stargazers

Oğuz Kırçiçek avatar  avatar  avatar yick avatar  avatar yanqiangmiffy avatar ccy avatar  avatar  avatar yuanke avatar Amir Hadifar avatar Adit Biswas avatar gowithwind avatar goodluckMrlee avatar Vinay M avatar

Watchers

 avatar ccy avatar

quora_duplicate's Issues

config doesn't have any attribute called WORD_EMBEDDING_DIM or MAX_NB_WORDS

When use decomposable_attention for training model it throws exception because there is no attribute in config called WORD_EMBEDDING_DIM. I think you should change this to following:

nb_words = min(TrainConfig.MAX_NB_WORDS, len(word_index)) + 1
    embedding_matrix = np.zeros((nb_words, TrainConfig.WORD_EMBEDDING_DIM))
    for word, i in word_index.items():
        if word in word2vec.vocab:
            embedding_matrix[i] = word2vec.word_vec(word)
    print('Null word embeddings: %d' % np.sum(np.sum(embedding_matrix, axis=1) == 0))

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.