Text Generation
PEFT
Safetensors
English
code-generation
coding-assistant
lora
qwen2.5
blitzkode
conversational
Instructions to use neuralbroker/blitzkode-1.5b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use neuralbroker/blitzkode-1.5b-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct") model = PeftModel.from_pretrained(base_model, "neuralbroker/blitzkode-1.5b-lora") - Notebooks
- Google Colab
- Kaggle
Update model card README.md
Browse files
README.md
CHANGED
|
@@ -1,207 +1,183 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
| 3 |
library_name: peft
|
| 4 |
-
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
- lora
|
| 8 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
## Model Details
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 32 |
-
|
| 33 |
-
### Model Sources [optional]
|
| 34 |
-
|
| 35 |
-
<!-- Provide the basic links for the model. -->
|
| 36 |
-
|
| 37 |
-
- **Repository:** [More Information Needed]
|
| 38 |
-
- **Paper [optional]:** [More Information Needed]
|
| 39 |
-
- **Demo [optional]:** [More Information Needed]
|
| 40 |
-
|
| 41 |
-
## Uses
|
| 42 |
-
|
| 43 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 44 |
-
|
| 45 |
-
### Direct Use
|
| 46 |
-
|
| 47 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 48 |
-
|
| 49 |
-
[More Information Needed]
|
| 50 |
-
|
| 51 |
-
### Downstream Use [optional]
|
| 52 |
-
|
| 53 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 54 |
-
|
| 55 |
-
[More Information Needed]
|
| 56 |
-
|
| 57 |
-
### Out-of-Scope Use
|
| 58 |
-
|
| 59 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 60 |
-
|
| 61 |
-
[More Information Needed]
|
| 62 |
-
|
| 63 |
-
## Bias, Risks, and Limitations
|
| 64 |
-
|
| 65 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 66 |
-
|
| 67 |
-
[More Information Needed]
|
| 68 |
-
|
| 69 |
-
### Recommendations
|
| 70 |
-
|
| 71 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 72 |
-
|
| 73 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 74 |
-
|
| 75 |
-
## How to Get Started with the Model
|
| 76 |
-
|
| 77 |
-
Use the code below to get started with the model.
|
| 78 |
-
|
| 79 |
-
[More Information Needed]
|
| 80 |
-
|
| 81 |
-
## Training Details
|
| 82 |
-
|
| 83 |
-
### Training Data
|
| 84 |
-
|
| 85 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 86 |
-
|
| 87 |
-
[More Information Needed]
|
| 88 |
-
|
| 89 |
-
### Training Procedure
|
| 90 |
-
|
| 91 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 92 |
-
|
| 93 |
-
#### Preprocessing [optional]
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
#### Training Hyperparameters
|
| 99 |
-
|
| 100 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 101 |
-
|
| 102 |
-
#### Speeds, Sizes, Times [optional]
|
| 103 |
-
|
| 104 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 105 |
-
|
| 106 |
-
[More Information Needed]
|
| 107 |
-
|
| 108 |
-
## Evaluation
|
| 109 |
-
|
| 110 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 111 |
-
|
| 112 |
-
### Testing Data, Factors & Metrics
|
| 113 |
-
|
| 114 |
-
#### Testing Data
|
| 115 |
-
|
| 116 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 117 |
-
|
| 118 |
-
[More Information Needed]
|
| 119 |
-
|
| 120 |
-
#### Factors
|
| 121 |
-
|
| 122 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 123 |
-
|
| 124 |
-
[More Information Needed]
|
| 125 |
-
|
| 126 |
-
#### Metrics
|
| 127 |
-
|
| 128 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 129 |
-
|
| 130 |
-
[More Information Needed]
|
| 131 |
-
|
| 132 |
-
### Results
|
| 133 |
-
|
| 134 |
-
[More Information Needed]
|
| 135 |
-
|
| 136 |
-
#### Summary
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
## Model Examination [optional]
|
| 141 |
-
|
| 142 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 143 |
-
|
| 144 |
-
[More Information Needed]
|
| 145 |
-
|
| 146 |
-
## Environmental Impact
|
| 147 |
-
|
| 148 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 149 |
-
|
| 150 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 151 |
-
|
| 152 |
-
- **Hardware Type:** [More Information Needed]
|
| 153 |
-
- **Hours used:** [More Information Needed]
|
| 154 |
-
- **Cloud Provider:** [More Information Needed]
|
| 155 |
-
- **Compute Region:** [More Information Needed]
|
| 156 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 157 |
-
|
| 158 |
-
## Technical Specifications [optional]
|
| 159 |
|
| 160 |
-
##
|
| 161 |
|
| 162 |
-
|
|
|
|
| 163 |
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
-
|
| 167 |
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
-
|
| 171 |
|
| 172 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
-
|
| 175 |
|
| 176 |
-
##
|
| 177 |
|
| 178 |
-
|
| 179 |
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
-
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
-
|
| 189 |
|
| 190 |
-
|
| 191 |
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
-
|
| 195 |
|
| 196 |
-
|
| 197 |
|
| 198 |
-
|
| 199 |
|
| 200 |
-
|
|
|
|
|
|
|
| 201 |
|
| 202 |
-
|
| 203 |
|
| 204 |
-
|
| 205 |
-
### Framework versions
|
| 206 |
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
library_name: peft
|
|
|
|
| 6 |
tags:
|
| 7 |
+
- code-generation
|
| 8 |
+
- lora
|
| 9 |
+
- qwen2.5
|
| 10 |
+
- blitzkode
|
| 11 |
+
- coding-assistant
|
| 12 |
+
- fine-tuned
|
| 13 |
+
- peft
|
| 14 |
+
base_model: Qwen/Qwen2.5-1.5B-Instruct
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# BlitzKode LoRA Adapter (0.5B)
|
| 19 |
|
| 20 |
+
**BlitzKode** is a local AI coding assistant fine-tuned from
|
| 21 |
+
**[Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)** using LoRA
|
| 22 |
+
(Low-Rank Adaptation). This repository contains the PEFT adapter β the
|
| 23 |
+
research-friendly version that can be hot-loaded on top of the base model.
|
| 24 |
|
| 25 |
+
> **Creator:** [Sajad (neuralbroker)](https://github.com/neuralbroker)
|
| 26 |
+
> **GitHub:** <https://github.com/neuralbroker/blitzkode>
|
| 27 |
+
> **Production GGUF:** [`neuralbroker/blitzkode`](https://huggingface.co/neuralbroker/blitzkode)
|
| 28 |
|
| 29 |
+
---
|
| 30 |
|
| 31 |
## Model Details
|
| 32 |
|
| 33 |
+
| Property | Value |
|
| 34 |
+
|---|---|
|
| 35 |
+
| **Adapter version** | 2.1 |
|
| 36 |
+
| **Base model** | `Qwen/Qwen2.5-1.5B-Instruct` |
|
| 37 |
+
| **LoRA rank (r)** | 16 |
|
| 38 |
+
| **LoRA alpha** | 32 |
|
| 39 |
+
| **LoRA dropout** | 0.05 |
|
| 40 |
+
| **Target modules** | `up_proj`, `down_proj`, `q_proj`, `o_proj`, `k_proj`, `gate_proj`, `v_proj` |
|
| 41 |
+
| **Training steps** | 50 |
|
| 42 |
+
| **Final loss** | ~0.48 |
|
| 43 |
+
| **Library** | PEFT |
|
| 44 |
+
| **License** | MIT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
## Training Pipeline
|
| 49 |
|
| 50 |
+
This adapter was produced by a **4-stage fine-tuning pipeline** applied
|
| 51 |
+
to the Qwen2.5 family:
|
| 52 |
|
| 53 |
+
| Stage | Method | Purpose |
|
| 54 |
+
|---|---|---|
|
| 55 |
+
| 1 | SFT | Supervised fine-tuning on 71 curated algorithmic coding problems |
|
| 56 |
+
| 2 | Reward-SFT | Continued SFT with heuristic reward signals for code correctness and formatting |
|
| 57 |
+
| 3 | DPO | Direct Preference Optimization on handcrafted chosen/rejected pairs |
|
| 58 |
+
| 4 | LoRA SFT (this adapter) | Final LoRA fine-tune (r=16) on 99 samples; base model Qwen2.5-0.5B |
|
| 59 |
|
| 60 |
+
### Training Dataset (199 total samples)
|
| 61 |
|
| 62 |
+
| Subset | Count | Source | License |
|
| 63 |
+
|---|---|---|---|
|
| 64 |
+
| Curated algorithmic problems | 71 | Custom (local) β arrays, strings, trees, DP, graphs | MIT |
|
| 65 |
+
| MetaMathQA samples | 100 | [`meta-math/MetaMathQA`](https://huggingface.co/datasets/meta-math/MetaMathQA) | CC BY 4.0 |
|
| 66 |
+
| Python/JavaScript patterns | 28 | Custom (local) β decorators, context managers, data classes | MIT |
|
| 67 |
+
| **Total** | **199** | | |
|
| 68 |
|
| 69 |
+
---
|
| 70 |
|
| 71 |
+
## Usage
|
| 72 |
+
|
| 73 |
+
### Load with PEFT
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
from peft import PeftModel
|
| 77 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 78 |
+
|
| 79 |
+
base_model_id = "Qwen/Qwen2.5-1.5B-Instruct"
|
| 80 |
+
adapter_repo = "neuralbroker/blitzkode-1.5b-lora"
|
| 81 |
+
|
| 82 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
|
| 83 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 84 |
+
base_model_id,
|
| 85 |
+
torch_dtype="auto",
|
| 86 |
+
device_map="auto",
|
| 87 |
+
trust_remote_code=True,
|
| 88 |
+
)
|
| 89 |
+
model = PeftModel.from_pretrained(model, adapter_repo)
|
| 90 |
+
model.eval()
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
### Generate code
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
prompt = (
|
| 97 |
+
"<|im_start|>system\n"
|
| 98 |
+
"You are BlitzKode, a precise AI coding assistant created by Sajad.\n"
|
| 99 |
+
"<|im_end|>\n"
|
| 100 |
+
"<|im_start|>user\n"
|
| 101 |
+
"Write a Python function for binary search with full edge-case handling.\n"
|
| 102 |
+
"<|im_end|>\n"
|
| 103 |
+
"<|im_start|>assistant\n"
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 107 |
+
outputs = model.generate(
|
| 108 |
+
**inputs,
|
| 109 |
+
max_new_tokens=300,
|
| 110 |
+
temperature=0.7,
|
| 111 |
+
do_sample=True,
|
| 112 |
+
repetition_penalty=1.1,
|
| 113 |
+
)
|
| 114 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
### Merge adapter into base model (for export)
|
| 118 |
+
|
| 119 |
+
```python
|
| 120 |
+
merged = model.merge_and_unload()
|
| 121 |
+
merged.save_pretrained("blitzkode-0.5b-merged")
|
| 122 |
+
tokenizer.save_pretrained("blitzkode-0.5b-merged")
|
| 123 |
+
```
|
| 124 |
|
| 125 |
+
---
|
| 126 |
|
| 127 |
+
## Prompt Format
|
| 128 |
|
| 129 |
+
BlitzKode uses the **ChatML** template standard for Qwen models:
|
| 130 |
|
| 131 |
+
```
|
| 132 |
+
<|im_start|>system
|
| 133 |
+
You are BlitzKode, a precise AI coding assistant created by Sajad.<|im_end|>
|
| 134 |
+
<|im_start|>user
|
| 135 |
+
{your question}<|im_end|>
|
| 136 |
+
<|im_start|>assistant
|
| 137 |
+
```
|
| 138 |
|
| 139 |
+
---
|
| 140 |
|
| 141 |
+
## Limitations
|
| 142 |
|
| 143 |
+
- **Text-only** β no image/multimodal support.
|
| 144 |
+
- **0.5B parameters** β smaller and faster than the 1.5B GGUF variant; may be
|
| 145 |
+
less accurate on complex algorithmic tasks.
|
| 146 |
+
- **2048-token context** β not suitable for long repository-level analysis.
|
| 147 |
+
- **Review all outputs** β generated code must be tested before use in production.
|
| 148 |
+
- **Not security-audited** β do not use for cryptographic or safety-critical code
|
| 149 |
+
without thorough expert review.
|
| 150 |
+
- **Math reasoning** β MetaMathQA training improves basic reasoning but does not
|
| 151 |
+
substitute a dedicated math model.
|
| 152 |
|
| 153 |
+
---
|
| 154 |
|
| 155 |
+
## Relation to the Production Model
|
| 156 |
|
| 157 |
+
| Variant | Repo | Size | Runtime | Use case |
|
| 158 |
+
|---|---|---|---|---|
|
| 159 |
+
| GGUF (1.5B, F16) | [`neuralbroker/blitzkode`](https://huggingface.co/neuralbroker/blitzkode) | ~3 GB | llama.cpp / llama-cpp-python | Production; CPU/GPU, no Python ML stack needed |
|
| 160 |
+
| LoRA adapter (0.5B) | `neuralbroker/blitzkode-1.5b-lora` (this repo) | ~100 MB | PEFT + Transformers | Research; merging, further fine-tuning, quantization |
|
| 161 |
|
| 162 |
+
---
|
| 163 |
|
| 164 |
+
## License
|
| 165 |
|
| 166 |
+
**MIT** β see [LICENSE](https://github.com/neuralbroker/blitzkode/blob/main/LICENSE).
|
| 167 |
|
| 168 |
+
You must also comply with the upstream
|
| 169 |
+
[Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) license
|
| 170 |
+
when redistributing any derived weights.
|
| 171 |
|
| 172 |
+
---
|
| 173 |
|
| 174 |
+
## Citation
|
|
|
|
| 175 |
|
| 176 |
+
```bibtex
|
| 177 |
+
@software{blitzkode2025,
|
| 178 |
+
author = {Sajad},
|
| 179 |
+
title = {BlitzKode: A Local AI Coding Assistant},
|
| 180 |
+
year = {2025},
|
| 181 |
+
url = {https://github.com/neuralbroker/blitzkode}
|
| 182 |
+
}
|
| 183 |
+
```
|