Skip to content

Commit 1471edd

Browse files
authored
Support auto-embedding (mongodb#3531)
Introduces support for automated embedding. This enables the user to store and update vector embeddings automatically for specified fields, instead of having to manage an embedding pipeline. See: https://www.mongodb.com/docs/vector-search/crud-embeddings/automated-embedding/
1 parent d83f1c4 commit 1471edd

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/Schema/Blueprint.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@
108108
* indexingMethod?: 'flat'|'hnsw',
109109
* hnswOptions?: array{maxEdges?: int, numEdgeCandidates?: int},
110110
* } | array{
111+
* type: 'autoEmbed',
112+
* modality: 'text',
113+
* path: string,
114+
* model: string,
115+
* numDimensions?: int,
116+
* quantization?: 'float'|'scalar'|'binary'|'binaryNoRescore',
117+
* similarity?: 'euclidean'|'cosine'|'dotProduct',
118+
* indexingMethod?: 'flat'|'hnsw',
119+
* hnswOptions?: array{maxEdges?: int, numEdgeCandidates?: int},
120+
* } | array{
111121
* type: 'filter',
112122
* path: string,
113123
* }

tests/PHPStan/SearchIndexTypes.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,40 @@ public static function vectorSearchIndexExamples(): void
229229
['type' => 'filter', 'path' => 'genres'],
230230
],
231231
]);
232+
233+
// autoEmbed - minimal definition
234+
// Source: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#automated-embedding
235+
self::assertVectorSearchIndexDefinition([
236+
'fields' => [
237+
[
238+
'type' => 'autoEmbed',
239+
'modality' => 'text',
240+
'path' => 'description',
241+
'model' => 'voyage-4',
242+
],
243+
],
244+
]);
245+
246+
// autoEmbed - with optional tuning parameters
247+
// Source: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#automated-embedding
248+
self::assertVectorSearchIndexDefinition([
249+
'fields' => [
250+
[
251+
'type' => 'autoEmbed',
252+
'modality' => 'text',
253+
'path' => 'description',
254+
'model' => 'voyage-4-large',
255+
'numDimensions' => 1024,
256+
'quantization' => 'scalar',
257+
'similarity' => 'dotProduct',
258+
'indexingMethod' => 'hnsw',
259+
'hnswOptions' => [
260+
'maxEdges' => 32,
261+
'numEdgeCandidates' => 200,
262+
],
263+
],
264+
['type' => 'filter', 'path' => 'genres'],
265+
],
266+
]);
232267
}
233268
}

0 commit comments

Comments
 (0)