Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- qwen2
|
| 5 |
+
- lora
|
| 6 |
+
- fine-tuned
|
| 7 |
+
- code-generation
|
| 8 |
+
- opencodeinstruct
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
base_model: Qwen/Qwen2-0.5B
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Qwen2-0.5b LoRA Fine-tuned on OpenCodeInstruct
|
| 14 |
+
|
| 15 |
+
This model is a LoRA fine-tuned version of Qwen/Qwen2-0.5B on the OpenCodeInstruct dataset.
|
| 16 |
+
|
| 17 |
+
## Model Details
|
| 18 |
+
|
| 19 |
+
- **Base Model**: Qwen/Qwen2-0.5B
|
| 20 |
+
- **Fine-tuning Dataset**: OpenCodeInstruct (300 samples)
|
| 21 |
+
- **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
|
| 22 |
+
- **LoRA Rank**: 16
|
| 23 |
+
- **LoRA Alpha**: 32
|
| 24 |
+
|
| 25 |
+
## Usage
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 29 |
+
from peft import PeftModel
|
| 30 |
+
|
| 31 |
+
# Load base model
|
| 32 |
+
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B")
|
| 33 |
+
|
| 34 |
+
# Load LoRA adapters
|
| 35 |
+
model = PeftModel.from_pretrained(base_model, "alpayH/qwen2-0.5b-lora-opencodeinstruct")
|
| 36 |
+
|
| 37 |
+
# Load tokenizer
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained("alpayH/qwen2-0.5b-lora-opencodeinstruct")
|
| 39 |
+
|
| 40 |
+
# Generate code
|
| 41 |
+
prompt = "### Instruction:\nWrite a Python function to reverse a string\n\n### Response:\n"
|
| 42 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 43 |
+
outputs = model.generate(**inputs, max_length=512)
|
| 44 |
+
print(tokenizer.decode(outputs[0]))
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Training Details
|
| 48 |
+
|
| 49 |
+
- **Learning Rate**: 2e-4
|
| 50 |
+
- **Batch Size**: 16 (effective, with gradient accumulation)
|
| 51 |
+
- **Epochs**: 3
|
| 52 |
+
- **Precision**: bfloat16
|
| 53 |
+
|
| 54 |
+
## Evaluation
|
| 55 |
+
|
| 56 |
+
This model has been evaluated on LiveCodeBench. See the main repository for evaluation results.
|
| 57 |
+
|
| 58 |
+
## License
|
| 59 |
+
|
| 60 |
+
Apache 2.0
|