OliverSundaram commited on
Commit
060acf3
·
verified ·
1 Parent(s): de1c950

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +138 -0
README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: llama3.2
4
+ license_link: https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/LICENSE
5
+ base_model: unsloth/Llama-3.2-1B
6
+ tags:
7
+ - math
8
+ - fine-tuned
9
+ - lora
10
+ - unsloth
11
+ - llama
12
+ datasets:
13
+ - MathLLMs/MathCodeInstruct
14
+ language:
15
+ - en
16
+ library_name: transformers
17
+ pipeline_tag: text-generation
18
+ model-index:
19
+ - name: Llama-3.2-1B-MathCodeInstruct-{{SIZE}}
20
+ results:
21
+ - task:
22
+ type: text-generation
23
+ name: GSM8K
24
+ dataset:
25
+ type: gsm8k
26
+ name: GSM8K
27
+ metrics:
28
+ - type: exact_match
29
+ value: {{GSM8K_ACC}}
30
+ name: exact match (flexible-extract, 5-shot)
31
+ - task:
32
+ type: text-generation
33
+ name: ARC-Challenge
34
+ dataset:
35
+ type: ai2_arc
36
+ name: ARC-Challenge
37
+ metrics:
38
+ - type: acc_norm
39
+ value: {{ARC_ACC}}
40
+ name: acc_norm (25-shot)
41
+ - task:
42
+ type: text-generation
43
+ name: HellaSwag
44
+ dataset:
45
+ type: hellaswag
46
+ name: HellaSwag
47
+ metrics:
48
+ - type: acc_norm
49
+ value: {{HELLASWAG_ACC}}
50
+ name: acc_norm (10-shot)
51
+ - task:
52
+ type: text-generation
53
+ name: WinoGrande
54
+ dataset:
55
+ type: winogrande
56
+ name: WinoGrande
57
+ metrics:
58
+ - type: acc
59
+ value: {{WINOGRANDE_ACC}}
60
+ name: acc (5-shot)
61
+ - task:
62
+ type: text-generation
63
+ name: MMLU
64
+ dataset:
65
+ type: mmlu
66
+ name: MMLU
67
+ metrics:
68
+ - type: acc
69
+ value: {{MMLU_ACC}}
70
+ name: acc (5-shot)
71
+ ---
72
+
73
+ # Llama-3.2-1B-MathCodeInstruct-20k
74
+
75
+ A [Llama-3.2-1B](https://huggingface.co/unsloth/Llama-3.2-1B) fine-tune on **20k examples** from
76
+ [MathLLMs/MathCodeInstruct](https://huggingface.co/datasets/MathLLMs/MathCodeInstruct), trained to solve math
77
+ word problems with step-by-step natural-language reasoning interleaved with executable Python.
78
+
79
+ This is one of three sibling models trained on {5k, 10k, 20k}-example subsets of the same dataset, to study how
80
+ fine-tuning data volume trades off against both math performance and general capability. See the
81
+ [training write-up](https://github.com/OliverSundaram/finetuning-Llama3.2-1B) for the full comparison across all three.
82
+
83
+ ## Training details
84
+
85
+ | | |
86
+ |---|-----------------------------------------------------------------------------------------|
87
+ | Base model | `unsloth/Llama-3.2-1B` |
88
+ | Method | LoRA (r=16, α=16, dropout=0) on all attention + MLP projections, merged to full weights |
89
+ | Dataset | MathLLMs/MathCodeInstruct, 20k training examples |
90
+ | Epochs | 1 |
91
+ | Effective batch size | 16 (batch 1 × grad. accum. 16) |
92
+ | Learning rate | 2e-4, cosine schedule, warmup ratio 0.03 |
93
+ | Hardware | 1× RTX 4060 (8GB) |
94
+ | Framework | Unsloth + TRL `SFTTrainer` |
95
+
96
+ ## Benchmark results
97
+
98
+ All benchmarks run with [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness), each at
99
+ its standard published shot count, compared against the un-tuned base model.
100
+
101
+ | Benchmark | Llama-3.2-1B (base) | This model | Change |
102
+ |---|---|---|---|
103
+ | GSM8K | 5.8% | 8.9% | 🟢 +3.1% |
104
+ | ARC-Challenge | 36.9% | 35.8% | 🔴 -1.1% |
105
+ | HellaSwag | 64.2% | 63.6% | 🔴 -0.6% |
106
+ | WinoGrande | 60.8% | 61.4% | 🟢 +0.6% |
107
+
108
+ **Speed** (single-request generation, greedy, RTX 4060): **37.84 tokens/sec**
109
+ (base model: 12.74 tokens/sec)
110
+
111
+ ### MMLU by category
112
+
113
+ ![MMLU comparison](mmlu_20k.png)
114
+
115
+ ## Usage
116
+
117
+ ```python
118
+ from transformers import AutoModelForCausalLM, AutoTokenizer
119
+
120
+ model_id = "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-20k}"
121
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
122
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="bfloat16", device_map="auto")
123
+
124
+ messages = [
125
+ {"role": "system", "content": "Below is a math problem. Please solve it step by step."},
126
+ {"role": "user", "content": "If a train travels 60 miles in 45 minutes, what is its speed in miles per hour?"},
127
+ ]
128
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
129
+ output = model.generate(inputs, max_new_tokens=512, do_sample=False)
130
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
131
+ ```
132
+
133
+ ## Limitations
134
+
135
+ - Trained on a single epoch of a 20k-example subset — not intended to be a general-purpose assistant.
136
+ - MMLU/ARC/HellaSwag/WinoGrande scores reflect a small 1B-parameter base model and should be read relative to
137
+ the base model's own scores, not against much larger models.
138
+ - No safety alignment or RLHF was applied beyond what the base Llama-3.2-1B already has.