--- license: apache-2.0 base_model: Qwen/Qwen3.5-0.8B-Base tags: - qwen - python - code-generation - qlora - sft - unsloth - gguf datasets: - code-search-net/code_search_net language: - en library_name: transformers pipeline_tag: text-generation --- # Qwen3.5-0.8B-Python-SFT **Python code generation model** — Qwen3.5-0.8B-Base fine-tuned with **QLoRA (Supervised Fine-Tuning)** on **CodeSearchNet (Python)**: docstring → function code pairs. ## Model Details | Property | Value | |----------|-------| | Base model | [Qwen/Qwen3.5-0.8B-Base](https://huggingface.co/Qwen/Qwen3.5-0.8B-Base) | | Method | QLoRA (4-bit base + LoRA r=16, alpha=32) | | Trainable params | 6.4M / 759M (0.84%) | | Dataset | CodeSearchNet Python — 408K samples (13,590 repos) | | Task | Docstring → Python function code | | Sequence length | 2048 | | Precision | BF16 | | Hardware | NVIDIA RTX 4060 8GB | ## Training Results | Metric | Value | |--------|-------| | Train loss | 0.330 | | Eval loss | 1.214 | | Steps | 25,524 (1 epoch) | | Runtime | ~25.7h | ## Evaluation pass@1 (temperature 0.2), official test harness, both models in bf16. | Benchmark | Base | **Fine-tuned** | Improvement | |-----------|-----:|---------------:|------------:| | HumanEval | 1.2% | **17.7%** | 14.5x | | MBPP | 0.0% | 0.2% | 0 → 1 | Full report with example solutions: `reports/evaluation_report.md` in the training repo. ## Training Details - **Method:** QLoRA — 4-bit quantized base + LoRA (r=16, alpha=32, dropout=0) - **Target modules:** q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj - **Optimizer:** adamw_8bit (bitsandbytes), cosine schedule, 3% warmup - **Batch:** 2 per device × 8 grad accumulation (effective 16) - **Max sequence length:** 2048 - **Hardware:** NVIDIA RTX 4060 8GB, ~25.7h - **Data:** CodeSearchNet Python filtered to ≤2048 tokens (408,377 train samples) ## Usage ### Transformers (LoRA adapter) ```python from unsloth import FastLanguageModel model, tokenizer = FastLanguageModel.from_pretrained( "Qwen/Qwen3.5-0.8B-Base", max_seq_length=2048, load_in_4bit=True, ) model, tokenizer = FastLanguageModel.from_pretrained( "jaweed123/Qwen3.5-0.8B-Python-SFT", max_seq_length=2048, load_in_4bit=True, ) ``` ### GGUF (ollama / llama.cpp / vLLM) ```bash # llama.cpp llama-cli -m qwen3.5-0.8b-python-sft-q4_k_m.gguf -p "Write a Python function that..." # Ollama ollama create qwen3.5-python -f Modelfile ``` ```dockerfile # Modelfile FROM qwen3.5-0.8b-python-sft-q4_k_m.gguf TEMPLATE "{{ if .System }}<|im_start|>system {{ .System }}<|im_end|> {{ end }}<|im_start|>user {{ .Prompt }}<|im_end|> <|im_start|>assistant " ``` ## Files | File | Description | |------|-------------| | `adapter_model.safetensors` | LoRA adapter (small, ~13MB) | | `model.safetensors` | Merged 16-bit model | | `qwen3.5-0.8b-python-sft-q4_k_m.gguf` | GGUF Q4_K_M (~0.5GB) | | `qwen3.5-0.8b-python-sft-q8_0.gguf` | GGUF Q8_0 (~0.9GB) | | `qwen3.5-0.8b-python-sft-f16.gguf` | GGUF F16 | ## Limitations - Fine-tuned for Python function generation from docstrings - Trained on 2019-era open-source code - 0.8B scale — limited reasoning; best for straightforward code tasks