AI_GENERATE_EMBEDDINGS

Generate an embedding vector per row via a registered embeddings model.

Category: aiReturns: List<Float32>Dialect: DeltaForgeDeltaForge extension

Syntax

AI_GENERATE_EMBEDDINGS(model_name, text)
AI_GENERATE_EMBEDDINGS(text USE MODEL model_name)

Description

## Overview AI_GENERATE_EMBEDDINGS returns the embedding vector the provider computes for each row's text. Inputs are deduplicated within a batch and sent to the provider in native batches (up to 96 texts per request), which is dramatically cheaper and faster than one request per row. ## Return shape List<Float32>, not a fixed-size VECTOR: the dimension is a provider/model fact unknown at plan time (the same rationale as the local embed() function). Wrap the call in array_to_vector(...) to store a fixed-dim VECTOR column ready for CREATE INDEX ... USING HNSW and the vector distance functions. ## Relationship to embed() embed(model, text) runs a LOCAL embedding backend inside the engine process; AI_GENERATE_EMBEDDINGS calls a REMOTE provider endpoint registered via CREATE MODEL. Same output shape, different execution locus: pick embed() for offline/local models and AI_GENERATE_EMBEDDINGS for hosted providers.

Parameters

NameTypeDescription
model_nameThe registry name of a MODEL_TYPE = EMBEDDINGS model (see CREATE MODEL). Must be constant within a query.
textThe text to embed. NULL inputs produce NULL output without calling the provider.

Examples

-- Embed document chunks for RAG indexing
SELECT chunk_id, AI_GENERATE_EMBEDDINGS('embedder', chunk_text) AS embedding
FROM docs.silver.chunks;
-- Fixed-dim VECTOR for the HNSW index: wrap with array_to_vector
CREATE TABLE docs.gold.chunk_vectors AS
SELECT chunk_id,
       array_to_vector(AI_GENERATE_EMBEDDINGS('embedder', chunk_text)) AS embedding
FROM docs.silver.chunks;
-- USE MODEL sugar
SELECT AI_GENERATE_EMBEDDINGS(chunk_text USE MODEL embedder) FROM docs.silver.chunks;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →