CoolFace
Modelpublic

asadullahdogarr/adaption_codeintel_python_reasoning_v

sourceHugging Faceotherupdated 2mo agoView on Hugging Face
0likes6downloads
README.md100 linesDownload Raw Back to root
1---2base_model: google/gemma-3-4b-it3library_name: peft4license: other5tags:6  - lora7  - peft8  - adapter9  - adaption10---11 12# adaption_codeintel_python_reasoning_v13 14## Model Training15 16A LORA adapter for `google/gemma-3-4b-it`. This model was trained with SFT using [Adaption](https://adaptionlabs.ai)'s AutoScientist on the CodeIntel-Python-Reasoning-v1 dataset.17 18 19![Training metrics](training-metrics.png)20 21### AutoScientist Config22 23```json24{25  "job_id": "23277988-2422-4c04-8552-1bd3d6c06ff3",26  "training_experiment_id": "486c999b-f867-47c4-b288-e9e5624c0aad",27  "original_model_name": "google/gemma-3-4b-it",28  "trained_model_name": "adaption_codeintel_python_reasoning_v",29  "training_method": "sft",30  "training_type": "lora",31  "data_format": "chat",32  "hyperparams": {33    "lora": "true",34    "lora_r": 32,35    "n_evals": 5,36    "n_epochs": 1,37    "batch_size": "max",38    "lora_alpha": 64,39    "lora_dropout": 0,40    "min_lr_ratio": 0.1,41    "warmup_ratio": 0.1,42    "weight_decay": 0,43    "learning_rate": 0.00001,44    "max_grad_norm": 2,45    "base_model_size": "4B",46    "train_on_inputs": "false",47    "training_method": "sft",48    "lr_scheduler_type": "cosine",49    "scheduler_num_cycles": 0.5,50    "lora_trainable_modules": "all-linear"51  }52}53```54 55## Training Data56 57The model was trained on 27,678 rows of adapted data with the following domain distribution: code (97%), math (3%).58 59## Model Evaluation60 61The model was evaluated on an in-distribution held-out test set as well as a broader domain-specific test set to measure generalization.62 63 64![Win rates](win-rates.png)65 66 67## How to use68 69```bash70pip install torch transformers peft71```72 73```python74import torch75from transformers import AutoModelForCausalLM, AutoTokenizer76from peft import PeftModel77 78BASE = "google/gemma-3-4b-it"79ADAPTER = "<this-repo-id>"80 81device = "cuda" if torch.cuda.is_available() else "cpu"82dtype = torch.float32 if device == "cpu" else torch.bfloat1683 84base = AutoModelForCausalLM.from_pretrained(BASE, dtype=dtype).to(device)85model = PeftModel.from_pretrained(base, ADAPTER)86# Optional: merge the LoRA weights into the base for faster inference87model = model.merge_and_unload()88model.eval()89 90tokenizer = AutoTokenizer.from_pretrained(BASE)91messages = [{"role": "user", "content": "Hello!"}]92text = tokenizer.apply_chat_template(93    messages, tokenize=False, add_generation_prompt=True)94inputs = tokenizer(text, return_tensors="pt").to(device)95 96with torch.inference_mode():97    out = model.generate(**inputs, max_new_tokens=512)98print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))99```100