Train your own SPM models and Fairseq dictionary
mainIf you wish to use custom data instead of the provided BPCC datasets, follow these steps to train your own SentencePiece (SPM) models and learn a Fairseq dictionary:
- Collect Data: Gather balanced English and Indic monolingual data (recommended ~3M sentences per language-script combination).
- Unify Scripts: Perform script unification for Indic languages using
scripts/preprocess_translate.pyand concatenate all Indic data into a single file. - Train SPM: Train two separate SPM models (one for English, one for Indic) using
spm_train. - Learn Dictionary: Copy the trained SPM models to your experiment directory and run
prepare_data_joint_training.shto learn the Fairseq dictionary.
Important: Use the same Fairseq dictionary for any subsequent fine-tuning experiments.
# Train SPM model
spm_train --input=train.indic --model_prefix=<model_name> --vocab_size=<vocab_size> --character_coverage=1.0 --model_type=BPE
# Learn Fairseq dictionary
bash prepare_data_joint_training.sh <exp_dir>