A PyTorch implementation of the Transformer model in "Attention is All You Need".
A PyTorch implementation of the Transformer model in "Attention is All You Need".
This is a PyTorch implementation of the Transformer model in "Attention is All You Need" (Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin, arxiv, 2017).
A novel sequence to sequence framework utilizes the self-attention mechanism, instead of Convolution operation or Recurrent structure, and achieve the state-of-the-art performance on WMT 2014 English-to-German translation task. (2017/06/12)
The official Tensorflow Implementation can be found in: tensorflow/tensor2tensor.
To learn more about self-attention mechanism, you could read "A Structured Self-attentive Sentence Embedding".
The project support training and translation with trained model now.
Note that this project is still a work in progress.
BPE related parts are not yet fully tested.
If there is any suggestion or error, feel free to fire an issue to let me know. :)
An example of training for the WMT'16 Multimodal Translation task (http://www.statmt.org/wmt16/multimodal-task.html).
# conda install -c conda-forge spacy
python -m spacy download en
python -m spacy download depython preprocess.py -lang_src de -lang_trg en -share_vocab -save_data m30k_deen_shr.pklpython train.py -data_pkl m30k_deen_shr.pkl -log m30k_deen_shr -embs_share_weight -proj_share_weight -label_smoothing -output_dir output -b 256 -warmup 128000 -epoch 400python translate.py -data_pkl m30k_deen_shr.pkl -model trained.chkpt -output prediction.txtSince the interfaces is not unified, you need to switch the main function call from
main_wo_bpetomain.
python preprocess.py -raw_dir /tmp/raw_deen -data_dir ./bpe_deen -save_data bpe_vocab.pkl -codes codes.txt -prefix deenpython train.py -data_pkl ./bpe_deen/bpe_vocab.pkl -train_path ./bpe_deen/deen-train -val_path ./bpe_deen/deen-val -log deen_bpe -embs_share_weight -proj_share_weight -label_smoothing -output_dir output -b 256 -warmup 128000 -epoch 400根据requirements.txt安装出错
ValueError: Cell is empty
preprocess ERROR
python preprocess.py -lang_src de -lang_trg en -save_data multi30k_de_en.pkl -share_vocab have problem
Preprocess error
when I run the `python preprocess.py -lang_src de -lang_trg en -share_vocab -save_data m30k_deen_shr.pkl`.I have faced a problem
Error time to execute 'python preprocess.py -lang_src de -lang_trg en -share_vocab -save_data m30k_deen_shr.pkl' command
preprocess error
About target mask
TranslationDataset is now deprecated in torchtext