Giter Site home page Giter Site logo

songmzhang / nmt-kd Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 5.03 MB

Repo for ACL2023 paper "Towards Understanding and Improving Knowledge Distillation for Neural Machine Translation".

Shell 3.52% Makefile 0.01% Python 94.63% Batchfile 0.01% C++ 0.54% C 0.02% Cuda 0.90% Perl 0.05% Cython 0.24% Lua 0.08%

nmt-kd's Introduction

NMT-KD

Code for ACL2023 paper "Towards Understanding and Improving Knowledge Distillation for Neural Machine Translation". [paper]

Requirements

  • python version == 3.7.0
  • fairseq version == 0.12.2
  • pytorch version == 1.13.1
  • sacrebleu version == 1.5.1
  • admin-torch version == 0.1.0

Analysis Experiments (Take WMT14 En-De as an example)

Step 0: Train a teacher model (Transformer-big, 300k steps)

bash train_ende_big_teacher.sh

Step 1: Removing information from word-level KD

(a) Vanilla word-level KD

bash train_ende_vanilla_word_kd.sh

(b) Removing the correlation information

bash train_ende_word_kd_wo_corr.sh

(c) Removing the top-1 information

bash train_ende_word_kd_wo_top1.sh

(d) Student baseline (no KD)

bash train_ende_student_baseline.sh

Step 2: Expand top-1 to top-k information

bash train_ende_word_kd_topk_info.sh

Method: Top-1 Information Enhanced KD (TIE-KD)

bash train_ende_tie_kd.sh

Evaluation

Model Averaging

We use model averaging trick for the evaluation of all the student models (average last 5 checkpoints):

bash average_ckpts.sh

Generation

Then we use fairseq-interactive to generate translations with the averaged model:

bash interactive_ende.sh

We use multi-bleu.perl in mosesdecoder to calculate the tokenized BLEU scores of the translations. Besides, we also use COMET (Unbabel/wmt20-comet-da) for a more convincing evaluation.

Citation

Please cite this paper if you use this repo.

@article{zhang2023towards,
  title={Towards Understanding and Improving Knowledge Distillation for Neural Machine Translation},
  author={Zhang, Songming and Liang, Yunlong and Wang, Shuaibo and Han, Wenjuan and Liu, Jian and Xu, Jinan and Chen, Yufeng},
  journal={arXiv preprint arXiv:2305.08096},
  year={2023}
}

nmt-kd's People

Contributors

songmzhang avatar

Stargazers

Daxiong avatar Kontani Yushi avatar Zengkui Sun avatar  avatar XLiang avatar

Watchers

 avatar

nmt-kd's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.