1. Go to this page and download the library: Download thakladd/vector-lite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Document::query()->whereVectorSimilarTo('embedding', $queryEmbedding, minSimilarity: 0.4);
Document::query()->whereVectorSimilarTo('embedding', 'best wineries in Napa Valley'); // auto-embeds the string
Document::query()
->select('*') // selectVectorDistance() is additive, like the AI SDK's - select('*') first to keep other columns
->selectVectorDistance('embedding', $queryEmbedding, as: 'distance')
->whereVectorDistanceLessThan('embedding', $queryEmbedding, maxDistance: 0.3)
->orderByVectorDistance('embedding', $queryEmbedding);
use ThaKladd\VectorLite\Embeddings;
use Illuminate\Support\Str;
$response = Embeddings::for(['Napa Valley has great wine.'])->cache(seconds: 3600)->generate();
$response->embeddings; // [[0.123, 0.456, ...]]
$embedding = Str::of('Napa Valley has great wine.')->toEmbeddings(cache: true);
use ThaKladd\VectorLite\Reranking;
$response = Reranking::of([$textA, $textB])->rerank('PHP frameworks');
$response->first()->document;
$response->first()->score;
$response->first()->index;
// Or on any collection:
$posts->rerank('body', 'Laravel tutorials');
use ThaKladd\VectorLite\Tools\SimilaritySearch;
$tool = SimilaritySearch::usingModel(Document::class, 'embedding', minSimilarity: 0.7, limit: 10);
$tool('best wineries in Napa Valley');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.