Workshop at NAACL 2022, Seattle, Friday July 15, 2022
Contact:
autosimtrans.workshop@gmail.com or
twitter.com/autosimtrans
conda_specfile.txt
和pip_requirement.txt
两个文件
conda activate <myenv> # activate your virtual env
conda list --explicit > conda_specfile.txt # export packages installed via conda
pip freeze > pip_requirement.txt # export packages installed via pip
Dockerfile_pt13.gpu
)
wget https://raw.githubusercontent.com/autosimtrans/autosimtrans.github.io/master/sp/Dockerfile_pt13.gpu
<code folder>
。打开Dockerfile_pt13.gpu
,编辑替换OpenNMT-py
为你自己的代码和模型所在的文件夹<code folder>
(将模型复制到当前工作目录的原因是docker配置文件的CP
命令只支持相对路径)。本Dockerfile文件可以按需调整cuda/cudnn版本。docker build -t <ImageName:Tag> -f Dockerfile_pt13.gpu .
mkdir decode && chmod 777 decode
nvidia-docker run -it -v <abs_path_to_your_data_dir>:/data -v <abs_path_to_your_local_decode_result_dir>:/decode <ImageName:Tag> bash
python translate.py -model multi30k_model_step_100000.pt -src /data/wmt16-multi30k/test2016.en.atok -tgt /data/wmt16-multi30k/test2016.de.atok -replace_unk -verbose -output /decode/multi30k.test.pred.atok
<abs_path_to_your_local_decode_result_dir>
(本地) or /decode
(docker容器中)查看翻译结果并测试BLEU分数
# in docker conatiner
perl tools/multi-bleu.perl /data/wmt16-multi30k/test2016.de.atok < /decode/multi30k.test.pred.atok
# result:
# BLEU = 35.50, 65.9/41.8/28.8/20.0 (BP=1.000, ratio=1.007, hyp_len=12323, ref_len=12242)
tar
文件
docker tag <local-image:loacl-tagname> <dockerhub_username/new-repo:repo-tagname>
docker login
docker push <dockerhub_username/new-repo:repo-tagname>
tar
文件,以便后续传送
# save image to `tar` file
docker save -o <imageFile>.tar <local-image:loacl-tagname>
# load `tar` file to image
docker load < <imageFile>.tar
wget https://github.com/autosimtrans/autosimtrans.github.io/raw/master/sp/wmtdata.tar.gz
tar -zxvf wmtdata.tar.gz
mkdir decode && chmod 777 decode
sudo nvidia-docker run -it -v <abs_path_to_your_data_dir>:/data -v <abs_path_to_your_local_decode_result_dir>:/decode kaiboliu/onmt-py_en2de:torch1.3-gpu bash
python translate.py -model multi30k_model_step_100000.pt -src /data/wmt16-multi30k/test2016.en.atok -replace_unk -verbose -output /decode/multi30k.test.pred.atok
<abs_path_to_your_local_decode_result_dir>
(本地) 或者 /decode
(docker容器中)查看翻译结果并测试BLEU分数
# in docker conatiner
perl tools/multi-bleu.perl /data/wmt16-multi30k/test2016.de.atok < /decode/multi30k.test.pred.atok
# result:
# BLEU = 35.50, 65.9/41.8/28.8/20.0 (BP=1.000, ratio=1.007, hyp_len=12323, ref_len=12242)