Giter Club home page Giter Club logo

lstm-syl's Introduction

Syllable-aware Neural Language Models

Code for the Syl-Concat, Syl-Sum, and Syl-CNN models from the paper Syllable-aware Neural Language Models: A Failure to Beat Character-aware Ones (EMNLP 2017)

Requirements

Code is written in Python 3 and requires TensorFlow 1.1+. It also requires the following Python modules: numpy, pyphen, argparse. You can install them via:

sudo pip3 install numpy pyphen argparse

Data

Data should be put into the data/ directory, split into train.txt, valid.txt, and test.txt. Each line of the .txt file should be a sentence. The English Penn Treebank (PTB) data is given as the default.

The non-English data (Czech, French, German, Russian, and Spanish) can be downloaded from Jan Botha's website. For ease of use you can use the Yoon Kim's script, which downloads these data and saves them into the relevant folders.

Note on non-English data

The PTB data above does not have end-of-sentence tokens for each sentence, and by default these are appended. The non-English data already have end-of-sentence tokens for each line so, you want to add --eos " " to the command line.

For non-English data you also need to specify the appropriate hyphenation dictionary which is supported by Pyphen via the --dict option. The complete list of dictionaries is available at LibreOffice's repository.

Model

To reproduce the Syl-Concat result on English PTB from Table 1

python3 LSTM-Syl.py

To reproduce the Syl-Sum result on English PTB from Table 3 use

python3 LSTM-Syl.py --model sum --size medium

To reproduce the Syl-CNN result on Czech DATA-S from Table 3 use

python3 LSTM-Syl.py --model cnn --size medium --data_dir data/cs --dict cs_CZ --eos " "

Sampled Softmax

Training on a larger vocabulary will require sampled softmax (SSM) to train at a reasonable speed. You can use the --ssm 1 option to do this.

Other options

To see the full list of options run

python3 LSTM-Syl.py -h

lstm-syl's People

Contributors

zh3nis avatar

Stargazers

Noel Elias avatar  avatar  avatar Fan(帆) Yang(杨) avatar  avatar 爱可可-爱生活 avatar

Watchers

paper2code - bot 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.