--- 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" } } ```