Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language: en
|
| 4 |
+
tags:
|
| 5 |
+
- qwen3
|
| 6 |
+
- coding
|
| 7 |
+
- code-generation
|
| 8 |
+
- fine-tuned
|
| 9 |
+
- qlora
|
| 10 |
+
- gguf
|
| 11 |
+
- instruction
|
| 12 |
+
- python
|
| 13 |
+
datasets:
|
| 14 |
+
- TokenBender/code_instructions_122k_alpaca_style
|
| 15 |
+
model_type: qwen3
|
| 16 |
+
base_model: Qwen/Qwen3-0.6B
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Qwen3-0.6B-Coding-Finetuned-v1
|
| 20 |
+
|
| 21 |
+
This model is a fine-tuned version of `Qwen/Qwen3-0.6B` specialized for Python code generation tasks. It's designed to understand programming-related instructions and provide accurate and efficient Python code solutions.
|
| 22 |
+
|
| 23 |
+
## 💻 Model Description
|
| 24 |
+
|
| 25 |
+
- **Base Model**: `Qwen/Qwen3-0.6B`
|
| 26 |
+
- **Fine-tuning Method**: **QLoRA** (Quantized Low-Rank Adaptation)
|
| 27 |
+
- **Dataset**: `TokenBender/code_instructions_122k_alpaca_style` - A large dataset of coding instructions and their corresponding solutions.
|
| 28 |
+
- **Training**: Optimized for instruction-based code generation using 4-bit quantization for efficiency.
|
| 29 |
+
|
| 30 |
+
## ⚠️ Important Considerations
|
| 31 |
+
|
| 32 |
+
- **Verify All Code**: Generated code may contain errors or be suboptimal. Always test and review the code thoroughly before using it in production environments.
|
| 33 |
+
- **Security**: The generated code has not been vetted for security vulnerabilities. Be cautious when using it in security-sensitive applications.
|
| 34 |
+
- **Not a Replacement for Developers**: This model is a tool to assist developers, not replace them. Human oversight and expertise are crucial.
|
| 35 |
+
|
| 36 |
+
## 🚀 Usage
|
| 37 |
+
|
| 38 |
+
### With `transformers`
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 42 |
+
import torch
|
| 43 |
+
|
| 44 |
+
model_id = "rohitnagareddy/Qwen3-0.6B-Coding-Finetuned-v1"
|
| 45 |
+
|
| 46 |
+
# Load model and tokenizer
|
| 47 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 48 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 49 |
+
model_id,
|
| 50 |
+
torch_dtype=torch.float16,
|
| 51 |
+
device_map="auto",
|
| 52 |
+
trust_remote_code=True
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
# Create conversation for a Python code-generation task
|
| 56 |
+
messages = [
|
| 57 |
+
{"role": "system", "content": "You are an expert coding assistant."},
|
| 58 |
+
{"role": "user", "content": "Write a Python function that takes a list of integers and returns the sum of all even numbers in the list."}
|
| 59 |
+
]
|
| 60 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 61 |
+
|
| 62 |
+
pipe = pipeline(
|
| 63 |
+
"text-generation",
|
| 64 |
+
model=model,
|
| 65 |
+
tokenizer=tokenizer
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
# Generate response
|
| 69 |
+
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
| 70 |
+
print(outputs[0]["generated_text"])
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## 🔧 GGUF Versions
|
| 74 |
+
|
| 75 |
+
This repository includes quantized GGUF versions for use with `llama.cpp` and compatible tools:
|
| 76 |
+
|
| 77 |
+
- `Qwen3-0.6B-Coding-Finetuned-v1.fp16.gguf` - Full precision (largest, best quality)
|
| 78 |
+
- `Qwen3-0.6B-Coding-Finetuned-v1.Q8_0.gguf` - 8-bit quantization (good balance)
|
| 79 |
+
- `Qwen3-0.6B-Coding-Finetuned-v1.Q5_K_M.gguf` - 5-bit quantization (smaller, fast)
|
| 80 |
+
- `Qwen3-0.6B-Coding-Finetuned-v1.Q4_K_M.gguf` - 4-bit quantization (smallest, fastest)
|
| 81 |
+
|
| 82 |
+
### Example with llama.cpp
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
./main -m ./Qwen3-0.6B-Coding-Finetuned-v1.Q4_K_M.gguf -n 256 -p "<|im_start|>system\nYou are an expert coding assistant.<|im_end|>\n<|im_start|>user\nCreate a Python function to find the factorial of a number.<|im_end|>\n<|im_start|>assistant\n"
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## 📊 Training Details
|
| 89 |
+
|
| 90 |
+
- **Training Epochs**: 1
|
| 91 |
+
- **QLoRA Rank (r)**: 16
|
| 92 |
+
- **QLoRA Alpha**: 32
|
| 93 |
+
- **Learning Rate**: 2e-4
|
| 94 |
+
- **Optimizer**: Paged AdamW 32-bit
|
| 95 |
+
- **Target Modules**: Auto-detected linear layers
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
*Model created by rohitnagareddy using an automated Colab script.*
|