Programowanie · Budowanie i kod
laravel-vector-search
/laravel-vector-search
Wdraża wyszukiwanie semantyczne i wektorowe w Laravel 13 z użyciem PostgreSQL i pgvector.
- Autor
- fusengine ↗
- Repozytorium
- agents ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 12.10.2026
Ocena i bezpieczeństwo
100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
- Pliki w paczce
- 6
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Przestarzałość
Brak sygnałów. Repozytorium zmienione 12.10.2026, bez odwołań do wycofanych modeli i API.
Licencja
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Wdraża wyszukiwanie semantyczne i wektorowe w Laravel 13 z użyciem PostgreSQL i pgvector.
Oryginalny opis (EN)
Use when implementing semantic/vector search in Laravel 13 with PostgreSQL + pgvector.
Jak działa
- Agent Workflow (MANDATORY)
- Overview
- Critical Rules
- Architecture
- Reference Guide
- Quick Reference
- Best Practices
Sekcje z nagłówków SKILL.md, w oryginale · 125 linii, 575 słów
Podgląd SKILL.md
---
name: laravel-vector-search
description: Use when implementing semantic/vector search in Laravel 13 with PostgreSQL + pgvector.
versions:
laravel: "13.0"
php: "8.3"
postgresql: "16+"
pgvector: "0.7+"
user-invocable: true
references: references/pgvector-setup.md, references/embeddings-workflow.md, references/queries.md, references/templates/Document-model.php.md, references/templates/VectorSearchService.php.md
related-skills: laravel-ai-sdk, laravel-eloquent, laravel-migrations
---
<objective>
Covers Laravel 13 vector/semantic search on PostgreSQL with the pgvector
extension: enabling the extension via Schema::ensureVectorExtensionExists(),
the vector column type and HNSW/IVFFlat indexing, the embedding generation
and persistence workflow, and the query builder's vector methods
(whereVectorSimilarTo, selectVectorDistance, whereVectorDistanceLessThan,
orderByVectorDistance). PostgreSQL (pgvector) or MariaDB 11.7+ (13.27+) —
no MySQL/SQLite fallback. For
full-text/keyword search, see laravel-scout instead (the two can be
combined for hybrid search).
</objective>
# Laravel 13 Vector Search (pgvector)
## Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one `Agent` call each with a `name`:
1. **fuse-ai-pilot:explore-codebase** - Check current DB driver (must be PostgreSQL) and existing embedding columns
2. **fuse-ai-pilot:research-expert** - Verify pgvector extension version and HNSW vs IVFFlat tradeoffs
3. **mcp__context7__query-docs** - Pull `laravel.com/docs/13.x/search` + `queries` examples
After implementation, run **fuse-ai-pilot:sniper** for validation.
---
## Overview
| Feature | Description |
|---------|-------------|
| **PostgreSQL / MariaDB** | PostgreSQL + `pgvector`, or MariaDB 11.7+ (vector queries since 13.27); not available on MySQL/SQLite |
| **Schema helper** | `Schema::ensureVectorExtensionExists()` enables the extension |
| **Query builder** | `whereVectorSimilarTo()`, `selectVectorDistance()`, `whereVectorDistanceLessThan()`, `orderByVectorDistance()` |
| **Auto-embedding** | Pass a raw string and Laravel generates the embedding via AI SDK |
| **Cosine similarity** | Default distance; threshold via `minSimilarity` (0.0 - 1.0) |
---
## Critical Rules
1. **Use PostgreSQL (pgvector) or MariaDB 11.7+** - Vector clauses do not work on MySQL/SQLite - no fallback
2. **Create an HNSW index** - Without an index, queries do full table scans; > 10k rows means seconds-to-minutes latency
3. **Match dimensions exactly** - Insert-time and query-time embedding models MUST share the same dimensions
4. **Cache embeddings** - Regenerating embeddings on every request is the #1 cost driver; persist them
5. **Lock the embedding model** - Changing the model invalidates ALL stored embeddings; treat the model as a schema field
---
## Architecture
```
database/migrations/
└── XXXX_create_documents_table.php # Schema::ensureVectorExtensionExists(), vector(1536) col, HNSW index
app/Models/
└── Document.php # casts embedding to array, uses whereVectorSimilarTo
app/Ai/Services/
└── VectorSearchService.php # encapsulates query + threshold logic
```
→ See [Document-model.php.md](references/templates/Document-model.php.md) for full example
---
## Reference Guide
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| **pgvector setup** | [pgvector-setup.md](references/pgvector-setup.md) | Migrations + index creation |
| **Embedding workflow** | [embeddings-workflow.md](references/embeddings-workflow.md) | Generating + persisting vectors |
| **Query patterns** | [queries.md](references/queries.md) | `whereVectorSimilarTo` and friends |
### Templates
| Template | When to Use |
|----------|-------------|
| [Document-model.php.md](references/templates/Document-model.php.md) | Eloquent model with vector column |
| [VectorSearchService.php.md](references/templates/VectorSearchService.php.md) | Reusable service |
---
## Quick Reference
### Migration
```php
Schema::ensureVectorExtensionExists();
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->text('content');
$table->vector('embedding', dimensions: 1536)->index(); // HNSW cosine index
$table->timestamps();
});
```
### Query
```php
$documents = Document::query()
->whereVectorSimilarTo('embedding', 'best wineries in Napa Valley', minSimilarity: 0.4)
->limit(10)
->get();
```
→ See [VectorSearchService.php.md](references/templates/VectorSearchService.php.md) for complete example
---
## Best Practices
### DO
- Create an HNSW index BEFORE inserting bulk data - faster total ingest
- Store the embedding model name alongside the vector to detect drift
- Use `minSimilarity` 0.3-0.5 as a starting threshold; tune empirically
- Combine vector search with classic `where()` for hybrid filtering (date ranges, tenancy)
### DON'T
- Don't run vector queries without an index past a few thousand rows - it becomes a full table scan
- Don't mix embedding models in the same column - distances become meaningless
- Don't generate query embeddings inside loops - batch them via `Embeddings::for([...])`
- Don't store embeddings as JSON strings - use the native `vector` column type for index support
Pliki w paczce (6)
- SKILL.md 5 KB
- references/embeddings-workflow.md 2 KB
- references/pgvector-setup.md 3 KB
- references/queries.md 3 KB
- references/templates/Document-model.php.md 2 KB
- references/templates/VectorSearchService.php.md 3 KB
Wersje
W bazie nie ma innych skilli o nazwie laravel-vector-search.
Migawka bazy z 28.10.2026 · wersja paczki 1fdbc0665f9d (skrót SHA-256 całej paczki)
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100mariadb-laravel-vector
Pokazuje użycie MariaDB Vector w aplikacji Laravel: kolumny wektorowe, VECTOR INDEX, rzutowanie AsVector w Eloquent i wyszukiwanie podobieństwa przez query builder. - 100mariadb-laravel-ai-sdk
Wykorzystuje MariaDB Vector jako magazyn dla Laravel AI SDK: generuje embeddingi, zapisuje je w kolumnie wektorowej i buduje wyszukiwanie semantyczne oraz narzędzie podobieństwa dla agenta. - 100pgvector
Obsługuje pgvector, rozszerzenie PostgreSQL przechowujące embeddingi w zwykłych tabelach i wyszukujące je po podobieństwie: kolumny wektorowe, indeksy, filtrowanie, Node.js i Drizzle. - 98vector-search-patterns
Wdraża wyszukiwanie wektorowe: generowanie embeddingów, dobór indeksu i wyszukiwanie hybrydowe w ChromaDB, pgvector i FAISS oraz projekt potoku RAG. - 100laravel-auth
Pomaga wdrożyć uwierzytelnianie użytkowników, tokeny API, logowanie społecznościowe i autoryzację w Laravel 13. - 95azure-search-documents-py
Obsługuje SDK Azure AI Search dla Pythona: wyszukiwanie wektorowe i hybrydowe, rankowanie semantyczne, indeksowanie i skillsety.