--- base_model: meta-llama/Llama-3.2-3B-Instruct library_name: peft license: other tags: - lora - peft - adapter - adaption --- # adaption_africa_math_code_qa ## 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 africa_math_code_qa dataset. ![Training metrics](training-metrics.png) ### AutoScientist Config ```json { "job_id": "d70be010-a89f-464a-a6c9-928fae8e0d79", "training_experiment_id": "2904a8f8-eaab-4afa-81cb-1a5473972fd3", "original_model_name": "meta-llama/Llama-3.2-3B-Instruct", "trained_model_name": "adaption_africa_math_code_qa", "training_method": "sft", "training_type": "lora", "data_format": "chat", "hyperparams": { "lora": "true", "lora_r": 16, "n_evals": 5, "n_epochs": 1, "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" } } ``` ## Training Data The model was trained on 27,523 rows of adapted data with the following domain distribution: code (31%), math (20%), agriculture (18%), personal-finance (10%), geography (4%), technology (4%), science (4%), governance (3%), corporate-business (2%), how-to (1%), travel (1%), architecture-design (1%), legal (0%), language (0%), education (0%), marketing (0%), data-analysis-visualization (0%). ## 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 | | --- | --- | | general | 54% | ## How to use ```bash pip install torch transformers peft ``` ```python import torch from transformers import AutoModelForCausalLM, AutoTokenizer from peft import PeftModel BASE = "meta-llama/Llama-3.2-3B-Instruct" ADAPTER = "" device = "cuda" if torch.cuda.is_available() else "cpu" dtype = torch.float32 if device == "cpu" else torch.bfloat16 base = AutoModelForCausalLM.from_pretrained(BASE, dtype=dtype).to(device) model = PeftModel.from_pretrained(base, ADAPTER) # Optional: merge the LoRA weights into the base for faster inference model = model.merge_and_unload() model.eval() tokenizer = AutoTokenizer.from_pretrained(BASE) messages = [{"role": "user", "content": "Hello!"}] text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True) inputs = tokenizer(text, return_tensors="pt").to(device) with torch.inference_mode(): out = model.generate(**inputs, max_new_tokens=512) print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)) ```