Updated README ๐
Browse files
README.md
CHANGED
|
@@ -5,4 +5,62 @@ datasets:
|
|
| 5 |
- openai/gsm8k
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
- openai/gsm8k
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# NanoMath: A 136M Parameter Math-Reasoning Language Model
|
| 11 |
+
|
| 12 |
+
## ๐ Model Overview
|
| 13 |
+
|
| 14 |
+
NanoMath is a custom-built, GPT-style Large Language Model explicitly designed to solve mathematical problems using Chain-of-Thought (CoT) reasoning. Built entirely from scratch in PyTorch, the primary goal of this model is to demonstrate an end-to-end language modeling pipeline, helping to understand transformer architectures, training optimizations, and data processing bottlenecks.
|
| 15 |
+
|
| 16 |
+
## ๐ ๏ธ Model Details
|
| 17 |
+
|
| 18 |
+
* **Architecture:** Decoder-only Transformer (GPT-style) built from scratch.
|
| 19 |
+
* **Parameters:** 136 Million.
|
| 20 |
+
* **Training Compute:** Trained for 12 hours on a single NVIDIA T4 GPU via Kaggle.
|
| 21 |
+
* **Tokenizer:** Custom Byte-Pair Encoding (BPE) tokenizer trained using `sentencepiece` to explicitly recognize mathematical operators and digits efficiently.
|
| 22 |
+
|
| 23 |
+
## ๐ Training Data
|
| 24 |
+
|
| 25 |
+
The model was trained on approximately 1 Billion tokens. The dataset is a combination of high-quality math datasets and procedural generations:
|
| 26 |
+
|
| 27 |
+
* **Synthetic Basic Math:** Hundreds of thousands of synthetic arithmetic problems generated via a custom Python script.
|
| 28 |
+
* **GSM8K:** Gold-standard grade school math word problems.
|
| 29 |
+
* **NuminaMath:** Large-scale math reasoning problems.
|
| 30 |
+
|
| 31 |
+
To teach the model step-by-step reasoning, the data enforces a strict `<|thinking|>` and `<|answer|>` formatting structure.
|
| 32 |
+
|
| 33 |
+
## ๐ง Performance and Capabilities
|
| 34 |
+
|
| 35 |
+
NanoMath was trained to "think before it speaks". It successfully generates intermediate reasoning steps and performs well on basic arithmetic tasks.
|
| 36 |
+
|
| 37 |
+
**Successes:**
|
| 38 |
+
|
| 39 |
+
* The model successfully executes multi-step algorithmic logic like partial products.
|
| 40 |
+
* It correctly utilizes long division from left to right.
|
| 41 |
+
|
| 42 |
+
## โ ๏ธ Limitations
|
| 43 |
+
|
| 44 |
+
Given its small scale (136M parameters) and heavily constrained training time (12 hours), the model exhibits standard LLM hallucinations on complex operations.
|
| 45 |
+
|
| 46 |
+
* **Multi-Step Borrowing:** It sometimes struggles to carry values perfectly across complex mathematical borrowing steps.
|
| 47 |
+
* **Logic Routing:** It can lose track of logical routing in word problems, leading to hallucinated results.
|
| 48 |
+
|
| 49 |
+
## ๐ป How to Use
|
| 50 |
+
|
| 51 |
+
Because this is a custom model architecture built from scratch, you cannot use the standard HuggingFace `transformers` library out-of-the-box. Instead, download the weights and run inference using the codebase provided in the linked GitHub repository.
|
| 52 |
+
|
| 53 |
+
1. Download the `model_weights.pth` and `token.model` files from this repository.
|
| 54 |
+
2. Clone the [NanoMath GitHub repository](https://github.com/agmada-asa/NanoMath) and install the dependencies:
|
| 55 |
+
```bash
|
| 56 |
+
pip install -r requirements.txt
|
| 57 |
+
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
3. Place the downloaded `.pth` and `.model` files into the `build/` directory of the cloned repository.
|
| 62 |
+
4. Run the interactive chat CLI:
|
| 63 |
+
```bash
|
| 64 |
+
python chat.py
|
| 65 |
+
|
| 66 |
+
```
|