Laravel 13.x Qwen2.5-Coder-3B-Instruct LoRA

A code-specialized Qwen2.5-Coder-3B model fine-tuned on Laravel 13.x instruction-to-code pairs. Generates production-ready Laravel PHP code from natural language instructions.

Designed to work with fchis/Laravel-13x-Planner-Qwen3-1.7B-LoRA as a two-model pipeline, or standalone with specific instructions.

Key Finding: Specific Instructions = Perfect Output

When given specific, single-file instructions, this model produces near-perfect code:

Instruction Output quality PHP valid
"Create model for Contact with fillable: name, email, subject, message" Perfect — exact 4 fields, no extras Yes
"Write migration to create contacts table with name, email, subject, message" Perfect — full class wrapper, correct types Yes
"Create Form Request with validation: name, email, subject, message" Perfect — correct rules Yes
"Write ContactController with store using StoreContactRequest, return 201" Near-perfect — correct FormRequest injection Yes

When instructions are vague, quality drops. The model works best as the second stage of a planner→coder pipeline where the planner provides specific instructions.

Limitations (Honest Assessment)

After testing on real Laravel projects:

  • Works well for: Migrations, Models (simple), Form Requests, short Controllers
  • Struggles with: Long controllers (>30 lines), complex multi-concept models
  • Known issues:
    • Occasionally adds prose before <?php (post-processing strips this)
    • May add unwanted relationships if instruction is vague
    • May hallucinate fields not in the instruction if instruction doesn't list them explicitly
    • Controllers can enter repetition loops on longer outputs — cap at 600 tokens
    • 139 training examples is not enough to fully override base model patterns — 500+ would be better

Model Details

Detail Value
Base model Qwen2.5-Coder-3B-Instruct (4-bit via MLX)
Fine-tuning LoRA, 16 layers, mask-prompt
Training data 139 instruction-to-code pairs (v5)
Training time ~5 minutes on Apple M2 Pro 16GB
Peak memory 5.8 GB
Best val loss 0.344 (iter 200)

Training Data Composition (v5)

  • 8 simple models WITHOUT relationships (fixes over-generation)
  • 8 instruction-grounded models (exact field matching)
  • 10+ short controllers using FormRequest injection
  • 4 full migration examples with class wrappers (all bare Schema examples removed)
  • 3 route file examples
  • No attribute-based controller examples (removed — toxic at 3B scale)

Usage

from mlx_lm import load, generate

model, tok = load("fchis/Laravel-13x-Qwen2.5-Coder-3B-Instruct-LoRA")

messages = [
    {"role": "system", "content": "You are a senior Laravel developer. Write clean, production-ready Laravel code."},
    {"role": "user", "content": "Create a Laravel Eloquent model for Contact with fillable fields: name, email, subject, message."}
]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response = generate(model, tok, prompt=text, max_tokens=500)
print(response)

Best Practices

  1. Be specific in instructions — list exact fields, relationships, methods
  2. One file per instruction — don't ask for migration + model in one prompt
  3. Cap max_tokens: migrations=500, models=500, controllers=600
  4. Post-process: strip text before <?php, detect repetition loops

Companion Models

Model Role Link
Planner Decompose features into instructions fchis/Laravel-13x-Planner-Qwen3-1.7B-LoRA
This model Generate code per instruction You're here
CLI tool End-to-end pipeline github.com/florinel-chis/laravel-ai-code-generator
Downloads last month
183
Safetensors
Model size
0.5B params
Tensor type
F16
·
U32
·
MLX
Hardware compatibility
Log In to add your hardware

4-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for fchis/Laravel-13x-Qwen2.5-Coder-3B-Instruct-LoRA

Base model

Qwen/Qwen2.5-3B
Adapter
(24)
this model

Dataset used to train fchis/Laravel-13x-Qwen2.5-Coder-3B-Instruct-LoRA