Qwen2.5 Math 1.5 B Instruct
QwenIntroduction
In August 2024, the Qwen team released the Qwen2-Math series, a family of large language models (LLMs) designed for mathematical problem-solving. A month later, they released the upgraded and open-sourced Qwen2.5-Math series. This series includes base models (Qwen2.5-Math-1.5B/7B/72B), instruction-tuned models, and a mathematical reward model. These models utilize both Chain-of-Thought (CoT) and Tool-integrated Reasoning (TIR) to solve math problems in English and Chinese, showing significant performance improvements over the previous series.
Architecture
Qwen2.5-Math models support both CoT and TIR for enhanced computational accuracy and symbolic reasoning. CoT enhances reasoning capabilities but struggles with computational precision, while TIR addresses these challenges by improving proficiency in precise computation and algorithmic tasks. The Qwen2.5-Math-1.5B/7B/72B-Instruct models perform notably on the MATH benchmark using TIR.
Training
The models are tuned to solve mathematical problems using enhanced reasoning techniques. They leverage the transformers library (version 4.37.0 or later), which includes Qwen2 codes. The models have been trained to perform well on both English and Chinese mathematics benchmarks using CoT and TIR.
Guide: Running Locally
To run the Qwen2.5-Math-1.5B-Instruct model locally, follow these steps:
-
Install Dependencies: Ensure
transformers
version 4.37.0 or later is installed.pip install transformers>=4.37.0
-
Setup Model: Use the following code snippet to load and run the model:
from transformers import AutoModelForCausalLM, AutoTokenizer model_name = "Qwen/Qwen2.5-Math-1.5B-Instruct" device = "cuda" # Set to 'cpu' if GPU is not available model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto" ) tokenizer = AutoTokenizer.from_pretrained(model_name) prompt = "Find the value of $x$ that satisfies the equation $4x+5 = 6x+7$." messages = [ {"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{}."}, {"role": "user", "content": prompt} ] text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True ) model_inputs = tokenizer([text], return_tensors="pt").to(device) generated_ids = model.generate( **model_inputs, max_new_tokens=512 ) response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
-
Cloud GPUs: Consider using cloud GPU services like AWS, GCP, or Azure for optimal performance, especially for larger models.
License
The Qwen2.5-Math series is released under the Apache 2.0 License. For more details, refer to the license file.