Minutor commited on
Commit
9b63543
·
verified ·
1 Parent(s): 5af2711

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -41
README.md CHANGED
@@ -3,10 +3,18 @@ base_model: meta-llama/Llama-3.2-3B-Instruct
3
  library_name: peft
4
  license: other
5
  tags:
6
- - lora
7
- - peft
8
- - adapter
9
- - adaption
 
 
 
 
 
 
 
 
10
  ---
11
 
12
  # adaption_math_word_problem_sub_2
@@ -18,6 +26,69 @@ A LORA adapter for `meta-llama/Llama-3.2-3B-Instruct`. This model was trained wi
18
 
19
  ![Training metrics](training-metrics.png)
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ### AutoScientist Config
22
 
23
  ```json
@@ -52,10 +123,7 @@ A LORA adapter for `meta-llama/Llama-3.2-3B-Instruct`. This model was trained wi
52
  }
53
  ```
54
 
55
- ## Training Data
56
-
57
- 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%).
58
-
59
  ## Model Evaluation
60
 
61
  The model was evaluated on an in-distribution held-out test set as well as a broader domain-specific test set to measure generalization.
@@ -65,38 +133,6 @@ The model was evaluated on an in-distribution held-out test set as well as a bro
65
 
66
  | Domain | Win rate vs. base model |
67
  | --- | --- |
68
- | math | 50% |
69
-
70
- ## How to use
71
-
72
- ```bash
73
- pip install torch transformers peft
74
- ```
75
-
76
- ```python
77
- import torch
78
- from transformers import AutoModelForCausalLM, AutoTokenizer
79
- from peft import PeftModel
80
-
81
- BASE = "meta-llama/Llama-3.2-3B-Instruct"
82
- ADAPTER = "<this-repo-id>"
83
-
84
- device = "cuda" if torch.cuda.is_available() else "cpu"
85
- dtype = torch.float32 if device == "cpu" else torch.bfloat16
86
-
87
- base = AutoModelForCausalLM.from_pretrained(BASE, dtype=dtype).to(device)
88
- model = PeftModel.from_pretrained(base, ADAPTER)
89
- # Optional: merge the LoRA weights into the base for faster inference
90
- model = model.merge_and_unload()
91
- model.eval()
92
 
93
- tokenizer = AutoTokenizer.from_pretrained(BASE)
94
- messages = [{"role": "user", "content": "Hello!"}]
95
- text = tokenizer.apply_chat_template(
96
- messages, tokenize=False, add_generation_prompt=True)
97
- inputs = tokenizer(text, return_tensors="pt").to(device)
98
 
99
- with torch.inference_mode():
100
- out = model.generate(**inputs, max_new_tokens=512)
101
- print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
102
- ```
 
3
  library_name: peft
4
  license: other
5
  tags:
6
+ - lora
7
+ - peft
8
+ - math
9
+ - reasoning
10
+ - adaption
11
+ - word-problems
12
+ - llama
13
+ - sft
14
+ datasets:
15
+ - Minutor/adaption-math-word-problem-sub-2
16
+ - Minutor/20k_math_dataset
17
+ pipeline_tag: text-generation
18
  ---
19
 
20
  # adaption_math_word_problem_sub_2
 
26
 
27
  ![Training metrics](training-metrics.png)
28
 
29
+ ### Model Details
30
+
31
+ - **Base model**: `meta-llama/Llama-3.2-3B-Instruct`
32
+ - **Training method**: SFT + LoRA
33
+ - **LoRA rank**: 16 | **alpha**: 32
34
+ - **Epochs**: 3
35
+ - **Learning rate**: 1e-5 (cosine schedule)
36
+ - **Trainable modules**: all-linear
37
+ - **Data format**: chat
38
+
39
+ ### Training Data
40
+ 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%).
41
+ Trained on the adapted dataset:
42
+ → [Minutor/adaption-math-word-problem-sub-2](https://huggingface.co/datasets/Minutor/adaption-math-word-problem-sub-2)
43
+
44
+ Which itself was derived from the cleaned seed:
45
+ → [Minutor/20k_math_dataset](https://huggingface.co/datasets/Minutor/20k_math_dataset)
46
+ (GSM8K + NuminaMath-1.5 + OpenMathInstruct-1)
47
+
48
+ ### Evaluation Results
49
+
50
+ Win rates are computed by Adaption using **Gemini 3.1 Pro** as the judge.
51
+ ![Win rates](win-rates.png)
52
+ | Evaluation | Sample size | Base | Adapted | Change |
53
+ |------------|-------------|------|---------|--------|
54
+ | Win-rate on training distribution | 200 held-out datapoints | 42 | **58** | **+16** |
55
+ | Math Win-rate (Adaption held-out) | 100 unseen datapoints across Math tasks | 51 | 50 | –1 |
56
+
57
+ The model shows a clear +16 point improvement on its training distribution while remaining essentially neutral on Adaption’s broader Math evaluation set.
58
+
59
+ ### How to use
60
+
61
+ notebook snippet: [collab shared notebook](https://colab.research.google.com/drive/1E5yBG_7vgviVKPE7qJpbTwJRKLs6YbV_?usp=sharing)
62
+ ```python
63
+ import torch
64
+ from transformers import AutoModelForCausalLM, AutoTokenizer
65
+ from peft import PeftModel
66
+
67
+ BASE = "meta-llama/Llama-3.2-3B-Instruct"
68
+ ADAPTER = "Minutor/adaption_math_word_problem_sub_2"
69
+
70
+ device = "cuda" if torch.cuda.is_available() else "cpu"
71
+ dtype = torch.bfloat16 if device == "cuda" else torch.float32
72
+
73
+ base = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=dtype, device_map="auto")
74
+ model = PeftModel.from_pretrained(base, ADAPTER)
75
+ # Optional: merge for faster inference
76
+ # model = model.merge_and_unload()
77
+
78
+ tokenizer = AutoTokenizer.from_pretrained(BASE)
79
+
80
+ messages = [
81
+ {"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?"}
82
+ ]
83
+
84
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
85
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
86
+
87
+ with torch.inference_mode():
88
+ outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
89
+
90
+ print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
91
+ ```
92
  ### AutoScientist Config
93
 
94
  ```json
 
123
  }
124
  ```
125
 
126
+ <!--
 
 
 
127
  ## Model Evaluation
128
 
129
  The model was evaluated on an in-distribution held-out test set as well as a broader domain-specific test set to measure generalization.
 
133
 
134
  | Domain | Win rate vs. base model |
135
  | --- | --- |
136
+ | math | 50% | -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
 
 
 
 
 
138