[关闭]
@kpatrick 2019-10-29T11:42:20.000000Z 字数 3605 阅读 128

翻译模型的训练和部署

交接


0. 环境

1. 相关目录

1.1 数据集

1.2 工具

1.3 训练数据、脚本和模型

中-英,英-中的目录结构一致,所以这里只拿中-英的讲解。

1.3.1 数据

1.3.2 脚本

1.3.3 模型


2. 训练

2.1 数据集

见1.3.1节。

2.2 预处理流程

2.3 参数配置

  1. # scripts directory of moses decoder: http://www.statmt.org/moses/
  2. # you do not need to compile moses; a simple download is sufficient
  3. moses_scripts=/home/xiaojie/URun.ResearchPrototype/People/Xiaojie/MachineTranslation/toolbox/mosesdecoder/scripts
  4. #scripts for subword segmentation: https://github.com/rsennrich/subword-nmt
  5. bpe_scripts=/home/xiaojie/URun.ResearchPrototype/People/Xiaojie/MachineTranslation/toolbox/subword-nmt
  6. #nematus (theano version): https://github.com/EdinburghNLP/nematus/tree/theano
  7. nematus_home=/home/xiaojie/URun.ResearchPrototype/People/Xiaojie/MachineTranslation/toolbox/nematus
  8. #jieba word segmentation utility: https://pypi.python.org/pypi/jieba/
  9. #this is only required for Chinese
  10. zh_segment_home=/home/xiaojie/URun.ResearchPrototype/People/Xiaojie/MachineTranslation/toolbox/jieba
  11. # Theano/TensorFlow device; change this to execute Nematus on GPU
  12. #
  13. # For Theano, a typical value is 'cuda'
  14. #
  15. # For TensorFlow, the value will be passed to CUDA_VISIBLE_DEVICES. It should
  16. # be a list of GPU identifiers. For example, '1' or '0,1,3'
  17. device='3'

指定训练用的硬件,就是最后一个device的配置

2.4 模型训练

cd /home/xiaojie/URun.ResearchPrototype/People/Xiaojie/MachineTranslation/Transformer_zh-en/training/scripts
./train.sh

2.5 模型评价

训练时会有模型的指标输出,如果需要手动计算,可以利用1.2中的bleu工具计算,在之前对模型评价时,我整理中英和英中的计算脚本,目录分别是,可以用notebook打开查看:


3. 接口部署

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注