Transformer implementation in PyTorch.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dataset
model
utils
.gitignore
LICENSE
README.md
decoder.py
requirements.txt
train.py

README.md

Transformer

This is a pytorch implementation of the Transformer model like tensorflow/tensor2tensor.

Prerequisite

I tested it with PyTorch 1.0.0 and Python 3.6.5.

It's using SpaCy to tokenize languages. So, if you want to run wmt32 problem which is a de/en translation dataset, you should download language models first with the following command.

$ pip install spacy
$ python -m spacy download en
$ python -m spacy download de

Usage

  1. Train a model.
$ python train.py --problem wmt32k --output_dir ./output --data_dir ./wmt32k_data
  1. You can translate a single sentence with the trained model.
$ python decoder.py --translate --data_dir ./wmt32k_data --model_dir ./output/last/models