Views
No views yet
1r: 64 # LoRA rank
2alpha: 128 # LoRA alpha (2*r)
3dropout: 0.05 # LoRA dropout
4target_modules: # Applied to all linear layers
5 - q_proj, k_proj, v_proj, o_proj
6 - gate_proj, up_proj, down_projFinal Loss: 0.48 (from 1.63)
Perplexity: 1.59 (from 5.12)
Accuracy: 89% (from 61%)1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5# Load base model
6base_model = AutoModelForCausalLM.from_pretrained(
7 "Qwen/Qwen2.5-Coder-32B-Instruct",
8 dtype=torch.bfloat16,
9 device_map="auto"
10)
11
12# Load tokenizer
13tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-32B-Instruct")
14
15# Load LoRA adapter
16model = PeftModel.from_pretrained(base_model, "juspay/Qwen2.5-Coder-32B-Instruct-CPT-LoRA-Adapter-HyperSwitch")
17
18# Generate code
19prompt = """// Hyperswitch payment processing
20pub fn validate_payment_method("""
21
22inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
23outputs = model.generate(
24 **inputs,
25 max_new_tokens=200,
26 temperature=0.2, # Lower temperature for code generation
27 do_sample=True,
28 pad_token_id=tokenizer.eos_token_id
29)
30
31print(tokenizer.decode(outputs[0], skip_special_tokens=True))1@misc{hyperswitch-qwen-lora-2024,
2 title={Qwen2.5-Coder-32B-Instruct-CPT-LoRA-Adapter-HyperSwitch},
3 author={Juspay},
4 year={2024},
5 publisher={Hugging Face},
6 url={https://huggingface.co/juspay/Qwen2.5-Coder-32B-Instruct-CPT-LoRA-Adapter-HyperSwitch}
7}