Giter Site home page Giter Site logo

opennmt-docker's Introduction

OpenNMT の使い方

OpenNMT の利用法およびdocker関連のリポジトリ

OpenNMT について

特に説明するまでもなく、オープンソースのニューラル翻訳用のOSSである。
http://opennmt.net/
しかしながらOpenNMTをうまくつかうことでいろいろなアプリケーションに利用可能である。例えば

環境構築

事前 docker, nvidiaドライバ, cuda, cuDNN, nvidia-docker がinstallされていることを前提とする。

$ cd container/shell
$ ./build.sh && ./start.sh

上記のコマンドでdocker環境を構築できる。

入力データ

学習時は分かち書きした以下の4種のファイルを用意しておく。 言語方向は en → ja のように方言語毎に学習する必要がある。今仮に、 en → ja で学習するとすると 以下のデータが必要。検証用は3000文ほどでよい。

  • src-train.txt
    学習用英語文
  • tgt-train.txt
    学習用日本語文
  • src-val.txt
    検証用英語文
  • tgt-val.txt
    検証用日本語文

学習

$ cd bin/
$ ./train.sh
VOC_SIZE=50000
EPOCH=30
logs="./train.log"

for pat in "j2e" "e2j"
do
    # 前処理
    (cd /root/opennmt; th preprocess.lua -train_src /data/corpus/${pat}/src-train.txt -train_tgt /data/corpus/${pat}/tgt-train.txt \
       -valid_src /data/corpus/${pat}/src-val.txt -valid_tgt /data/corpus/${pat}/tgt-val.txt \
       -save_data /data/corpus/${pat}/${pat} -src_vocab_size ${VOC_SIZE} -tgt_vocab_size ${VOC_SIZE} \
       -preprocess_pthreads 8 >> ${logs})

    # 学習
    # GNMT の2層の翻訳モデルで学習 (2GPUで学習)
    (cd /root/opennmt; mkdir -p ${pat}; \
    th train.lua -data /data/corpus/${pat}/${pat}-train.t7 \
       -save_model ./${pat}/${pat}-model -gpuid 1 2 \
       -end_epoch ${EPOCH} -src_vocab_size ${VOC_SIZE} \
       -tgt_vocab_size ${VOC_SIZE} -layers 2 \
       -encoder_type gnmt -save_every_epochs 10 >> ${logs})
done

opennmt-docker's People

Contributors

hisashi-ito avatar

Watchers

 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.