Top
Enterprise Postgres 18 Knowledge DataManagement FeatureUser's Guide

5.3.3 Definition of Vectorization

To define vectorization using a model imported into the database, use the pgx_vectorizer.pgx_embedding_onnx function. In this example, vectorization is defined for the text format knowledge data table "sample_table".

SELECT pgx_vectorizer.pgx_create_vectorizer(
'sample_table'::regclass,
destination => 'sample_embeddings',
embedding => pgx_vectorizer.pgx_embedding_onnx('sample-model-v1',384),
chunking => ai.chunking_recursive_character_text_splitter('contents'),
processing => ai.processing_default(batch_size => 200, concurrency => 1),
scheduling => pgx_vectorizer.schedule_vectorizer(interval '1 hour'),
indexing => ai.indexing_hnsw(min_rows =>50000, opclass => 'vector_cosine_ops'),
);