Naholav/CodeGen-Deep-5K
Viewer • Updated • 5k • 56
How to use colak46/Qwen2.5-Coder-1.5B-DEEP-LoRA with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-1.5B-Instruct")
model = PeftModel.from_pretrained(base_model, "colak46/Qwen2.5-Coder-1.5B-DEEP-LoRA")This model is a Fine-Tuned version of Qwen2.5-Coder-1.5B-Instruct using LoRA (Low-Rank Adaptation). It was trained as part of a Competitive Code Reasoning project.
The model was fine-tuned on the CodeGen-Deep-5K dataset.
solution (code-only) alanı kullanılarak eğitilmiştir."You are an expert Python programmer. Please read the problem carefully before writing any Python code."
The following hyperparameters were used during training (as per project specifications):
| Parameter | Value |
|---|---|
| Learning Rate | 2e-4 |
| Batch Size | 8 (Effective: 16 via Gradient Accumulation) |
| Context Length | 1024 |
| LoRA Rank (r) | 64 |
| LoRA Alpha | 128 |
| LoRA Dropout | 0.05 |
| Target Modules | All Linear Layers (q, k, v, o, gate, up, down) |
| Optimizer | AdamW |
| Precision | bf16 (BFloat16) |
Training loss logs demonstrating the model's convergence:
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# 1. Load Base Model
base_model_id = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# 2. Load This LoRA Adapter
adapter_id = "colak46/Qwen2.5-Coder-1.5B-DEEP-LoRA"
model = PeftModel.from_pretrained(model, adapter_id)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
# 3. Inference
prompt = "Write a Python function to solve the Valid Parentheses problem."
messages = [
{"role": "system", "content": "You are an expert Python programmer. Please read the problem carefully before writing any Python code."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Base model
Qwen/Qwen2.5-1.5B