Home

Awesome

Lifelong Language Knowledge Distillation 🙋‍♂️ → 🏫 → 👨‍🎓

Code for the paper "Lifelong Language Knowledge Distillation"
In The 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP 2020)
by Yung-Sung Chuang, Shang-Yu Su, Yun-Nung Chen

Our code is based on the released code from LAnguage-MOdeling-for-Lifelong-Language-Learning. Most of the settings are identical to theirs.

📚 Dataset

TaskDataset (Original Data Link)
SummarizationCNN/DM
Goal-Oriented DialogueWOZ
Semantic ParsingWikiSQL
Natural Language GenerationE2ENLG
Natural Language GenerationRNNLG
Text ClassificationAGNews, Yelp, Amazon, DBPedia, Yahoo

We use the released data from LAMOL's authors here, except for E2ENLG and RNNLG datasets.

We also release our processed data in here.

💻 Dependencies (same as LAMOL)

🔧 Setup (same as LAMOL)

  1. Create the following two directories in wherever you want. (you can name the directories arbitrarily):
    • data directory: Where the dataset will be load by the model.
    • model directory: The place for the model to dump its outputs.
  2. Download the dataset: Download here and decompress it. After decompression, move all the files in the decompressed directory into data directory.
  3. Make a copy of env.example and save it as env. In env, set the value of DATA_DIR as data directory and set the value of MODEL_ROOT_DIR as model directory.

👨‍🏫 Training and Testing (same as LAMOL)

train.sh and test.sh are the entrance for training and testing. Main options for them include:

OptionsDescription
seq_train_typeThe mode to deal with a sequence of tasks. Mode include: lll|finetune|multitask|mas|ewc|gem. "lll" is the default value corresponding our proposed method. The others are the methods for comparing with our proposal.
tasksA sequence of tasks we want to train by seq_train_type. Leave a space between tasks after the --tasks tag. Tasks are the keys in TASK_DICT variable in settings.py
model_nameThe language model we want to use. The default is gpt2. Options include gpt2|openai-gpt,
gen_lm_sample_percentageThis tag only works with --seq_train_type lll. The percentage of the size of the dataset will be generated as pseudo samples for our proposed method.
lm_lambdaLambda value for the loss function.
max_n_epochsMaximum epoch value for all tasks.
min_batch_sizeMinimum batch size for all tasks.
min_n_stepsMinimum step for optimizing the model for all tasks.
n_train_epochsEpochs for training for all tasks.
n_gpuNumber of gpu to be used.
reg_lambdaLambda value for mas and ewc.
top_k_lmTop k sampling for the language model.
top_k_qaTop k sampling for the qa model.
train_batch_sizeBatch size for all tasks. The default is 0. Once the value equals to 0, The batch size will be decided dynamically based on the memory usage of the gpu.

🚨 New Arguments

OptionsDescription
distilUse --distil to conduct Word-KD (the teacher model under models/gpt2/lll/[TASK]_0.2/ is needed if [TASK] is in your LLL tasks.)
seq_distilUse --seq_distil to conduct Seq-KD (distilled data need to be put in data/[TASK]_to_squad-distil-v2.0.json, which can be found in Supplementary Materials.)

Examples

See examples in run_seqsoftkd-WCS.sh/run_seqsoftkd-NLG.sh/run_seqsoftkd-TC.sh, which conduct Seq-KD(soft) on all the experiments in our paper.

In the examples, both --seq_distil and --distil are add to the arguments.

If you want to conduct Word-KD, skip --seq_distil in the arguments.

If you want to conduct Seq-KD, skip --distil in the arguments.

Outputs:

We add $SEED suffix to the model dir
If assigning multitask to --seq_train_type tag, the model will be dumped in $MODEL_ROOT_DIR / model_name / seq_train_type /TASK1_TASK2_... directory. Otherwise, it will be in $MODEL_ROOT_DIR / model_name / seq_train_type / TASK1_TASK2_... / TASK1, $MODEL_ROOT_DIR / model_name / seq_train_type / TASK1_TASK2_... / TASK2, ... directories.

📝 Acknowledgements:

📕 Citation

@article{chuang2020lifelong,
  title={Lifelong Language Knowledge Distillation},
  author={Chuang, Yung-Sung and Su, Shang-Yu and Chen, Yun-Nung},
  journal={arXiv preprint arXiv:2010.02123},
  year={2020}
}

@inproceedings{sun2019lamol,
  title={LAMOL: LAnguage MOdeling for Lifelong Language Learning},
  author={Sun, Fan-Keng and Ho, Cheng-Hao and Lee, Hung-Yi},
  booktitle={International Conference on Learning Representations},
  year={2019}
}