Update README.md
Browse files
README.md
CHANGED
|
@@ -47,6 +47,8 @@ extra_gated_button_content: Submit
|
|
| 47 |
base_model: meta-llama/Llama-3.2-3B-Instruct
|
| 48 |
metrics:
|
| 49 |
- accuracy
|
|
|
|
|
|
|
| 50 |
---
|
| 51 |
# MathLlama 3.2 - Enhanced Mathematical Reasoning Model
|
| 52 |
|
|
@@ -57,21 +59,15 @@ MathLlama 3.2 is a fine-tuned version of Meta's Llama-3.2-3B-Instruct model, spe
|
|
| 57 |
## Key Improvements
|
| 58 |
|
| 59 |
### Mathematical Reasoning Enhancement
|
| 60 |
-
- **
|
| 61 |
- Enhanced capability in complex mathematical reasoning tasks
|
| 62 |
- Improved performance across various mathematical domains including algebra, calculus, and abstract mathematical concepts
|
| 63 |
|
| 64 |
### Training Methodology
|
| 65 |
-
- **Synthetic Dataset**: Utilized
|
| 66 |
- **Chain-of-Thought Training**: Each training example includes detailed step-by-step reasoning processes
|
| 67 |
-
- **Data Quality**: Carefully curated advanced mathematical problems covering:
|
| 68 |
-
- Abstract algebra concepts (groups, rings, fields)
|
| 69 |
-
- Advanced calculus problems
|
| 70 |
-
- Complex mathematical proofs
|
| 71 |
-
- Multi-step mathematical reasoning tasks
|
| 72 |
|
| 73 |
## Model Architecture
|
| 74 |
-
|
| 75 |
- **Base Model**: Meta Llama-3.2-3B-Instruct
|
| 76 |
- **Parameters**: 3 billion parameters
|
| 77 |
- **Context Length**: 128k tokens
|
|
@@ -81,39 +77,32 @@ MathLlama 3.2 is a fine-tuned version of Meta's Llama-3.2-3B-Instruct model, spe
|
|
| 81 |
|
| 82 |
### Basic Usage
|
| 83 |
```python
|
| 84 |
-
import torch
|
| 85 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 86 |
-
|
| 87 |
-
tokenizer = AutoTokenizer.from_pretrained("path/to/MathLlama-3.2")
|
| 88 |
-
model = AutoModelForCausalLM.from_pretrained("path/to/MathLlama-3.2")
|
| 89 |
|
| 90 |
-
#
|
| 91 |
-
|
| 92 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
| 93 |
-
|
| 94 |
-
outputs = model.generate(**inputs, max_length=512, temperature=0.7)
|
| 95 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 96 |
-
print(response)
|
| 97 |
-
```
|
| 98 |
-
|
| 99 |
-
### Advanced Mathematical Reasoning
|
| 100 |
-
```python
|
| 101 |
-
# For complex mathematical problems
|
| 102 |
-
complex_prompt = """
|
| 103 |
-
Solve this advanced algebra problem using step-by-step reasoning:
|
| 104 |
-
|
| 105 |
-
Let G be a group and H be a subgroup of G. If [G:H] = n and for every g in G,
|
| 106 |
-
the order of g divides some fixed integer m, prove that the order of G divides n! * m^n.
|
| 107 |
|
| 108 |
-
|
| 109 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
```
|
| 111 |
|
| 112 |
## Training Details
|
| 113 |
|
| 114 |
### Dataset Creation
|
| 115 |
-
- **
|
| 116 |
-
- **Chain-of-Thought Format**: Each
|
| 117 |
1. Clear problem statement
|
| 118 |
2. Step-by-step reasoning process
|
| 119 |
3. Final answer with justification
|
|
@@ -122,7 +111,7 @@ Show your step-by-step reasoning:
|
|
| 122 |
- **Learning Rate**: Optimized for mathematical reasoning tasks
|
| 123 |
- **Batch Size**: Configured for stable training with mathematical data
|
| 124 |
- **Training Steps**: Sufficient iterations to achieve mathematical reasoning improvements
|
| 125 |
-
- **Hardware**: Trained on
|
| 126 |
|
| 127 |
## Applications
|
| 128 |
|
|
|
|
| 47 |
base_model: meta-llama/Llama-3.2-3B-Instruct
|
| 48 |
metrics:
|
| 49 |
- accuracy
|
| 50 |
+
datasets:
|
| 51 |
+
- HenryShan/Gemini-MMLU-CoT
|
| 52 |
---
|
| 53 |
# MathLlama 3.2 - Enhanced Mathematical Reasoning Model
|
| 54 |
|
|
|
|
| 59 |
## Key Improvements
|
| 60 |
|
| 61 |
### Mathematical Reasoning Enhancement
|
| 62 |
+
- **12% improvement on abstract_algebra in MMLU** compared to the base Llama-3.2-3B-Instruct model
|
| 63 |
- Enhanced capability in complex mathematical reasoning tasks
|
| 64 |
- Improved performance across various mathematical domains including algebra, calculus, and abstract mathematical concepts
|
| 65 |
|
| 66 |
### Training Methodology
|
| 67 |
+
- **Synthetic Dataset**: Utilized the [Gemini-MMLU-CoT](https://huggingface.co/datasets/HenryShan/Gemini-MMLU-CoT) dataset consisting of **7,000 advanced math problems**
|
| 68 |
- **Chain-of-Thought Training**: Each training example includes detailed step-by-step reasoning processes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
## Model Architecture
|
|
|
|
| 71 |
- **Base Model**: Meta Llama-3.2-3B-Instruct
|
| 72 |
- **Parameters**: 3 billion parameters
|
| 73 |
- **Context Length**: 128k tokens
|
|
|
|
| 77 |
|
| 78 |
### Basic Usage
|
| 79 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
# Load model directly
|
| 82 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
tokenizer = AutoTokenizer.from_pretrained("HenryShan/MathLlama3.2")
|
| 85 |
+
model = AutoModelForCausalLM.from_pretrained("HenryShan/MathLlama3.2")
|
| 86 |
+
messages = [
|
| 87 |
+
{"role": "user", "content": "Find the degree for the given field extension Q(sqrt(2), sqrt(3), sqrt(18)) over Q. Answer Choices: A: "0", B: "4", C: "2", D: "6"},
|
| 88 |
+
]
|
| 89 |
+
inputs = tokenizer.apply_chat_template(
|
| 90 |
+
messages,
|
| 91 |
+
add_generation_prompt=True,
|
| 92 |
+
tokenize=True,
|
| 93 |
+
return_dict=True,
|
| 94 |
+
return_tensors="pt",
|
| 95 |
+
).to(model.device)
|
| 96 |
+
|
| 97 |
+
outputs = model.generate(**inputs, max_new_tokens=40)
|
| 98 |
+
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
|
| 99 |
```
|
| 100 |
|
| 101 |
## Training Details
|
| 102 |
|
| 103 |
### Dataset Creation
|
| 104 |
+
- **Synthetic Dataset**: 7,000 carefully designed advanced mathematical problems
|
| 105 |
+
- **Chain-of-Thought Format**: Each row includes:
|
| 106 |
1. Clear problem statement
|
| 107 |
2. Step-by-step reasoning process
|
| 108 |
3. Final answer with justification
|
|
|
|
| 111 |
- **Learning Rate**: Optimized for mathematical reasoning tasks
|
| 112 |
- **Batch Size**: Configured for stable training with mathematical data
|
| 113 |
- **Training Steps**: Sufficient iterations to achieve mathematical reasoning improvements
|
| 114 |
+
- **Hardware**: Trained on an Apple M4 Max Computer using [MLX](https://github.com/ml-explore/mlx)
|
| 115 |
|
| 116 |
## Applications
|
| 117 |
|