File size: 7,484 Bytes
121d948
9357a15
 
 
 
121d948
9357a15
 
 
 
 
 
 
 
 
65dd304
 
3d6bbbe
9357a15
3d6bbbe
9357a15
f678829
121d948
f678829
9357a15
73deb91
f678829
121d948
f678829
 
 
 
 
 
 
 
 
121d948
482e7ca
4cff9fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0041cb2
4cff9fc
0041cb2
4cff9fc
0041cb2
4cff9fc
0041cb2
4cff9fc
0041cb2
4cff9fc
 
 
0041cb2
4cff9fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a653df
 
 
 
 
 
 
 
 
 
 
 
 
4cff9fc
0041cb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f79c366
 
 
 
 
 
121d948
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65dd304
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
---
language:
- en
license: apache-2.0
pipeline_tag: text-generation
tags:
- mathematics
- reasoning
- education
- adaption-labs
- autoscientist
- llama4
- lora
- instruction-tuning
- sft
datasets:
- Charley890/adaption-adaptive-math-2
---

#  Overview

#  Adaptive Math 2

> A mathematics-specialized instruction dataset designed to improve reasoning, structured problem solving, and educational AI assistants through supervised fine-tuning with Adaptation Labs AutoScientist.


## Research Snapshot

| Property | Value |
|----------|-------|
| Domain | Mathematics |
| Dataset Type | Instruction Tuning |
| Framework | Adaptation Labs AutoScientist |
| Base Model | Llama-4 Scout 17B |
| Fine-tuning | LoRA (SFT) |
| Grade | A |
| Quality Score | 9.5 / 10 |

##  Dataset : https://huggingface.co/datasets/Charley890/adaption-adaptive-math-2

Adaptive Math 2 focuses on educational mathematical reasoning rather than simple answer prediction.

### Covers

- Algebra
- Geometry
- Arithmetic
- Number Theory
- Statistics
- Word Problems
- Mathematical Reasoning
- Multi-step Solutions

### Characteristics

 Structured instruction format

 Educational explanations

 Curriculum-oriented questions

 Reasoning-aware responses

 Clean supervised fine-tuning format

##  Example Dataset Samples

### Example 

**Instruction**

```
Solve:
4x - 9 = 19
```

**Expected Response**

```
4x = 28

x = 7
```

---
##  Educational Impact

Adaptive Math 2 is intended for:

- AI tutors
- Educational assistants
- Mathematical reasoning
- Homework support
- Classroom demonstrations
- STEM education
- Benchmark evaluation

The dataset emphasizes transparent reasoning instead of answer memorization.

## Mathematical Training Specification

model:
  base_model: "meta-llama/Llama-4-Scout-17B-16E-Instruct"
  approximate_model_size: "109B parameters"
  training_method: "Supervised Fine-Tuning (SFT)"
  adaptation_method: "LoRA"
  data_format: "Chat"

mathematical_formulation:

  objective:
    description: "The adapted model minimizes the supervised language-modeling loss over the Adaptive Math 2 dataset."
    equation: |
      θ* = argmin_θ L(θ)

  language_model_loss:
    equation: |
      L(θ) = -Σᵢ log Pθ(yᵢ | xᵢ)

  lora:
    description: "Instead of updating the full model weights, LoRA learns a low-rank update."
    equation: |
      W' = W + ΔW
      ΔW = (α/r)BA

    parameters:
      rank_r: 16
      alpha: 32
      dropout: 0
      scaling_factor: |
        α/r = 32/16 = 2

    effective_update:
      equation: |
        ΔW = 2BA

  optimization:
    learning_rate: 0.00005
    weight_decay: 0
    max_gradient_norm: 2
    optimizer_constraint: |
      ||g||₂ ≤ 2

  training_schedule:
    epochs: 5
    evaluations: 5
    evaluation_frequency: |
      5 evaluations / 5 epochs = 1 evaluation per epoch

    scheduler:
      type: "Linear"
      num_cycles: 0.5
      warmup_ratio: 0.03

    warmup:
      equation: |
        T_warmup = 0.03T

  batch:
    batch_size: "max"

  target_modules:
    count: 10
    modules:
      - "k_proj"
      - "o_proj"
      - "q_proj"
      - "v_proj"
      - "shared_expert.gate"
      - "shared_expert.up_proj"
      - "shared_expert.down_proj"
      - "feed_forward.gate_proj"
      - "feed_forward.up_proj"
      - "feed_forward.down_proj"

  training_objective:
    equation: |
      θ_LoRA* = argmin_{A,B} L(W + (α/r)BA)

  interpretation:
    rank: "r = 16 controls the low-rank adaptation capacity."
    scaling: "α/r = 2 controls the magnitude of the LoRA update."
    regularization: "LoRA dropout = 0 and weight decay = 0."
    stability: "Gradient norm is clipped at 2."
    schedule: "Learning rate follows a linear schedule after a 3% warmup."

## Training Interpretation

benchmark:
  adaptation_strategy: "Parameter-efficient fine-tuning"
  objective: "Improve mathematical reasoning while preserving the pretrained model."
  full_parameter_update: false
  low_rank_update: true

  key_result:
    statement: |
      Adaptive Math 2 applies a low-rank parameter update rather than
      retraining the complete 109B-parameter model.

  mathematical_summary: |
    W_adapted = W_base + 2BA

  meaning:
    - "W_base represents the pretrained model."
    - "A and B are learned low-rank matrices."
    - "r = 16 defines the adaptation rank."
    - "α = 32 gives a scaling factor of 2."
    - "Only the selected target modules receive LoRA updates."

## Reproducibility

configuration:
  training_method: "SFT"
  training_type: "LoRA"
  epochs: 5
  learning_rate: 0.00005
  warmup_ratio: 0.03
  weight_decay: 0
  max_grad_norm: 2
  lora_rank: 16
  lora_alpha: 32
  lora_dropout: 0
  scheduler: "linear"
  scheduler_cycles: 0.5
  evaluations: 5
  batch_size: "max"

credit:
  adaptive_data: "Adaptive Data by Adaption Labs"
  training_evaluation: "AutoScientist"




Adaptive Math 2 was developed using the **Adaption Lab AutoScientist** pipe


## 📊 Model Performance

![Adaptive Math 2 Performance](adaptive_math_2_performance.png)

```json
{
  "job_id": "8db3bddd-326c-44ba-8440-2456d10d33f2",
  "training_experiment_id": "78a0fd31-7d13-40cf-bc55-fb2d2bf9e92c",
  "original_model_name": "meta-llama/Llama-4-Scout-17B-16E-Instruct",
  "trained_model_name": "adaption_adaptive_math_2",
  "training_method": "sft",
  "training_type": "lora",
  "data_format": "chat",
  "hyperparams": {
    "lora": "true",
    "lora_r": 16,
    "n_evals": 5,
    "n_epochs": 5,
    "batch_size": "max",
    "lora_alpha": 32,
    "lora_dropout": 0,
    "min_lr_ratio": 0.1,
    "warmup_ratio": 0.03,
    "weight_decay": 0,
    "learning_rate": 0.00005,
    "max_grad_norm": 2,
    "base_model_size": "109B",
    "train_on_inputs": "false",
    "training_method": "sft",
    "lr_scheduler_type": "linear",
    "scheduler_num_cycles": 0.5,
    "lora_trainable_modules": "k_proj,o_proj,q_proj,v_proj,shared_expert.gate_proj,shared_expert.up_proj,shared_expert.down_proj,feed_forward.gate_proj,feed_forward.up_proj,feed_forward.down_proj"
  }
}
```

## Training Data

The model was trained on 1,306 rows of adapted data with the following domain distribution: math (77%), code (8%), science (8%), academic-education (8%).

## Model Evaluation

The model was evaluated on an in-distribution held-out test set as well as a broader domain-specific test set to measure generalization.


![Win rates](win-rates.png)

| Domain | Win rate vs. base model |
| --- | --- |
| math | 66% |

## How to use

```bash
pip install torch transformers peft
```

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

BASE = "meta-llama/Llama-4-Scout-17B-16E-Instruct"
ADAPTER = "<this-repo-id>"

device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float32 if device == "cpu" else torch.bfloat16

base = AutoModelForCausalLM.from_pretrained(BASE, dtype=dtype).to(device)
model = PeftModel.from_pretrained(base, ADAPTER)
# Optional: merge the LoRA weights into the base for faster inference
model = model.merge_and_unload()
model.eval()

tokenizer = AutoTokenizer.from_pretrained(BASE)
messages = [{"role": "user", "content": "Hello!"}]
text = tokenizer.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(device)

with torch.inference_mode():
    out = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```