Text Generation
MLX
Safetensors
English
qwen2
laravel
php
code-generation
lora
fine-tuned
laravel-boost
conversational
4-bit precision
Instructions to use fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,16 +1,219 @@
|
|
| 1 |
---
|
| 2 |
-
base_model: mlx-community/Qwen2.5-Coder-7B-Instruct-4bit
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
-
library_name: mlx
|
| 6 |
license: apache-2.0
|
| 7 |
-
|
| 8 |
-
pipeline_tag: text-generation
|
| 9 |
tags:
|
| 10 |
-
-
|
| 11 |
-
-
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- laravel
|
| 6 |
+
- php
|
| 7 |
+
- code-generation
|
| 8 |
+
- mlx
|
| 9 |
+
- lora
|
| 10 |
+
- fine-tuned
|
| 11 |
+
datasets:
|
| 12 |
+
- fchis/Laravel-13x-Code-Instructions
|
| 13 |
+
language:
|
| 14 |
+
- en
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
library_name: mlx
|
| 17 |
+
model-index:
|
| 18 |
+
- name: Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA
|
| 19 |
+
results: []
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
# Laravel 13.x Qwen2.5-Coder-7B-Instruct LoRA
|
| 23 |
+
|
| 24 |
+
A 7B code-specialized model fine-tuned on Laravel 13.x instruction-to-code pairs. **Trained entirely on an Apple M2 Pro with 16GB RAM** using Apple's MLX framework — no cloud GPU needed.
|
| 25 |
+
|
| 26 |
+
Part of a two-model pipeline for AI-assisted Laravel code generation. See [github.com/florinel-chis/laravel-ai-gen](https://github.com/florinel-chis/laravel-ai-gen) for the complete tool.
|
| 27 |
+
|
| 28 |
+
## Proven: Fine-Tuning Works
|
| 29 |
+
|
| 30 |
+
A/B comparison of base vs fine-tuned model on the same prompts:
|
| 31 |
+
|
| 32 |
+
| Behavior | Base Qwen2.5-Coder-7B | This model (fine-tuned) |
|
| 33 |
+
|----------|----------------------|------------------------|
|
| 34 |
+
| Output format | "Certainly! Below is a clean..." prose + markdown | **Pure PHP code, no prose** |
|
| 35 |
+
| Token efficiency | ~500 tokens for incomplete output with explanation | **Complete files in 100-200 tokens** |
|
| 36 |
+
| Migration style | Old named class `class CreateContactsTable` | **Modern `return new class extends Migration`** |
|
| 37 |
+
| Validation syntax | N/A (never reached code in 500 tokens) | **Array syntax `['required', 'max:255']`** |
|
| 38 |
+
| Controller pattern | N/A (spent all tokens on "Step 1: Create the Model...") | **FormRequest injection + `response()->json()`** |
|
| 39 |
+
|
| 40 |
+
The base model literally never produces usable code at 500 max_tokens because it spends all tokens on explanation. The fine-tuned model produces complete, runnable PHP files.
|
| 41 |
+
|
| 42 |
+
## Test Results: 4/4 Perfect on Specific Instructions
|
| 43 |
+
|
| 44 |
+
| Instruction | Output | PHP Valid |
|
| 45 |
+
|------------|--------|-----------|
|
| 46 |
+
| "Create model for Contact with fillable: name, email, subject, message" | Exact 4 fields, no extras, no relationships | **Yes** |
|
| 47 |
+
| "Write migration for contacts with name, email, subject, message" | Full `return new class extends Migration` wrapper | **Yes** |
|
| 48 |
+
| "Create Form Request with validation rules" | Modern array syntax, correct 4 rules | **Yes** |
|
| 49 |
+
| "Write ContactController with store using StoreContactRequest, return 201" | FormRequest injection, `Contact::create`, 201 JSON | **Yes** |
|
| 50 |
+
|
| 51 |
+
### Sample output: Controller
|
| 52 |
+
|
| 53 |
+
**Prompt:** "Write a Laravel ContactController with a store method that uses StoreContactRequest and creates a Contact. Return 201 JSON."
|
| 54 |
+
|
| 55 |
+
```php
|
| 56 |
+
<?php
|
| 57 |
+
|
| 58 |
+
namespace App\Http\Controllers;
|
| 59 |
+
|
| 60 |
+
use App\Http\Requests\StoreContactRequest;
|
| 61 |
+
use App\Models\Contact;
|
| 62 |
+
|
| 63 |
+
class ContactController extends Controller
|
| 64 |
+
{
|
| 65 |
+
public function store(StoreContactRequest $request)
|
| 66 |
+
{
|
| 67 |
+
$contact = Contact::create($request->validated());
|
| 68 |
+
|
| 69 |
+
return response()->json($contact, 201);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### Sample output: Model
|
| 75 |
+
|
| 76 |
+
**Prompt:** "Create a Laravel Eloquent model for Contact with fillable fields: name, email, subject, message."
|
| 77 |
+
|
| 78 |
+
```php
|
| 79 |
+
<?php
|
| 80 |
+
|
| 81 |
+
namespace App\Models;
|
| 82 |
+
|
| 83 |
+
use Illuminate\Database\Eloquent\Model;
|
| 84 |
+
|
| 85 |
+
class Contact extends Model
|
| 86 |
+
{
|
| 87 |
+
protected $fillable = [
|
| 88 |
+
'name',
|
| 89 |
+
'email',
|
| 90 |
+
'subject',
|
| 91 |
+
'message',
|
| 92 |
+
];
|
| 93 |
+
}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## 7B vs 3B Comparison
|
| 97 |
+
|
| 98 |
+
Both trained on the same 139 examples:
|
| 99 |
+
|
| 100 |
+
| Aspect | 3B (LoRA) | **7B (LoRA)** |
|
| 101 |
+
|--------|-----------|---------------|
|
| 102 |
+
| Form Request | Pipe syntax `'required\|max:255'` | **Array syntax `['required', 'max:255']`** |
|
| 103 |
+
| Controller | Minor `\response` return type issue | **Clean, no issues** |
|
| 104 |
+
| Training peak | 5.8 GB | **7.6 GB** |
|
| 105 |
+
| Inference speed | ~1-2s per file | ~12-14s per file |
|
| 106 |
+
| Quality | Good | **Better** |
|
| 107 |
+
|
| 108 |
+
The 7B is recommended when quality matters. The 3B is 6x faster for iteration.
|
| 109 |
+
|
| 110 |
+
## Real Laravel Test: Contact Form
|
| 111 |
+
|
| 112 |
+
Tested in a real Laravel 13.x project with `php artisan serve`:
|
| 113 |
+
|
| 114 |
+
| Endpoint | Status | Result |
|
| 115 |
+
|----------|--------|--------|
|
| 116 |
+
| POST /api/contact (valid data) | **201 Created** | Contact saved to database |
|
| 117 |
+
| POST /api/contact (missing fields) | **422 Validation** | Correct error messages |
|
| 118 |
+
| POST /api/contact (invalid email) | **422 Validation** | "must be a valid email address" |
|
| 119 |
+
|
| 120 |
+
Migration + Form Request files were usable as-is. Model and Controller needed fixes when instructions came from the planner (vague), but were perfect when given specific instructions directly.
|
| 121 |
+
|
| 122 |
+
## How to Use
|
| 123 |
+
|
| 124 |
+
### Standalone (specific instructions)
|
| 125 |
+
|
| 126 |
+
```python
|
| 127 |
+
from mlx_lm import load, generate
|
| 128 |
+
|
| 129 |
+
model, tok = load("fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA")
|
| 130 |
+
|
| 131 |
+
messages = [
|
| 132 |
+
{"role": "system", "content": "You are a senior Laravel developer. Write clean, production-ready Laravel code."},
|
| 133 |
+
{"role": "user", "content": "Create a Laravel Eloquent model for Contact with fillable fields: name, email, subject, message."}
|
| 134 |
+
]
|
| 135 |
+
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 136 |
+
response = generate(model, tok, prompt=text, max_tokens=500)
|
| 137 |
+
print(response)
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
### Two-model pipeline (feature descriptions)
|
| 141 |
+
|
| 142 |
+
```bash
|
| 143 |
+
pip install mlx-lm
|
| 144 |
+
git clone https://github.com/florinel-chis/laravel-ai-gen
|
| 145 |
+
cd laravel-ai-gen
|
| 146 |
+
|
| 147 |
+
# Use 7B coder for best quality
|
| 148 |
+
python3 laravel-gen.py --model 7b "simple contact form - name, email, subject, message"
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
## Model Details
|
| 152 |
+
|
| 153 |
+
| Detail | Value |
|
| 154 |
+
|--------|-------|
|
| 155 |
+
| **Base model** | [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) (4-bit via MLX) |
|
| 156 |
+
| **Fine-tuning** | LoRA, 16 layers, batch=1, seq=768, mask-prompt |
|
| 157 |
+
| **Training data** | 139 instruction-to-code pairs from Laravel 13.x docs |
|
| 158 |
+
| **Training hardware** | Apple M2 Pro, 16GB RAM |
|
| 159 |
+
| **Training time** | ~5 minutes |
|
| 160 |
+
| **Peak memory** | 7.6 GB |
|
| 161 |
+
| **Best val loss** | 0.503 (iter 50) |
|
| 162 |
+
| **Trainable params** | 11.534M / 7,615.617M (0.151%) |
|
| 163 |
+
|
| 164 |
+
## Training Data
|
| 165 |
+
|
| 166 |
+
Dataset: [fchis/Laravel-13x-Code-Instructions](https://huggingface.co/datasets/fchis/Laravel-13x-Code-Instructions) (139 examples)
|
| 167 |
+
|
| 168 |
+
Covers: Eloquent models (with and without relationships), migrations (full class wrappers), Form Requests, controllers (short, with FormRequest injection), API Resources, routes, middleware, Blade templates, View Composers.
|
| 169 |
+
|
| 170 |
+
Key training data decisions:
|
| 171 |
+
- All migration examples have full `return new class extends Migration` wrapper (no bare Schema calls)
|
| 172 |
+
- Simple model examples WITHOUT relationships (prevents hallucinating unwanted belongsTo)
|
| 173 |
+
- Controller examples use FormRequest injection (not inline Validator)
|
| 174 |
+
- Attribute-based controller examples removed (toxic at small scale — caused hallucinated imports)
|
| 175 |
+
- 8 instruction-grounded model examples (exact field matching)
|
| 176 |
+
|
| 177 |
+
## Limitations
|
| 178 |
+
|
| 179 |
+
- **Works best with specific instructions** — list exact fields, relationships, methods
|
| 180 |
+
- **Vague instructions cause hallucination** — "fillable fields" without listing them triggers pretraining archetypes
|
| 181 |
+
- **Repetition loops on long outputs** — models/controllers >300 tokens may enter loops. Cap at 500-600 tokens.
|
| 182 |
+
- **139 training examples** — more data (500+) would improve instruction following
|
| 183 |
+
- **MLX format** — requires Apple Silicon Mac for inference
|
| 184 |
+
- **7B is slower** — ~12-14s per file vs ~1-2s for the 3B variant
|
| 185 |
+
|
| 186 |
+
### The Repetition Problem
|
| 187 |
+
|
| 188 |
+
Small models (3B-7B) can enter repetition loops on longer outputs. Root causes:
|
| 189 |
+
1. Vague instructions trigger pretraining archetypes (the model "remembers" generic patterns)
|
| 190 |
+
2. Autoregressive generation has no self-correction — once in a loop, it can't escape
|
| 191 |
+
|
| 192 |
+
Mitigations: specific instructions, max token caps, post-processing repetition detection.
|
| 193 |
+
|
| 194 |
+
## Also Tested: DoRA
|
| 195 |
+
|
| 196 |
+
DoRA (LoRA + magnitude decomposition) was tested but OOM'd at 16 layers on 7B (>10.5 GB). At 8 layers it ran but produced worse output than 16-layer LoRA. On 16GB Mac, **LoRA with more layers beats DoRA with fewer layers**.
|
| 197 |
+
|
| 198 |
+
## Companion Models
|
| 199 |
+
|
| 200 |
+
| Model | Params | Role | Link |
|
| 201 |
+
|-------|--------|------|------|
|
| 202 |
+
| Planner | 1.7B | Decompose features into tasks | [fchis/Laravel-13x-Planner-Qwen3-1.7B-LoRA](https://huggingface.co/fchis/Laravel-13x-Planner-Qwen3-1.7B-LoRA) |
|
| 203 |
+
| Coder (3B) | 3B | Generate code (faster, lighter) | [fchis/Laravel-13x-Qwen2.5-Coder-3B-Instruct-LoRA](https://huggingface.co/fchis/Laravel-13x-Qwen2.5-Coder-3B-Instruct-LoRA) |
|
| 204 |
+
| **Coder (7B)** | **7B** | **Generate code (best quality)** | **You're here** |
|
| 205 |
+
| CLI tool | — | End-to-end pipeline | [github.com/florinel-chis/laravel-ai-gen](https://github.com/florinel-chis/laravel-ai-gen) |
|
| 206 |
+
|
| 207 |
+
## Research Context
|
| 208 |
+
|
| 209 |
+
Built as part of a 21-step research investigation into local AI-assisted code generation on consumer hardware. Key discoveries:
|
| 210 |
+
|
| 211 |
+
- 90 instruction-to-code pairs beat 14,000 doc-Q&A pairs (training format > quantity)
|
| 212 |
+
- Fine-tuned 7B produces perfect code when given specific instructions
|
| 213 |
+
- The planner→coder two-model pipeline runs in ~4 GB total on any 8GB+ Mac
|
| 214 |
+
- GRPO is ineffective for this use case (failures are semantic, not syntactic)
|
| 215 |
+
- DoRA is better than LoRA per-layer but needs more memory — LoRA wins when memory-constrained
|
| 216 |
+
|
| 217 |
+
## License
|
| 218 |
+
|
| 219 |
+
Apache 2.0 (same as base model)
|