Downloads · 30 days
16
5% of all-time downloads
fchis/Laravel-13x-Llama-3.2-1B-Instruct-LoRA
Laravel-13x-Llama-3.2-1B-Instruct-LoRA is a text generation model from fchis. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as llama3.2.
A Llama 3.2 1B model fine-tuned on Laravel 13.x instruction-to-code pairs. Generates Laravel PHP code from natural language instructions.
Downloads · 30 days
16
5% of all-time downloads
All-time downloads
354
Public
Parameters
1.2B
712 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors695 MB · 98%
How the weights are stored.
U321.2B · 100%
From the Hugging Face model README
A Llama 3.2 1B model fine-tuned on Laravel 13.x instruction-to-code pairs. Generates Laravel PHP code from natural language instructions.
This is a companion model to fchis/Laravel-13x-Qwen2.5-Coder-3B-Instruct-LoRA, created as part of a research investigation comparing different base models and training data formats for framework-specific code generation.
Compared against yannelli/Laravel-11-Llama-3.2-1B (trained on 14K doc Q&A pairs) and base Qwen2.5-Coder-14B (no fine-tuning):
| Prompt | yannelli 1B (14K doc Q&A) | This model (90 code pairs) | Qwen 14B (no fine-tune) |
|---|---|---|---|
| Eloquent Model | 0/3 | 1/3 | 3/3 |
| Form Request | 0/3 | 2/3 | 3/3 |
| Middleware | 0/3 | 3/3 | 2/3 |
| Migration | 1/3 | 3/3 | 2/3 |
| Total | 1/12 | 9/12 | 10/12 |
| Detail | Value |
|---|---|
| Base model | meta-llama/Llama-3.2-1B-Instruct (4-bit via MLX) |
| Fine-tuning | LoRA, 16 target layers |
| Framework | Apple MLX (mlx-lm) |
| Hardware | Apple M2 Pro, 16GB RAM |
| Training time | ~4 minutes |
| Peak memory | 3.6 GB |
| Training data | 90 instruction-to-code pairs from Laravel 13.x docs |
| Best checkpoint | Iteration 200 (val loss 1.578) |
| Trainable params | 5.636M / 1,235.814M (0.456%) |
| Model size | 663 MB (fused safetensors) |
Dataset: fchis/Laravel-13x-Code-Instructions
90 instruction-to-code pairs from Laravel 13.x official documentation covering: Eloquent models, relationships, controllers, migrations, validation, Form Requests, middleware, views, Blade templates, View Composers, API Resources, routing, and HTTP Requests.
from mlx_lm import load, generate
model, tokenizer = load("fchis/Laravel-13x-Llama-3.2-1B-Instruct-LoRA")
messages = [
{"role": "system", "content": "You are a senior Laravel developer. Write clean, production-ready Laravel code."},
{"role": "user", "content": "Write a Laravel middleware that checks if the user has an active subscription and returns 403 JSON if not."}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response = generate(model, tokenizer, prompt=text, max_tokens=800)
print(response)
Prompt: "Write a Laravel middleware that checks if the authenticated user has an active subscription. If not, return a 403 JSON response."
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class EnsureUserIsSubscribed
{
public function handle(Request $request, Closure $next): Response
{
if (! $request->user()?->hasActiveSubscription()) {
return response()->json([
'message' => 'You do not have an active subscription.'
], 403);
}
return $next($request);
}
}
Prompt: "Write a migration for products table with slug, price, FK, soft deletes, timestamps."
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->unsignedInteger('price');
$table->text('description')->nullable();
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
$table->softDeletes();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('products');
}
};
Prompt: "Create a Form Request for storing a blog post with validation."
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreBlogPostRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'title' => ['required', 'string', 'max:255'],
'body' => ['required', 'string'],
'category_id' => ['required', 'string', 'must exist in categories table'],
'tags' => ['nullable', 'array'],
'tags.*' => ['exists:tags,id'],
'published_at' => ['nullable', 'date', 'after:now'],
];
}
}
Note: One error - 'must exist in categories table' should be 'exists:categories,id'
| Iteration | Train Loss | Val Loss |
|---|---|---|
| 1 | - | 3.111 |
| 50 | 1.389 | - |
| 100 | 0.729 | 1.647 |
| 150 | 0.383 | - |
| 200 | 0.162 | 1.578 |
| 300 | 0.022 | 1.671 |
| 500 | 0.001 | 1.719 |
Best checkpoint at iteration 200 (lowest validation loss). The model used the iteration 500 checkpoint for these results; iteration 200 would likely score slightly higher.
Both models trained on the same 90 examples:
| Aspect | This model (Llama 1B) | Qwen 3B companion |
|---|---|---|
| Base | General chat model | Code-specialized model |
| Size | 663 MB | 1.74 GB |
| Training peak | 3.6 GB | 5.0 GB |
| Score | 9/12 | 9/12 |
| Strengths | Perfect on simple tasks (middleware, migration) | Better on complex multi-concept tasks (model with casts + fillable) |
| Weaknesses | Struggles with multi-concept tasks | Slightly less precise on memorized patterns |
This model was part of a broader investigation. Key findings:
'must exist in categories table')