File size: 2,343 Bytes
e4a469a bebba81 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
---
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 |