基于Pythorch的神经机器翻译工具包Reader-Translator-Generator(RTG)
rtg的Python项目详细描述
读写器转换器生成器(RTG)
<读者>翻译生成器(RTG)是基于PyTrink的神经机器翻译工具包。 有关文档,请参阅https://isi-nlp.github.io/rtg/。在特点
- 可重复的实验:一个
conf.yml
拥有所有东西——数据路径、参数和 超参数——需要复制实验。在 - 预处理选项:sentencepiece或nlcodec(或添加自己的)
- word/char/bpe等类型
- 共享词汇,独立词汇
- 单向、双向、三向捆绑嵌入件
- Transformer model from "Attention is all you need"(完全测试并与{a5}竞争)
- 跨多个GPU自动检测和并行化。(注意:所有的GPU必须在同一个节点中!)在
- 变压器品种繁多:变宽变压器、跳变变压器等
- RNN based Encoder-Decoder与{a7}一起使用。(不再使用它,但它是用来做实验的)
- 语言建模:RNN,Transformer
- 还有更多。。
- 简单易懂的代码(对于那些读代码和读论文一样多的人来说)
- 面向对象的设计。张量传感器的功能和功能不多(工厂太多)
- 实验和重现性是重点。要控制实验,请编辑实验目录中的YAML文件。在
- 如果可能,最好是convention-over-configuation。看看这个实验目录中的examples/transformer.test.yml
快速启动
使用这个googlecolab笔记本来学习如何使用RTG训练您的NMT模型:https://colab.research.google.com/drive/198KbkUcCGXJXnWiM7IyEiO1Mq2hdVq8T?usp=sharing
设置
将此repo的根目录添加到PYTHONPATH
或通过pip --editable
安装它
git clone https://github.com/isi-nlp/rtg-xt.git # use rtg.git if you have accesscd rtg # go to the code conda create -n rtg python=3.7 # adds a conda env named rtg conda activate rtg # activate it# install this as a local editable pip package pip install --editable . # All requirements are in setup.py
使用
请参阅scripts/rtg-pipeline.sh
bash脚本和examples/transformer.base.yml
文件以获取特定示例。在
管道接受源(.src
)和目标(.tgt
)文件。源语言是一种语言,目标是另一种语言。至少提供培训来源、培训目标、验证来源和验证目标。最好使用.tok
文件进行培训。(.tok
表示标记化。)
培训和运行mdoel的示例:
^{pr2}$主持实验的001-tfm
目录如下所示:
001-tfm
├── _PREPARED <-- Flag file indicating experiment is prepared
├── _TRAINED <-- Flag file indicating experiment is trained
├── conf.yml <-- Where all the params and hyper params are! You should look into this
├── data
│ ├── samples.tsv.gz <-- samples to log after each check point during training
│ ├── sentpiece.shared.model <-- as the name says, sentence piece model, shared
│ ├── sentpiece.shared.vocab <-- as the name says
│ ├── train.db <-- all the prepared trainig data in a sqlite db
│ └── valid.tsv.gz <-- and the validation data
├── githead <-- whats was the git HEAD hash this experiment was started?
├── job.sh.bak <-- job script used to submit this to grid. Just in case
├── models <-- All checkpoints go inside this
│ ├── model_400_5.265583_4.977106.pkl
│ ├── model_800_4.478784_4.606745.pkl
│ ├── ...
│ └── scores.tsv <-- train and validation losses. incase you dont want to see tensorboard
├── rtg.log <-- the python logs are redirected here
├── rtg.zip <-- the source code used to run. just `export PYTHONPATH=rtg.zip` to
├── scripts -> /Users/tg/work/me/rtg/scripts <-- link to some perl scripts for detok+BLEU
├── tensorboard <-- Tensorboard stuff for visualizations
│ ├── events.out.tfevents.1552850552.hackb0x2
│ └── ....
└── test_step2000_beam4_ens5 <-- Tests after the end of training, BLEU scores
├── valid.ref -> /Users/tg/work/me/rtg/data/valid.ref
├── valid.src -> /Users/tg/work/me/rtg/data/valid.src
├── valid.out.tsv
├── valid.out.tsv.detok.tc.bleu
└── valid.out.tsv.detok.lc.bleu
作者:
学分/感谢
- OpenNMT和哈佛NLP团队,我从他们的工作中学到了很多
- My team at USC ISI其他的一切
- 项目
标签: