基于Pythorch的神经机器翻译工具包Reader-Translator-Generator(RTG)

rtg的Python项目详细描述


读写器转换器生成器(RTG)

<读者>翻译生成器(RTG)是基于PyTrink的神经机器翻译工具包。 有关文档,请参阅https://isi-nlp.github.io/rtg/。在

特点

  • 可重复的实验:一个conf.yml拥有所有东西——数据路径、参数和 超参数——需要复制实验。在
  • 预处理选项:sentencepiecenlcodec(或添加自己的)
    • 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.shbash脚本和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


作者:

See Here

学分/感谢

  • OpenNMT和哈佛NLP团队,我从他们的工作中学到了很多
  • My team at USC ISI其他的一切

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
我们应该在测试java代码时模拟黄瓜测试吗。我们应该在多大程度上使用黄瓜?   Hibernate Weblogic 10.3.4 java。lang.NoSuchMethodError:javax/persistence/spi/PersistenceUnitInfo。getValidationMode()Ljavax/persistence/ValidationMode;   java如何在main()中访问私有静态实例变量   java JMockit无法模拟类的公共final字段   java是否可以返回特定控制器操作的输出(html)?   java如何返回正确类型的列表?   rest-OpenUI/Swagger-java-to-API   java组织。springframework。豆。工厂NoSuchBeanDefinitionException或加载ApplicationContext失败   java使用POST将参数从JSP发送到Servlet   java如何监听特定的按钮按下和主视图用户交互?   java如何让gradle在本地maven repo中覆盖库?   如何在Java中“合并”两个URI?   java如何制作一个方法来移动数组中的字符?   使用来自java的命令启动powershell窗口   java垃圾收集器和匿名类   java如何为CellTable(GWT 2.4)中的ImageResourceCell创建PanelPopup?