Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
| 4 |
+
# Arithmetic Reasoner
|
| 5 |
+
|
| 6 |
+
A 1-layer TrueACT model trained to generate chain-of-thought reasoning for arithmetic expressions with `+`, `-`, `*`, and parentheses.
|
| 7 |
+
|
| 8 |
+
Trained from scratch on purely random binary-tree expressions. Every non-root subexpression is parenthesized, forcing the model to learn step-by-step reduction of nested arithmetic.
|
| 9 |
+
|
| 10 |
+
## Performance
|
| 11 |
+
|
| 12 |
+

|
| 13 |
+
|
| 14 |
+
| Test | Accuracy |
|
| 15 |
+
|------|----------|
|
| 16 |
+
| Fixed 12-case benchmark | 12/12 (100%) |
|
| 17 |
+
| Random 500 expressions | 91.6% |
|
| 18 |
+
|
| 19 |
+
Errors are exclusively multi-digit arithmetic mistakes (e.g., `42×88=3524`). The model's structural reasoning (parenthesis resolution, operator precedence, chain-of-thought decomposition) is near-perfect.
|
| 20 |
+
|
| 21 |
+
## Files
|
| 22 |
+
|
| 23 |
+
| File | Description |
|
| 24 |
+
|------|-------------|
|
| 25 |
+
| `model.pt` | TorchScript-traced model for inference (no Python source needed) |
|
| 26 |
+
| `checkpoint.pt` | Original PyTorch checkpoint (requires the TrueACT architecture code to load) |
|
| 27 |
+
| `infer.py` | Standalone inference script |
|
| 28 |
+
| `plot.py` | Generate the training curves figure from the training log |
|
| 29 |
+
|
| 30 |
+
## Usage
|
| 31 |
+
|
| 32 |
+
```bash
|
| 33 |
+
# Single prompt
|
| 34 |
+
python infer.py model.pt '((5*5)+(10*2))='
|
| 35 |
+
|
| 36 |
+
# Interactive mode
|
| 37 |
+
python infer.py model.pt
|
| 38 |
+
Prompt > (1+2)*3=
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
The model expects a prompt ending with `=` and generates the chain-of-thought steps:
|
| 42 |
+
|
| 43 |
+
```
|
| 44 |
+
Input: ((5*5)+(10*2))=
|
| 45 |
+
Output: ((5*5)+(10*2))=(25+(10*2))=(25+20)=45
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Requirements
|
| 49 |
+
|
| 50 |
+
- Python 3.10+
|
| 51 |
+
- PyTorch 2.0+
|
| 52 |
+
|
| 53 |
+
No other dependencies.
|