--- license: apache-2.0 language: - en pipeline_tag: text-generation tags: - math - arithmetic - pytorch - decoder-only - from-scratch - small-language-model --- # MathGPT A 10.7M-parameter decoder-only Transformer trained from scratch for arithmetic reasoning. ## Overview MathGPT explores how carefully designed numerical representations, structured scratchpads, and randomized training data can help small language models perform arithmetic. - **Parameters:** 10.7M - **Architecture:** Decoder-only Transformer - **Framework:** PyTorch - **Training hardware:** Google Colab NVIDIA T4 - **Tokenizer:** Character-level - **Training:** From scratch ## Benchmark results MathGPT was evaluated against published GPT-3 few-shot results using samples of 300 problems per task from OpenAI's arithmetic benchmark files. | Task | MathGPT | GPT-3 | |---|---:|---:| | 2-digit addition | 100.0% | 100.0% | | 3-digit addition | 99.3% | 80.4% | | 4-digit addition | 95.3% | 25.5% | | 5-digit addition | 80.0% | 9.3% | | 2-digit subtraction | 86.0% | 98.9% | | 3-digit subtraction | 80.7% | 94.2% | | 4-digit subtraction | 74.0% | 26.8% | | 5-digit subtraction | 29.3% | 9.9% | | 2-digit multiplication | 98.3% | 29.2% | | 1-digit composite | 6.3% | 21.3% | MathGPT achieved higher accuracy on 6 of the 10 tasks. These results are task-specific and should not be interpreted as general mathematical superiority over GPT-3. ## Methodology 1. Each numerical digit is represented by an individual token. 2. Answers are generated least-significant-digit first. 3. Structured scratchpads teach intermediate arithmetic operations. 4. Randomized problems provide varied training examples. Approximately 14 million training examples were seen throughout training. ## Limitations - Weak generalization to unfamiliar natural-language word problems. - Lower accuracy on complex bracket-based arithmetic. - Performance decreases as arithmetic complexity increases. - Evaluation uses a 300-question sample per task. ## Intended use Research and experimentation involving small language models, arithmetic reasoning, numerical tokenization, and structured generation. ## Training and evaluation Source code, training notebooks, and evaluation scripts: [GitHub repository](https://github.com/Shahir1134/MATH_GPT) ## License Apache-2.0