NJUNLP/QAlign

Ruby

38

0 commits

updated Jan 23, 2024

See the code

README

Question Translation Training for Better Multilingual Reasoning

πŸ“ƒ Paper | πŸ€— Huggingface | πŸ“­ Contact

⛰️ Overview

  • This repository shares the code and models of our latest work on multilingual reasoning. In this work, we present a novel X-English question alignment finetuning step which performs targeted language alignment for best use of the LLMs English reasoning abilities.
  • Utilizing this library, you can finetune open-source LLMs into strong multilingual reasoning systems. For example, our fine-tuned LLaMA2-7B/13B achieves superior multilingual performance, significantly outperforming baseline models of equivalent size.
  • Overall, our method effectively reduces the performance disparity of LLMs across English and non-English languages, showing a new paradigm to unlock LLM’s capabilities to accompolish multilingual tasks.

πŸ“ˆ Benchmarks

Below we present LLMs' average answer accuracy (zero-shot) on multilingual reasoning benchmarks. With question alignment, our fine-tuned LLM surpasses the unaligned counterpart and the translate-training baseline (MathOctopus) by a large margin.

Our model has been open-sourced on Huggingface.

System (13B)Monolingual SupervisionMultilingual SupervisionmGSMmSVAMP
QAlign (ours)MetaMathQA-57.162.6
MetaMathMetaMathQA-43.951.8
MathOctopus-GSM8KInstruct45.846.5
WizardMathGSM8K & MATH-28.335.7
MAmmoThMathInstruct-28.938.6
RFTGSM8k-ScRel-29.537.1
SFTGSM8K-29.738.1
System (7B)Monolingual SupervisionMultilingual SupervisionmGSMmSVAMP
QAlign (ours)MetaMathQA-49.657.2
MetaMathMetaMathQA-38.446.2
MathOctopus-GSM8KInstruct40.044.1
WizardMathGSM8K & MATH-23.032.5
MAmmoThMathInstruct-21.326.3
RFTGSM8k-ScRel-20.631.3
SFTGSM8K-22.630.9

πŸ“‚ Dataset

In the table below, we list datasets that are used in this project. All datasets are available within this repository, with the exception of MetaMathQA. To use MetaMathQA, please download the file MetaMathQA-395K.json with the provided link and place it in the ./data/metamath directory.

DatasetUsageSizeLanguagesPath
MetaMathQATraining395,000En./data/metamath
GSM8KInstructTraining73,559En, Bn, Th, Sw, Ja, Zh, De, Fr, Ru, Es./data/gsm8kinstruct
mGSMEvaluation2,500En, Bn, Th, Sw, Ja, Zh, De, Fr, Ru, Es./evaluate/scripts/data/mgsm
mSVAMPEvaluation10,000En, Bn, Th, Sw, Ja, Zh, De, Fr, Ru, Es./evaluate/scripts/data/msvamp

🧩 Installation

To install this repository, follow these steps:

git clone [email protected]:NJUNLP/QAlign.git
cd QAlign
pip install --editable ./

For detailed information about the conda environment, refer to the environment.yaml file.

πŸ› οΈ Training

We develope our training pipeline based on the stanford_alpaca repository.

To perform question alignment and response alignment on pre-trained LLMs, use the following command. Please note that you must replace $PROJECT_PATH with the appropriate paths in finetune.sh or finetune_dp.sh to ensure it is executable. When fine-tuning the 13B model, we utilize DeepSpeed to save memory. You can find our deepspeed configuration in the ./config/ds.json file.

  • finetuning LLaMA2-7B
bash ./training_scripts/finetune_llama2_7B.sh
  • finetuning LLaMA2-13B
bash ./training_scripts/finetune_llama2_13B.sh

πŸ“ Evaluation

We use the evaluation code provided by Chen et al., which meansures answer accuracy by comparing the last numerical number that appears in the LLM-generated response with the gold answer.

To evaluate the model on mGSM and mSVAMP dataset, use the following command. Please note that you must replace $PROJECT_PATH and $MODEL_PATH with the appropriate paths in the script to ensure it is executable.

  • evaluating with mGSM
cd evaluate/scripts

bash evaluate_mgsm.sh
  • evaluating with mSVAMP
cd evaluate/scripts

bash evaluate_msvamp.sh

🌲 Citation

If you find this repository helpful, feel free to cite our paper:

@misc{zhu2024question,
      title={Question Translation Training for Better Multilingual Reasoning}, 
      author={Wenhao Zhu and Shujian Huang and Fei Yuan and Shuaijie She and Jiajun Chen and Alexandra Birch},
      year={2024},
      eprint={2401.07817},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

NJUNLP/QAlign

Ruby

38

0 commits

updated Jan 23, 2024

See the code

README

Question Translation Training for Better Multilingual Reasoning

πŸ“ƒ Paper | πŸ€— Huggingface | πŸ“­ Contact

⛰️ Overview

  • This repository shares the code and models of our latest work on multilingual reasoning. In this work, we present a novel X-English question alignment finetuning step which performs targeted language alignment for best use of the LLMs English reasoning abilities.
  • Utilizing this library, you can finetune open-source LLMs into strong multilingual reasoning systems. For example, our fine-tuned LLaMA2-7B/13B achieves superior multilingual performance, significantly outperforming baseline models of equivalent size.
  • Overall, our method effectively reduces the performance disparity of LLMs across English and non-English languages, showing a new paradigm to unlock LLM’s capabilities to accompolish multilingual tasks.

πŸ“ˆ Benchmarks

Below we present LLMs' average answer accuracy (zero-shot) on multilingual reasoning benchmarks. With question alignment, our fine-tuned LLM surpasses the unaligned counterpart and the translate-training baseline (MathOctopus) by a large margin.

Our model has been open-sourced on Huggingface.

System (13B)Monolingual SupervisionMultilingual SupervisionmGSMmSVAMP
QAlign (ours)MetaMathQA-57.162.6
MetaMathMetaMathQA-43.951.8
MathOctopus-GSM8KInstruct45.846.5
WizardMathGSM8K & MATH-28.335.7
MAmmoThMathInstruct-28.938.6
RFTGSM8k-ScRel-29.537.1
SFTGSM8K-29.738.1
System (7B)Monolingual SupervisionMultilingual SupervisionmGSMmSVAMP
QAlign (ours)MetaMathQA-49.657.2
MetaMathMetaMathQA-38.446.2
MathOctopus-GSM8KInstruct40.044.1
WizardMathGSM8K & MATH-23.032.5
MAmmoThMathInstruct-21.326.3
RFTGSM8k-ScRel-20.631.3
SFTGSM8K-22.630.9

πŸ“‚ Dataset

In the table below, we list datasets that are used in this project. All datasets are available within this repository, with the exception of MetaMathQA. To use MetaMathQA, please download the file MetaMathQA-395K.json with the provided link and place it in the ./data/metamath directory.

DatasetUsageSizeLanguagesPath
MetaMathQATraining395,000En./data/metamath
GSM8KInstructTraining73,559En, Bn, Th, Sw, Ja, Zh, De, Fr, Ru, Es./data/gsm8kinstruct
mGSMEvaluation2,500En, Bn, Th, Sw, Ja, Zh, De, Fr, Ru, Es./evaluate/scripts/data/mgsm
mSVAMPEvaluation10,000En, Bn, Th, Sw, Ja, Zh, De, Fr, Ru, Es./evaluate/scripts/data/msvamp

🧩 Installation

To install this repository, follow these steps:

git clone [email protected]:NJUNLP/QAlign.git
cd QAlign
pip install --editable ./

For detailed information about the conda environment, refer to the environment.yaml file.

πŸ› οΈ Training

We develope our training pipeline based on the stanford_alpaca repository.

To perform question alignment and response alignment on pre-trained LLMs, use the following command. Please note that you must replace $PROJECT_PATH with the appropriate paths in finetune.sh or finetune_dp.sh to ensure it is executable. When fine-tuning the 13B model, we utilize DeepSpeed to save memory. You can find our deepspeed configuration in the ./config/ds.json file.

  • finetuning LLaMA2-7B
bash ./training_scripts/finetune_llama2_7B.sh
  • finetuning LLaMA2-13B
bash ./training_scripts/finetune_llama2_13B.sh

πŸ“ Evaluation

We use the evaluation code provided by Chen et al., which meansures answer accuracy by comparing the last numerical number that appears in the LLM-generated response with the gold answer.

To evaluate the model on mGSM and mSVAMP dataset, use the following command. Please note that you must replace $PROJECT_PATH and $MODEL_PATH with the appropriate paths in the script to ensure it is executable.

  • evaluating with mGSM
cd evaluate/scripts

bash evaluate_mgsm.sh
  • evaluating with mSVAMP
cd evaluate/scripts

bash evaluate_msvamp.sh

🌲 Citation

If you find this repository helpful, feel free to cite our paper:

@misc{zhu2024question,
      title={Question Translation Training for Better Multilingual Reasoning}, 
      author={Wenhao Zhu and Shujian Huang and Fei Yuan and Shuaijie She and Jiajun Chen and Alexandra Birch},
      year={2024},
      eprint={2401.07817},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Significant stargazers

Qiushi

212 followers Β· starred Jan 2024