Tanstack Start
Exploration Projects

RAG-Laravel

A local Retrieval-Augmented Generation stack built on Laravel Sail, pgvector and Ollama

Description

A Laravel Sail project extended with two extra services on top of the default stack: a pgvector-enabled PostgreSQL image for storing embeddings, and an Ollama service for running local LLMs and embedding models. The goal was to explore building a Retrieval-Augmented Generation pipeline entirely with local, self-hosted tooling instead of external APIs.

Stack

CategoryDetail
BackendLaravel, Laravel Sail
Vector storePostgreSQL with the pgvector extension
LLM runtimeOllama (llama3.2:3b for generation, nomic-embed-text for embeddings)
ToolingDocker Compose, Composer, pnpm

What I learned

  • Extending a Sail compose.yaml with extra services (pgvector, Ollama)
  • Docker networking: using service names (pgsql, ollama) instead of localhost for inter-container calls
  • Enabling the vector Postgres extension via a Laravel migration
  • Calling the Ollama HTTP API directly for text generation and embeddings
  • Benchmarking local LLM generation and embedding latency

LLM Performance Metrics

Benchmarks captured against the local Ollama instance:

Generation (llama3.2:3b)

MetricValue
Total duration655.19 ms
Load duration3.10 ms
Prompt eval duration83.24 ms
Prompt eval count32 tokens
Eval duration567.11 ms
Eval count8 tokens

Embedding (nomic-embed-text)

MetricValue
Elapsed time13.45 ms
Vector length768

Repository

On this page