Awesome
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.
-
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.
-
Generate a dummy improved Transformer model with the following command:
- Generate the initial model by merging the standard Transformer model into the dummy model, then create a checkpoint file:
- Train the improved Transformer model with the following command:
- Translate with the improved Transformer model:
Citation
Please cite the following paper if you use the code:
<pre><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}, } </code></pre>FAQ
- 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:
<pre><code>==== 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></code></pre>The inputs to our system should be processed as (suppose that 2 preceding source sentences are used as context):
<pre><code>==== 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</code></pre>