Code Monkey home page Code Monkey logo

torch-defseq's Introduction

Dictionary Definition Models

A recurrent neural network that learns to define words from dictionaries. This repository is for AAAI2017 paper: "Definition Modeling: Learning to define word embeddings in natural language" along with the preporcessing scripts.

Dependencies

CUDA Libraries

Skip this if you do not have a GPU.

Torch Libraries

Most of the libraries will come with Torch if you install from their installation script. You can use luarocks to install additional packages. For examples, luarocks install dp. The additional packages are:

If you are planing to use GPU (CUDA), you will need the following packages:

  • cutorch
  • cunn
  • cudnn (make sure that you get the right branch for your cuDNN version)

To install from source, go to the source code directory and run luarocks install.

Python Libraries

  • numpy
  • KenLM (installation: pip install https://github.com/kpu/kenlm/archive/master.zip)

Word Embedding

You will also need a set of word embeddings in torch binary format of an object:

{
  M, -- 2D tensor where each row is an embedding
  v2wvocab, -- index-to-word map
  w2vvocab -- word-to-index map
}

You can download embeddings from Word2Vec and use word2vec.torch to convert them into torch binary file.

Usage

In most of the scripts, there will be a help message which can be accessed by

th script.lua --help

Preparing data

  • First you need to convert text data into torch binary files by using preprocess/prep_definition.lua. This will create multiple torch binary files in the data directory
  • Then sub-select word embeddings using preprocess/prep_w2v.lua. This will align vocab and only save a set of embeddings we need)

We include our dataset (data/commondefs). If you want to use other dataset, please check the file format. For dictionary parsing scripts, check out dict-definition (only support WordNet and GCIDE for now).

Main scripts

  • train.lua is a script for training a model
  • test.lua is a script that uses a model to compute perplexity, generate definitions, and rank words (reverse dictionary).

Please see the option within the help message of the scripts.

To-do

  • Add detail usage and examples to README
  • Refactor ranking scripts

torch-defseq's People

Contributors

northanapon avatar

Stargazers

 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.