Top
Enterprise Postgres 18 Knowledge DataManagement FeatureUser's Guide

5.3.1 Model Import

Import the model into the database.

Import the model file on the client.

pgx_aimodel_tool import -f ./model.onnx -n sample-model-v1 -F embedding -m '{"version":"v1"}' -d rag_db -h localhost -p 27500 -U model_owner

Check the imported model

SELECT * FROM pgx_inference.pgx_list_model_metadata();
id |      name         |   function    |         metadata           | model_file_oid | file_size   | owner |          
---+-----------------+--------------+-------------------------+----------------+------------+------|
1  | sample-model-v1 | embedding    | {"metadata": "sample1"} |       16767    |90000000  | 16329| 
2  | sample-model-v2 | embedding    | {"metadata": "sample2"} |       16782    |60000000  | 16330|

(1 row)

SELECT * FROM pgx_inference.pgx_get_model_metadata('sample-model-v1');
id |      name         |   function    |         metadata           | model_file_oid | file_size   | owner |          
---+-----------------+--------------+-------------------------+----------------+------------+------|
1  | sample-model-v1 | embedding    | {"metadata": "sample1"} |       16767    |90000000  | 16329|

(1 row)

Example) When an existing model name is specified as an argument

pgx_aimodel_tool import -f ./model.onnx -n sample-model-v1 -F embedding -m '{"version":"v1"}' -d rag_db -h localhost -p 27500 -U model_owner
pgx_aimodel_tool: error: query failed: ERROR:  model "sample-model-v1" already exist
HINT:  To overwrite the existing model, specify the "--update-on-conflict" option.

Example) When overwriting an imported model with the same name

pgx_aimodel_tool import -f ./model.onnx -n sample-model-v1 -F embedding -m '{"version":"v1"}' --update-on-conflict -d rag_db -h localhost -p 27500 -U model_owner
pgx_aimodel_tool: model "sample-model-v1" import completed