MindMerger

February 8, 2025 ยท View on GitHub

Code for MindMerger: Efficient Boosting LLM Reasoning in non-English Languages (NeurIPS 2024)

MindMerger is a new method for multilingual reasoning, which merges LLMs with the external language understanding capabilities from multilingual models to boost the multilingual reasoning performance. A two-step training scheme is introduced to first train to embeded the external capabilities into LLMs and then train the collaborative utilization of the external capabilities and the built-in capabilities in LLMs.

model

Pip Installation

pip install -r requirements.txt

Data Preparation

Download the datasets and checkpoint in here and put them under current folder.

In the folder, we provide two stage training data and evaluation data for math, x-csqa, and xnli tasks. We provide the checkpoint of MindMerger for math based on MetaMath-Llama-7B, for x-csqa based on LLaMAX-7B-X-CSQA, and for xnli based on LLaMAX-7B-X-XNLI. mT5-xl is used as multilingual encoder.

Evaluation

The checkpoint is the parameters of mapping layer for specfic LLM and multilingual model. To evaluate the performance of MindMerger, you can run as follows:

deepspeed run_evaluation.py --deepspeed \
    --llm_path meta-math/MetaMath-7B-V1.0 \
    --mt_path google/mt5-xl \
    --init_checkpoint outputs/MergeMinds/math/augmentation/pytorch_model.bin \
    --augmentation True

Evaluation results on MGSM dataset:

MGSMAvg.TeBnThSwJaZhDeFrRuEsEn
MindMerger (MetaMath-Llama-7B)57.652.852.059.256.851.255.261.255.261.662.466.0

Evaluation results on X-CSQA dataset:

X-CSQAAvg.SwUrHiArViJaPlZhNlRuItDePtFrEsEn
Llama2-7B-X-CSQA50.923.224.732.932.451.050.051.555.656.955.858.859.960.461.861.978.1
MindMerger (Llama2-7B-X-CSQA)61.045.546.248.451.460.653.963.362.963.863.766.867.067.168.169.178.1
LLaMAX-7B-X-CSQA55.143.539.044.145.154.049.954.658.258.957.159.159.060.961.662.774.0
MindMerger (LLaMAX-7B-X-CSQA)61.251.250.750.854.460.455.963.864.464.361.564.264.165.364.667.775.4

Evaluation results on XNLI dataset:

XNLIAvg.SwUrHiThArTrElViZhRuBgDeFrEsEn
Llama2-7B-X-XNLI70.644.655.162.258.464.764.965.675.475.978.978.680.781.783.189.5
MindMerer (Llama2-7B-X-XNLI)78.466.669.474.771.876.275.778.580.380.080.782.483.583.984.488.7
LLaMAX-7B-X-XNLI76.266.765.369.166.273.671.874.377.478.380.381.682.283.084.189.7
MindMerer (LLaMAX-7B-X-XNLI)79.272.671.574.973.477.176.478.780.480.580.882.483.184.184.588.5

Training

We use a two-stage scheme to train MergeMinds.

Mapping stage helps LLM learn to use the capabilities of multilingual model.

deepspeed run_training.py --deepspeed \
    --llm_path meta-math/MetaMath-7B-V1.0 \
    --mt_path google/mt5-xl \
    --task math \
    --stage_name mapping --train_num 100000 \
    --train_batch_size 128 \
    --train_micro_batch_size_per_gpu 8 \
    --augmentation False \
    --epoch_num 3 \
    --max_seq_len 200 \
    --max_gen_len 200 

Augmentation stage helps LLM collaboratively utilize its own and the capabilities from multilingual model.

deepspeed run_training.py --deepspeed \
    --llm_path meta-math/MetaMath-7B-V1.0 \
    --mt_path google/mt5-xl \
    --task math \
    --stage_name augmentation --train_num 30000 \
    --train_batch_size 128 \
    --train_micro_batch_size_per_gpu 2 \
    --augmentation False \
    --epoch_num 3 \
    --max_seq_len 512 \
    --max_gen_len 512

You can also use the script to run our codes:

bash scripts/training_math.sh

Reference

Please cite this paper in your publications if it helps your research:

@inproceedings{DBLP:conf/nips/HuangZ0LY24,
  author       = {Zixian Huang and
                  Wenhao Zhu and
                  Gong Cheng and
                  Lei Li and
                  Fei Yuan},
  editor       = {Amir Globersons and
                  Lester Mackey and
                  Danielle Belgrave and
                  Angela Fan and
                  Ulrich Paquet and
                  Jakub M. Tomczak and
                  Cheng Zhang},
  title        = {MindMerger: Efficiently Boosting {LLM} Reasoning in non-English Languages},
  booktitle    = {Advances in Neural Information Processing Systems 38: Annual Conference
                  on Neural Information Processing Systems 2024, NeurIPS 2024, Vancouver,
                  BC, Canada, December 10 - 15, 2024},
  year         = {2024},
  url          = {http://papers.nips.cc/paper\_files/paper/2024/hash/3bf80b34f731313b8292f4578e820c90-Abstract-Conference.html}
}