Views
No views yet
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."
| 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) |

1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import torch
4
5# 1. Load Base Model
6base_model_id = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
7model = AutoModelForCausalLM.from_pretrained(
8 base_model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12
13# 2. Load This LoRA Adapter
14adapter_id = "colak46/Qwen2.5-Coder-1.5B-DIVERSE-LoRA"
15model = PeftModel.from_pretrained(model, adapter_id)
16tokenizer = AutoTokenizer.from_pretrained(base_model_id)
17
18# 3. Inference
19prompt = "Write a Python function to solve a string manipulation problem."
20messages = [
21 {"role": "system", "content": "You are an expert Python programmer. Please read the problem carefully before writing any Python code."},
22 {"role": "user", "content": prompt}
23]
24
25text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26inputs = tokenizer([text], return_tensors="pt").to("cuda")
27
28outputs = model.generate(**inputs, max_new_tokens=512)
29print(tokenizer.decode(outputs[0], skip_special_tokens=True))