PHP code example of eloquage / embed

1. Go to this page and download the library: Download eloquage/embed 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/ */

    

eloquage / embed example snippets


use Eloquage\Embed\Embed;

$embed = new Embed();

echo $embed->name(); // embed

$record = $embed->record(
    id: 'manual-42',
    model: 'local/e5-base-v2',
    dimensions: 3,
    vector: [3, 4, 0],
    metadata: ['kind' => 'document'],
);

$normalized = $embed->normalize($record);
$chunked = $embed->withChunkMetadata($normalized, 'manual.md', 2, 100, 180);
$batch = $embed->batch([$chunked]);
$key = $embed->cacheKey('local/e5-base-v2', [
    'input' => 'A paragraph from the manual.',
    'dimensions' => 3,
]);
yaml
- uses: shivammathur/setup-php@v2
  with:
    php-version: '8.4'
    extensions: eloquage_embed
dockerfile
RUN docker-php-ext-configure /tmp/eloquage_embed \
 && docker-php-ext-install /tmp/eloquage_embed \
 && docker-php-ext-enable eloquage_embed
ini
extension=eloquage_embed