All Projects → THUNLP-MT → Document Transformer

THUNLP-MT / Document Transformer

Licence: bsd-3-clause
Improving the Transformer translation model with document-level context

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Document Transformer

Nlp Tutorial
A list of NLP(Natural Language Processing) tutorials
Stars: ✭ 1,188 (+642.5%)
Mutual labels:  neural-machine-translation
Pytorchnlpbook
Code and data accompanying Natural Language Processing with PyTorch published by O'Reilly Media https://nlproc.info
Stars: ✭ 1,390 (+768.75%)
Mutual labels:  neural-machine-translation
Marian Dev
Fast Neural Machine Translation in C++ - development repository
Stars: ✭ 136 (-15%)
Mutual labels:  neural-machine-translation
Opennmt Tf
Neural machine translation and sequence learning using TensorFlow
Stars: ✭ 1,223 (+664.38%)
Mutual labels:  neural-machine-translation
Pytorch nmt
A neural machine translation model in PyTorch
Stars: ✭ 100 (-37.5%)
Mutual labels:  neural-machine-translation
Opus Mt
Open neural machine translation models and web services
Stars: ✭ 111 (-30.62%)
Mutual labels:  neural-machine-translation
Na Nmt
Non-autoregressive Neural Machine Translation (not a full version)
Stars: ✭ 61 (-61.87%)
Mutual labels:  neural-machine-translation
Nspm
🤖 Neural SPARQL Machines for Knowledge Graph Question Answering.
Stars: ✭ 156 (-2.5%)
Mutual labels:  neural-machine-translation
Openseq2seq
Toolkit for efficient experimentation with Speech Recognition, Text2Speech and NLP
Stars: ✭ 1,378 (+761.25%)
Mutual labels:  neural-machine-translation
Subword Nmt
Unsupervised Word Segmentation for Neural Machine Translation and Text Generation
Stars: ✭ 1,819 (+1036.88%)
Mutual labels:  neural-machine-translation
Njunmt Pytorch
Stars: ✭ 79 (-50.62%)
Mutual labels:  neural-machine-translation
Njunmt Tf
An open-source neural machine translation system developed by Natural Language Processing Group, Nanjing University.
Stars: ✭ 97 (-39.37%)
Mutual labels:  neural-machine-translation
Nlp Models Tensorflow
Gathers machine learning and Tensorflow deep learning models for NLP problems, 1.13 < Tensorflow < 2.0
Stars: ✭ 1,603 (+901.88%)
Mutual labels:  neural-machine-translation
Lang Reps
Code accompanying our EMNLP paper Learning Language Representations for Typology Prediction
Stars: ✭ 75 (-53.12%)
Mutual labels:  neural-machine-translation
Code Docstring Corpus
Preprocessed Python functions and docstrings for automated code documentation (code2doc) and automated code generation (doc2code) tasks.
Stars: ✭ 137 (-14.37%)
Mutual labels:  neural-machine-translation
Xmunmt
An implementation of RNNsearch using TensorFlow
Stars: ✭ 69 (-56.87%)
Mutual labels:  neural-machine-translation
Mt Paper Lists
MT paper lists (by conference)
Stars: ✭ 105 (-34.37%)
Mutual labels:  neural-machine-translation
Mtbook
《机器翻译:基础与模型》肖桐 朱靖波 著 - Machine Translation: Foundations and Models
Stars: ✭ 2,307 (+1341.88%)
Mutual labels:  neural-machine-translation
Ctranslate2
Fast inference engine for OpenNMT models
Stars: ✭ 140 (-12.5%)
Mutual labels:  neural-machine-translation
Nmtpy
nmtpy is a Python framework based on dl4mt-tutorial to experiment with Neural Machine Translation pipelines.
Stars: ✭ 127 (-20.62%)
Mutual labels:  neural-machine-translation

Improving the Transformer Translation Model with Document-Level Context

Contents

Introduction

This is the implementation of our work, which extends Transformer to integrate document-level context [paper]. The implementation is on top of THUMT

Usage

Note: The usage is not user-friendly. May improve later.

  1. Train a standard Transformer model, please refer to the user manual of THUMT. Suppose that model_baseline/model.ckpt-30000 performs best on validation set.

  2. Generate a dummy improved Transformer model with the following command:

python THUMT/thumt/bin/trainer_ctx.py --inputs [source corpus] [target corpus] \
                                      --context [context corpus] \
                                      --vocabulary [source vocabulary] [target vocabulary] \
                                      --output model_dummy --model contextual_transformer \
                                      --parameters train_steps=1
  1. Generate the initial model by merging the standard Transformer model into the dummy model, then create a checkpoint file:
python THUMT/thumt/scripts/combine_add.py --model model_dummy/model.ckpt-0 \
                                         --part model_baseline/model.ckpt-30000 --output train
printf 'model_checkpoint_path: "new-0"\nall_model_checkpoint_paths: "new-0"' > train/checkpoint
  1. Train the improved Transformer model with the following command:
python THUMT/thumt/bin/trainer_ctx.py --inputs [source corpus] [target corpus] \
                                      --context [context corpus] \
                                      --vocabulary [source vocabulary] [target vocabulary] \
                                      --output train --model contextual_transformer \
                                      --parameters start_steps=30000,num_context_layers=1
  1. Translate with the improved Transformer model:
python THUMT/thumt/bin/translator_ctx.py --inputs [source corpus] --context [context corpus] \
                                         --output [translation result] \
                                         --vocabulary [source vocabulary] [target vocabulary] \
                                         --model contextual_transformer --checkpoints [model path] \
                                         --parameters num_context_layers=1

Citation

Please cite the following paper if you use the code:

@InProceedings{Zhang:18,
  author    = {Zhang, Jiacheng and Luan, Huanbo and Sun, Maosong and Zhai, Feifei and Xu, Jingfang and Zhang, Min and Liu, Yang},
  title     = {Improving the Transformer Translation Model with Document-Level Context},
  booktitle = {Proceedings of EMNLP},
  year      = {2018},
}

FAQ

  1. What is the context corpus?

The context corpus file contains one context sentence each line. Normally, context sentence is the several preceding source sentences within a document. For example, if the origin document-level corpus is:

==== source ====
<document id=XXX>
<seg id=1>source sentence #1</seg>
<seg id=2>source sentence #2</seg>
<seg id=3>source sentence #3</seg>
<seg id=4>source sentence #4</seg>
</document>

==== target ====
<document id=XXX>
<seg id=1>target sentence #1</seg>
<seg id=2>target sentence #2</seg>
<seg id=3>target sentence #3</seg>
<seg id=4>target sentence #4</seg>
</document>

The inputs to our system should be processed as (suppose that 2 preceding source sentences are used as context):

==== train.src ==== (source corpus)
source sentence #1
source sentence #2
source sentence #3
source sentence #4

==== train.ctx ==== (context corpus)
(the first line is empty)
source sentence #1
source sentence #1 source sentence #2 (there is only a space between the two sentence)
source sentence #2 source sentence #3

==== train.trg ==== (target corpus)
target sentence #1
target sentence #2
target sentence #3
target sentence #4
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].