Giter Club home page Giter Club logo

cove-1's Introduction

Context Vectors (CoVe)

This repo provides the Keras implementation of MT-LSTM from the paper Learned in Translation: Contextualized Word Vectors (McCann et. al. 2017) . For a high-level overview of why CoVe are great, check out the post.

The Weights are ported from PyTorch implementation of MT-LSTM by the paper's authur - https://github.com/salesforce/cove

Dependencies

Ported & tested on:

  • keras==2.1.3
  • tensorflow-gpu==1.4.1

For re-running PortFromPytorchToKeras.ipynb requires of PyTorch MT-LSTM implementation from site: https://github.com/salesforce/cove

Usage

Loading model

from keras.models import load_model
cove_model = load_model('Keras_CoVe.h5')

Prediction

  • input - GloVe vectors of dimension - (<batch_size>, <sentence_len>, 300)
  • output - CoVe vectors of dimension - (<batch_size>, <sentence_len>, 600)

Example

cove_model.predict(np.random.rand(1,10,300))

Padding

At the time of porting, keras has issue with using Masking along with Bidirectional layer - keras-team/keras#3086 ,a short-cut fix is applied, where the output of the final Bi-LSTM is removed off of prediction for padded field, refer PortFromPytorchToKeras.ipynb for the shortcut fix

Unknow words

For unknown words we recommend to use value other than ones used for padding, a small non-zero value say 1e-10 is recommended

Implementation Details

  • Refer to PortFromPytorchToKeras.ipynb
  • The ported Keras model is tested against PyTorch model CoVe predictions on SNLI corpus, For testing details refer - PortingTest.ipynb

Reference

  1. MT-LSTM from the paper Learned in Translation: Contextualized Word Vectors (McCann et. al. 2017)
  2. MT-LSTM PyTorch implementation from which weights are ported
  3. GloVe

cove-1's People

Contributors

rgsachin avatar

Watchers

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