Crosslingual Generalization through Multitask Finetuning

This repository provides an overview of all components used for the creation of BLOOMZ & mT0 and xP3 introduced in the paper Crosslingual Generalization through Multitask Finetuning. Link to 25min video on the paper by Samuel Albanie; Link to 4min video on the paper by Niklas Muennighoff.
Data
| Name |
Explanation |
Example models |
| xP3x
| Mixture of 17 tasks in 277 languages with English prompts |
WIP - Join us at Project Aya @C4AI to help! |
| xP3
| Mixture of 13 training tasks in 46 languages with English prompts |
BLOOMZ & mT0-13B |
| xP3mt
| Mixture of 13 training tasks in 46 languages with prompts in 20 languages (machine-translated from English) |
BLOOMZ-MT & mT0-13B-MT |
| xP3all
| xP3 + our evaluation datasets adding an additional 3 tasks for a total of 16 tasks in 46 languages with English prompts |
|
| xP3megds
| Megatron-DeepSpeed processed version of xP3 |
BLOOMZ |
| P3
| Repreprocessed version of the English-only P3 with 8 training tasks |
BLOOMZ-P3 & mT0-13B-P3 |
Models
Create xP3(x)
We have processed & uploaded xP3. If you want to recreate it, follow these steps:
- Get promptsource: For xP3mt
git clone -b xp3mt https://github.com/Muennighoff/promptsource.git, for xP3 git clone -b tr13 https://github.com/Muennighoff/promptsource.git & install cd promptsource; pip install -e .
- Get packages
pip install -q datasets iso-639
- Get the creation script & edit it if necessary:
- For xP3mt, set
USE_ENGLISH_PROMPTS = False in the beginning
- For xP3, set
USE_ENGLISH_PROMPTS = True in the beginning
- Run the script, such as via
python prepare_xp3.py or a SLURM script
For the new extension of xP3, xP3x, the process is largely the same except:
- Install the
xp3x branch instead i.e. pip install git+https://github.com/Muennighoff/promptsource.git@xp3x
- The creation script is in this repository & named
create_xp3x.py.
xP3x is a superset of xP3, so unless you want to reproduce the paper, we recommend always using xP3x (or xP3mt if you want machine-translated prompts).
Train models
BLOOMZ
- Download the pretrained model checkpoint, which is of shape PP=12, TP=4, DP=4. If you'd like to reshape the model you will also need to download the universal checkpoint. If you want to continue finetuning, you should use our finetuned checkpoint, which is of shape PP=72, TP=1, DP=4.
- Setup the training code:
git clone -b t0loading https://github.com/bigscience-workshop/Megatron-DeepSpeed & follow its setup guide to create an environment with necessary packages.
- Download the Megatron-DeepSpeed processed xP3megds or repreprocess it for Megatron-DeepSpeed yourself by downloading xP3, removing the
merged_{lang}.jsonl files & preprocess it using the script here.
- Setup & run the training script: We use SLURM scripts available at bigscience-workshop/bigscience/train/tr13-mtf and referred to as
xp3capmixnewcodelonglossseq. E.g. this is the script launched to train bloomz. Important parts of the script to modify are:
#SBATCH variables, such as nodes, gpus, time, etc. - Our SLURM guide is here
source $six_ALL_CCFRWORK/start-tr13f-6B3-ml-t0 to point to your own conda environment setup via Megatron-DeepSpeed
- PATH environment variables, notably
TRAIN_DATA_PATH & VALID_DATA_PATH, which point to files pointing to your processed training and validation data. We provide our files in this repository (xp3capmixnewcodelong_train.txt & xp3capmixnewcodelong_validation.txt), but you will likely want to change the paths inside. The percentages per language are based on how much each language makes up in xP3 with code being slightly upsampled.
- PP_SIZE=72, TP_SIZE=1 & BATCH SIZE & co specifying the layout. This will depend on the hardware available to you. If you change, you may have to reshape the model. For reshaping you need to use the universal checkpoint and use the
--universal flag in the script. We recommend saving a new checkpoint right after & then continuing training without --universal, which will be faster.
- If you want to restart from a saved checkpoint (e.g. after training a few steps like above), make sure to remove the
--no-load-optim & --reset-progress flags
- After training, you can convert the checkpoint to transformers format using the script here
Helpful resources:
mT0