Code for our ACL2021 paper Neural Machine Translation with Monolingual Translation Memory
Data
The preprocessed JRC data is available at Google Drive.
Environment
The code is written and tested with the following packages:
- transformers==2.11.0
- faiss-gpu==1.6.1
- torch==1.5.1+cu101
Instructions
The scripts to reproduce our results can be found in the scripts folder. Here we give an example to reproduce our experiments (es=>en translation). NOTE: You should check detailed information in the corresponding shell scripts.
-
do
export MTPATH=where_you_hold_your_data_and_models -
data preprocessing:
sh scripts/prepare.sh -
cross-alignment pre-training for the retrieval model:
sh scripts/esen/pretrain.sh -
build the initial index:
sh scripts/esen/build_index.sh(theinput_filecontains target-side sentences after bpe, and pls make sure to remove duplicates (sort -u)) -
training:
sh scripts/esen/train.multihead.dynamic.sh(model #4: fixed