Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

markc's avatar
Level 4

LLM for Laravel dev

Has anyone got a suggestion for the best local Ollama LLM for Laravel development?

At the rate that Anthropic is ripping me off I may as well invest in some half decent hardware and massage a local LLM with my own projects instead of having to start a new chat and lose context all the time.

0 likes
1 reply
LaryAI's avatar
Level 58

To set up a local Large Language Model (LLM) for Laravel development, you can consider using open-source models that can be fine-tuned on your own hardware. Here are some steps and suggestions to get you started:

  1. Choose a Suitable LLM:

    • Consider using models like GPT-Neo or GPT-J from EleutherAI, or LLaMA from Meta, which are open-source and can be run locally.
    • These models can be fine-tuned with your own data to better suit your Laravel development needs.
  2. Set Up Your Environment:

    • Ensure you have a machine with a decent GPU to handle the model's requirements. A modern NVIDIA GPU with CUDA support is recommended.
    • Install necessary libraries such as PyTorch or TensorFlow, depending on the model you choose.
  3. Download and Install the Model:

    • You can download pre-trained models from Hugging Face's Model Hub or directly from the model's repository.
    • For example, to use GPT-J, you can use the transformers library from Hugging Face:
    pip install transformers
    
  4. Fine-Tune the Model:

    • Collect a dataset that includes Laravel code snippets, documentation, and any other relevant material.
    • Use the transformers library to fine-tune the model on your dataset. Here's a basic example of how you might start:
    from transformers import GPT2LMHeadModel, GPT2Tokenizer, Trainer, TrainingArguments
    
    # Load pre-trained model and tokenizer
    model = GPT2LMHeadModel.from_pretrained("gpt2")
    tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
    
    # Prepare your dataset
    # Assume `train_dataset` is a PyTorch Dataset object with your Laravel data
    
    # Set up training arguments
    training_args = TrainingArguments(
        output_dir="./results",
        num_train_epochs=3,
        per_device_train_batch_size=2,
        save_steps=10_000,
        save_total_limit=2,
    )
    
    # Initialize Trainer
    trainer = Trainer(
        model=model,
        args=training_args,
        train_dataset=train_dataset,
    )
    
    # Train the model
    trainer.train()
    
  5. Deploy Locally:

    • Once fine-tuned, you can deploy the model locally using a simple Flask or FastAPI application to interact with it via a web interface or API.
  6. Integrate with Your Workflow:

    • Use the model to assist with code generation, documentation, or even as a smart code search tool within your Laravel projects.

By setting up a local LLM, you can have more control over the model's behavior and reduce dependency on external services, potentially saving costs in the long run.

Please or to participate in this conversation.