Text Generation
Transformers
Safetensors
English
llama
math
fine-tuned
lora
unsloth
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k") model = AutoModelForCausalLM.from_pretrained("OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k
- SGLang
How to use OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k with Docker Model Runner:
docker model run hf.co/OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k
Upload folder using huggingface_hub
Browse files
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-10k
|
| 74 |
+
|
| 75 |
+
A [Llama-3.2-1B](https://huggingface.co/unsloth/Llama-3.2-1B) fine-tune on **10k 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, 10k 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.7% | 🟢 +2.9% |
|
| 104 |
+
| ARC-Challenge | 36.9% | 36.1% | 🔴 -0.8% |
|
| 105 |
+
| HellaSwag | 64.2% | 63.8% | 🔴 -0.4% |
|
| 106 |
+
| WinoGrande | 60.8% | 62.0% | 🟢 +1.3% |
|
| 107 |
+
|
| 108 |
+
**Speed** (single-request generation, greedy, RTX 4060): **38.79 tokens/sec**
|
| 109 |
+
(base model: 12.74 tokens/sec)
|
| 110 |
+
|
| 111 |
+
### MMLU by category
|
| 112 |
+
|
| 113 |
+

|
| 114 |
+
|
| 115 |
+
## Usage
|
| 116 |
+
|
| 117 |
+
```python
|
| 118 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 119 |
+
|
| 120 |
+
model_id = "OliverSundaram/Llama-3.2-1B-MathCodeInstruct-10k}"
|
| 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 10k-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.
|