Instructions to use weihao1/MuMath-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use weihao1/MuMath-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="weihao1/MuMath-7B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("weihao1/MuMath-7B") model = AutoModelForCausalLM.from_pretrained("weihao1/MuMath-7B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use weihao1/MuMath-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "weihao1/MuMath-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "weihao1/MuMath-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/weihao1/MuMath-7B
- SGLang
How to use weihao1/MuMath-7B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "weihao1/MuMath-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "weihao1/MuMath-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "weihao1/MuMath-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "weihao1/MuMath-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use weihao1/MuMath-7B with Docker Model Runner:
docker model run hf.co/weihao1/MuMath-7B
| # MuMath: Multi-perspective Data Augmentation for Mathematical Reasoning in Large Language Models | |
| ## Introduction | |
| We have amalgamated and further refined these strengths while broadening the scope of augmentation methods to construct a multi-perspective augmentation dataset for mathematics—termed [MuMath (μ-Math) Dataset](https://huggingface.co/datasets/weihao1/MuMath). Subsequently, we finetune LLaMA-2 on the MuMath dataset to derive the MuMath model. | |
| | Model | Size | GSM8k | MATH | | |
| |---|---|---|---| | |
| | WizardMath-7B | 7B | 54.9 | 10.7 | | |
| | MetaMath-7B | 7B | 66.3 | 19.7 | | |
| | MuggleMath-7B | 7B | 68.4 | - | | |
| | [MuMath-7B](https://huggingface.co/weihao1/MuMath-7B) | 7B | **79.1** | **30.0** | | |
| || | |
| | WizardMath-13B | 13B | 63.9 | 14 | | |
| | MetaMath-13B | 13B | 72.3 | 22.4 | | |
| | MuggleMath-13B | 13B | 74 | - |s | |
| | [MuMath-13B](https://huggingface.co/weihao1/MuMath-13B) | 13B | **83.6** | **33.3** | | |
| || | |
| | WizardMath-70B | 70B | 81.6 | 22.7 | | |
| | MetaMath-70B | 70B | 82.3 | 26.6 | | |
| | MuggleMath-70B | 70B | 82.3 | - | | |
| | [MuMath-70B](https://huggingface.co/weihao1/MuMath-70B) | 70B | **88.5** | **41.2** | | |
| > The best results are bolded. | |
| ## Augmentation Methods | |
| <p align="center"> | |
| <img src="./images/MuMath.png" width="800"> | |
| <br> | |
| <em>Overview of the augmentation methods our MuMath employs, which can be divided into four categories: (1) Data Reformulation includes solution reorganization and question rephrasing; (2) Backward Creation includes Backward-Forward Transformation (BF-Trans) and FOBAR; (3) Question Alteration includes expression replacement and difficulty enhancement; (4) Nested Multi-task construction includes data of the auxiliary tasks, i.e., Problem Outline and Solution Plan.</em> | |
| </p> | |
| ### Setup | |
| We recommend using [Conda](https://docs.conda.io/projects/miniconda) to manage your environment. We use [vLLM](https://github.com/vllm-project/vllm) to accelerate inference. Run the following commands to setup your environment: | |
| ```sh | |
| conda create -n mumath python=3.10 | |
| conda activate mumath | |
| cd MuMath-src | |
| pip install -r requirements.txt | |
| ``` | |
| ## Training | |
| We also open [MuMath Dataset](https://huggingface.co/datasets/weihao1/MuMath) for the training stage. | |
| To train a model, after specifying `MODEL_PATH`, `SAVE_PATH`, `DATA_PATH`, the conda environment and so on, run the following command: | |
| ```sh | |
| # 7B or 13B | |
| bash train_7b.sh | |
| # 34B | |
| bash train_13b_70b.sh | |
| ``` | |
| ### Inference and Evaluation | |
| We provide scripts for inference and evaluation, which are called in `train_7b.sh` and `train_13b_70b.sh` as mentioned above. | |
| ```sh | |
| python eval_gsm8k.py --model $SAVE_PATH --data_file ./data/test/GSM8K_test.jsonl | |
| python eval_math.py --model $SAVE_PATH --data_path ./data/test/MATH_test.jsonl | |
| ``` | |
| ## Citation | |
| Please cite the paper if you refer to our model, code, data or paper from MuMath. | |
| ``` | |
| @inproceedings{you-etal-2024-mumath, | |
| title = "{M}u{M}ath: Multi-perspective Data Augmentation for Mathematical Reasoning in Large Language Models", | |
| author = "You, Weihao and Yin, Shuo and Zhao, Xudong and Ji, Zhilong and Zhong, Guoqiang and Bai, Jinfeng", | |
| booktitle = "Findings of the Association for Computational Linguistics: NAACL 2024", | |
| month = jun, | |
| year = "2024", | |
| pages = "2932--2958", | |
| } | |
| ``` | |
| ## Credits | |
| This project has adopted the [MeteMath](https://github.com/meta-math/MetaMath) and [MuggleMath](https://github.com/OFA-Sys/gsm8k-ScRel). | |