模型介绍
GPT Can Solve Mathematical Problems Without a Calculator
Official Pytorch Implementation
Previous studies have typically assumed that large language models are unable to accurately perform arithmetic operations, particularly multiplication of >8 digits, and operations involving decimals and fractions, without the use of calculator tools. This paper aims to challenge this misconception. With sufficient training data, a 2 billion-parameter language model can accurately perform multi-digit arithmetic operations with almost 100% accuracy without data leakage, significantly surpassing GPT-4 (whose multi-digit multiplication accuracy is only 4.3%). We also demonstrate that our MathGLM, finetuned from GLM-10B on a dataset with additional multi-step arithmetic operations and math problems described in text, achieves similar performance to GPT-4 on a 5,000-samples Chinese math problem
test set.
先前的研究通常假设大型语言模型在不使用计算器工具的情况下无法准确执行算术运算,特别是 >8 位数字的乘法以及涉及小数和分数的运算。 本文旨在挑战这种误解。 在足够的训练数据下,20亿参数的语言模型可以准确地进行多位算术运算,几乎100%的准确率且不会泄漏数据,大幅超越GPT-4(其多位乘法准确率仅为4.3%)。 我们还证明,我们的 MathGLM 在数据集上对 GLM-10B 进行了微调,并添加了额外的多步算术运算和文本中描述的数学问题,在 5,000 个样本的中国数学问题测试集上实现了与 GPT-4 类似的性能。
If you want to find the detailed introduction, Read our paper: GPT Can Solve Mathematical Problems Without a Calculator.
依赖
pip install SwissArmyTransformer==0.2.*
推理代码
method 1: use model
from modelscope import snapshot_download, Model, pipeline, Tasks
model_dir = snapshot_download('ZhipuAI/MathGLM', revision='v1.0.0')
model = Model.from_pretrained(model_dir)
query = '鸡和兔在一个笼子里,共有35个头,94只脚,那么鸡有多少只?'
response = model(query)
print(response)
"""Out
x=35-((94-35*2)/(4-2))=35-((94-70)/(4-2))=35-(24/(4-2))=35-(24/2)=35-12=23
"""
method 2: use pipeline
from modelscope import snapshot_download, Model, pipeline, Tasks
model_dir = snapshot_download('ZhipuAI/MathGLM', revision='v1.0.0')
pipe = pipeline(task=Tasks.text_generation, model=model_dir)
query = '10*9*8=?'
response = pipe(query)
print(response)
"""Out
x=10*9*8=90*8=720
"""
Citation
@article{yang2023gpt,
title={GPT Can Solve Mathematical Problems Without a Calculator},
author={Yang, Zhen and Ding, Ming and Lv, Qingsong and Jiang, Zhihuan and He, Zehai and Guo, Yuyi and Bai, Jinfeng and Tang, Jie},
journal={arXiv preprint arXiv:2309.03241},
year={2023}
}
评论