File size: 1,502 Bytes
c55f5dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
license: apache-2.0
tags:
- code
- qwen2.5
- unsloth
- lora
base_model: Qwen/Qwen2.5-3B-Instruct
library_name: peft
---

# CartCode-1 (LoRA Adapter)

This is a LoRA adapter for **Qwen 2.5 3B Instruct**, fine-tuned for code generation.

## 🔧 Training Details

- **Base Model**: Qwen/Qwen2.5-3B-Instruct
- **Method**: Unsloth + LoRA
- **Phase 1**: SFT on custom code dataset
- **Phase 2**: DPO on jondurbin/py-dpo-v0.1

## 🚀 Usage

You can use this model with Unsloth or PEFT.

### With Unsloth (Recommended)

```python
from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "cartmoney/CartCode-1",
    max_seq_length = 2048,
    load_in_4bit = True,
)

FastLanguageModel.for_inference(model)

# Use with system prompt
messages = [
    {"role": "system", "content": "You are an expert Python programmer."},
    {"role": "user", "content": "Write a function to calculate factorial"}
]

inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to("cuda")
outputs = model.generate(inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0]))
```

### With PEFT/Transformers

```python
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer

config = PeftConfig.from_pretrained("cartmoney/CartCode-1")
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-3B-Instruct")
model = PeftModel.from_pretrained(base_model, "cartmoney/CartCode-1")
```