OccamLLM: Fast and Exact Language Model Arithmetic in a Single Step
Abstract
Despite significant advancements in text generation and reasoning, Large Language Models (LLMs) still face challenges in accurately performing complex arithmetic operations. Language model systems often enable LLMs to generate code for arithmetic operations to achieve accurate calculations. However, this approach compromises speed and security, and fine-tuning risks the language model losing prior capabilities. We propose a framework that enables exact arithmetic in *a single autoregressive step*, providing faster, more secure, and more interpretable LLM systems with arithmetic capabilities. We use the hidden states of a LLM to control a symbolic architecture that performs arithmetic. Our implementation using Llama 3 with OccamNet as a symbolic model (OccamLlama) achieves 100\% accuracy on single arithmetic operations ($+,-,\times,\div,\sin{},\cos{},\log{},\exp{},\sqrt{}$), outperforming GPT 4o with and without a code interpreter. Furthermore, OccamLlama outperforms GPT 4o with and without a code interpreter on average across a range of mathematical problem solving benchmarks, demonstrating that OccamLLMs can excel in arithmetic tasks, even surpassing much larger models. Code is available at https://github.com/druidowm/OccamLLM.
Cite
Text
Dugan et al. "OccamLLM: Fast and Exact Language Model Arithmetic in a Single Step." Neural Information Processing Systems, 2024. doi:10.52202/079017-1125Markdown
[Dugan et al. "OccamLLM: Fast and Exact Language Model Arithmetic in a Single Step." Neural Information Processing Systems, 2024.](https://mlanthology.org/neurips/2024/dugan2024neurips-occamllm/) doi:10.52202/079017-1125BibTeX
@inproceedings{dugan2024neurips-occamllm,
title = {{OccamLLM: Fast and Exact Language Model Arithmetic in a Single Step}},
author = {Dugan, Owen and Jiménez-Benetó, Donato M. and Loh, Charlotte and Chen, Zhuo and Dangovski, Rumen and Soljačić, Marin},
booktitle = {Neural Information Processing Systems},
year = {2024},
doi = {10.52202/079017-1125},
url = {https://mlanthology.org/neurips/2024/dugan2024neurips-occamllm/}
}