File size: 4,460 Bytes
5af2711
 
 
 
 
9b63543
 
 
 
 
 
 
 
 
 
 
 
5af2711
 
 
 
 
 
 
 
 
 
 
9b63543
 
 
 
 
 
 
 
 
 
 
 
c0a190f
9b63543
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5af2711
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b63543
5af2711
 
 
 
 
 
 
 
 
9b63543
5af2711
 
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
---
base_model: meta-llama/Llama-3.2-3B-Instruct
library_name: peft
license: other
tags:
- lora
- peft
- math
- reasoning
- adaption
- word-problems
- llama
- sft
datasets:
- Minutor/adaption-math-word-problem-sub-2
- Minutor/20k_math_dataset
pipeline_tag: text-generation
---

# adaption_math_word_problem_sub_2

## Model Training

A LORA adapter for `meta-llama/Llama-3.2-3B-Instruct`. This model was trained with SFT using [Adaption](https://adaptionlabs.ai)'s AutoScientist on the math_word_problem_sub_2 dataset.


![Training metrics](training-metrics.png)

### Model Details

- **Base model**: `meta-llama/Llama-3.2-3B-Instruct`
- **Training method**: SFT + LoRA
- **LoRA rank**: 16 | **alpha**: 32
- **Epochs**: 3
- **Learning rate**: 1e-5 (cosine schedule)
- **Trainable modules**: all-linear
- **Data format**: chat

### Training Data
The model was trained on 19,573 rows of adapted data with the following domain distribution: math (99%), language (0%), science (0%), personal-finance (0%), fitness-sports (0%), animal-nature (0%), agriculture (0%), how-to (0%), sports (0%), travel (0%), data-analysis-visualization (0%).

Trained on the adapted dataset:  
→ [Minutor/adaption-math-word-problem-sub-2](https://huggingface.co/datasets/Minutor/adaption-math-word-problem-sub-2)

Which itself was derived from the cleaned seed:  
→ [Minutor/20k_math_dataset](https://huggingface.co/datasets/Minutor/20k_math_dataset)  
(GSM8K + NuminaMath-1.5 + OpenMathInstruct-1)

### Evaluation Results

Win rates are computed by Adaption using **Gemini 3.1 Pro** as the judge.
![Win rates](win-rates.png)
| Evaluation | Sample size | Base | Adapted | Change |
|------------|-------------|------|---------|--------|
| Win-rate on training distribution | 200 held-out datapoints | 42 | **58** | **+16** |
| Math Win-rate (Adaption held-out) | 100 unseen datapoints across Math tasks | 51 | 50 | –1 |

The model shows a clear +16 point improvement on its training distribution while remaining essentially neutral on Adaption’s broader Math evaluation set.

### How to use

notebook snippet: [collab shared notebook](https://colab.research.google.com/drive/1E5yBG_7vgviVKPE7qJpbTwJRKLs6YbV_?usp=sharing)
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

BASE = "meta-llama/Llama-3.2-3B-Instruct"
ADAPTER = "Minutor/adaption_math_word_problem_sub_2"

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

base = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=dtype, device_map="auto")
model = PeftModel.from_pretrained(base, ADAPTER)
# Optional: merge for faster inference
# model = model.merge_and_unload()

tokenizer = AutoTokenizer.from_pretrained(BASE)

messages = [
    {"role": "user", "content": "A store sells apples for $2 each and oranges for $3 each. If a customer buys 4 apples and 3 oranges, how much do they pay in total?"}
]

text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)

with torch.inference_mode():
    outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)

print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
### AutoScientist Config

```json
{
  "job_id": "dfdd2990-1ef7-41e4-829d-2924d668ab65",
  "training_experiment_id": "19aa2607-d5ad-43b7-90b2-5e7d3745b627",
  "original_model_name": "meta-llama/Llama-3.2-3B-Instruct",
  "trained_model_name": "adaption_math_word_problem_sub_2",
  "training_method": "sft",
  "training_type": "lora",
  "data_format": "chat",
  "hyperparams": {
    "lora": "true",
    "lora_r": 16,
    "n_evals": 5,
    "n_epochs": 3,
    "batch_size": "max",
    "lora_alpha": 32,
    "lora_dropout": 0,
    "min_lr_ratio": 0.1,
    "warmup_ratio": 0.1,
    "weight_decay": 0,
    "learning_rate": 0.00001,
    "max_grad_norm": 2,
    "base_model_size": "3B",
    "train_on_inputs": "false",
    "training_method": "sft",
    "lr_scheduler_type": "cosine",
    "scheduler_num_cycles": 0.5,
    "lora_trainable_modules": "all-linear"
  }
}
```

<!-- 
## 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 | 50% | -->