CoinMath: Harnessing the Power of Coding Instruction for Math LLM

Chengwei Wei, Bin Wang, Jung-jae Kim, Guimei Liu, Nancy F. Chen


Abstract
Large Language Models (LLMs) have shown strong performance in solving mathematical problems, with code-based solutions proving particularly effective. However, the best practice to leverage coding instruction data to enhance mathematical reasoning remains underexplored. This study investigates three key questions: (1) How do different coding styles of mathematical code-based rationales impact LLMs’ learning performance? (2) Can general-domain coding instructions improve performance? (3) How does integrating textual rationales with code-based ones during training enhance mathematical reasoning abilities? Our findings reveal that code-based rationales with concise comments, descriptive naming, and hardcoded solutions are beneficial, while improvements from general-domain coding instructions and textual rationales are relatively minor. Based on these insights, we propose CoinMath, a learning strategy designed to enhance mathematical reasoning by diversifying the coding styles of code-based rationales. CoinMath generates a variety of code-based rationales incorporating concise comments, descriptive naming conventions, and hardcoded solutions. Experimental results demonstrate that CoinMath significantly outperforms its baseline model, MAmmoTH, one of the SOTA math LLMs.
Anthology ID:
2025.findings-acl.44
Volume:
Findings of the Association for Computational Linguistics: ACL 2025
Month:
July
Year:
2025
Address:
Vienna, Austria
Editors:
Wanxiang Che, Joyce Nabende, Ekaterina Shutova, Mohammad Taher Pilehvar
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
786–797
Language:
URL:
https://preview.aclanthology.org/mtsummit-25-ingestion/2025.findings-acl.44/
DOI:
10.18653/v1/2025.findings-acl.44
Bibkey:
Cite (ACL):
Chengwei Wei, Bin Wang, Jung-jae Kim, Guimei Liu, and Nancy F. Chen. 2025. CoinMath: Harnessing the Power of Coding Instruction for Math LLM. In Findings of the Association for Computational Linguistics: ACL 2025, pages 786–797, Vienna, Austria. Association for Computational Linguistics.
Cite (Informal):
CoinMath: Harnessing the Power of Coding Instruction for Math LLM (Wei et al., Findings 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/mtsummit-25-ingestion/2025.findings-acl.44.pdf