Pipelines models reference Innovation Release
- Hybrid Manager dual release strategy
- Documentation for the current Long-term support release
This reference documentation for EDB Postgres AI - AI Accelerator Pipelines models includes information on the functions and views available in the aidb extension for working with models.
Tables
aidb.model_providers
The aidb.model_providers table stores information about the model providers that are available.
| Column | Type | Description |
|---|---|---|
server_name | name | Name for the model server |
server_description | text | Description of the model server |
server_options | text[] | Options for the model server |
aidb.models
Returns a list of all models in the registry and their configured options, including predefined models and user-created models.
| Column | Type | Description |
|---|---|---|
name | text | User-defined name for the model |
provider | text | Name of the model provider |
options | jsonb | Optional configuration for the model provider |
Example
SELECT * FROM aidb.models;
name | provider | options
-------+------------+---------------
bert | bert_local | {"config={}"}
clip | clip_local | {"config={}"}
t5 | t5_local | {"config={}"}Functions
aidb.create_model
Creates a new model in the system by saving its name, provider, and optional configuration.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | text | User-defined name for the model. | |
provider | text | Name of the model provider (as found in aidb.model_providers). | |
config | jsonb | '{}'::jsonb | Optional configuration for the model provider. May include model-specific parameters such as model, url, and TLS options (e.g., tls_config). |
credentials | jsonb | '{}'::jsonb | Optional credentials for the model provider. |
replace_credentials | boolean | false | If true, replaces the credentials for the model provider. If false, the credentials aren't overwritten. |
Example
SELECT aidb.create_model( name => 'my_t5'::text, provider => 't5_local'::character varying, config => '{"param1": "value1", "param2": "value2"}'::jsonb, credentials => '{"token": "abcd"}'::jsonb );
or equivalently, using default values:
SELECT aidb.create_model('my_t5', 't5_local');
or if updating the credentials of a model's provider, which has already been created.
SELECT aidb.create_model( name => 'my_t5'::text, provider => 't5_local'::character varying, config => '{"param1": "value1", "param2": "value2"}'::jsonb, credentials => '{"token": "abcd"}'::jsonb, replace_credentials => true );
TLS Configuration (optional)
To securely connect to HTTPS-based model endpoints, the config object can include a tls_config field:
"tls_config": { "insecure_skip_verify": true, // (optional) disables certificate validation "ca_path": "/etc/aidb/myCA.pem" // (optional) path to a trusted CA certificate }
aidb.get_model
Returns the configuration for a model in the registry.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model |
Returns
| Column | Type | Description |
|---|---|---|
name | text | User-defined name for the model |
provider | text | Name of the model provider |
options | jsonb | Optional configuration for the model provider |
Example
SELECT * FROM aidb.get_model('t5');
name | provider | options
------+----------+---------------
t5 | t5_local | {"config={}"}
(1 row)aidb.delete_model
Deletes a model from the registry.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model |
Example
SELECT aidb.delete_model('t5');
delete_model
---------------------------------
(t5,t5_local,"{""config={}""}")
(1 row)Returns
| Column | Type | Description |
|---|---|---|
delete_model | jsonb | The name, provider, and options of the deleted model |
aidb.list_hcp_models
Gets models running on the Hybrid Manager.
Returns
| Column | Type | Description |
|---|---|---|
name | text | The name of the model instance running on the HCP (Hybrid Manager) |
url | text | The API URL of the model running on the HCP (Hybrid Manager) |
model | text | The name the model running on the HCP (Hybrid Manager) |
Example
SELECT * FROM aidb.get_hcp_models(); name | url | model ---------------------------------------+----------------------------------------------------------------------------------+------------------------------------ llama-3-1-8b-instruct-1xgpu-g6 | http://llama-3-1-8b-instruct-1xgpu-g6-predictor.default.svc.cluster.local | meta/llama-3.1-8b-instruct llama-3-2-nv-embedqa-1b-v2 | http://llama-3-2-nv-embedqa-1b-v2-predictor.default.svc.cluster.local | nvidia/llama-3.2-nv-embedqa-1b-v2 meta-nim-llama3-70b-instruct-8xgpu-g5 | http://meta-nim-llama3-70b-instruct-8xgpu-g5-predictor.default.svc.cluster.local | meta/llama3-70b-instruct (3 rows)
aidb.create_hcp_model
Creates a new model in the system by referencing a running instance in the HCP (Hybrid Manager)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | text | User-defined name of the model | |
hcp_model_name | text | Name of the model instance running on HCP (Hybrid Manager) |
aidb.sync_hcp_models
Creates models in the HCP (Hybrid Manager) and sets is_hcp_model=true; deletes models with that setting if not found in the HCP (Hybrid Manager).
Returns
| Column | Type | Description |
|---|---|---|
status | text | Synchronization status; either deleted, unchanged, created, or skipped. |
model | text | The name the synchronized HCP (Hybrid Manager) model. |
aidb.encode_text
Encodes text using a model, generating a vector representation of a given text input.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model to encode with | |
text | text | Text to encode |
aidb.encode_text_batch
Encodes a batch of text using a model, generating a vector representation of a given text input.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model to encode with | |
text | text[] | Array of text to encode |
aidb.decode_text
Decodes text using a model, generating a vector representation of a given text input.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model to decode with | |
text | text | Text to decode |
Returns
| Column | Type | Description |
|---|---|---|
decode_text | text | The decoded text |
aidb.decode_text_batch
Decodes a batch of text using a model, generating a representation of a given text input.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model to decode with | |
text | text[] | Array of text to decode |
Returns
| Column | Type | Description |
|---|---|---|
decode_text | text | The decoded text |
aidb.encode_image
Encodes an image using a model, generating a vector representation of a given image input.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model to encode with | |
image | bytea | Image to encode |
Returns
| Column | Type | Description |
|---|---|---|
encode_image | bytea | The encoded image |
aidb.rerank_text
Reranks text using a model, generating a vector representation of a given text input.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | text | Name of the model to rerank with | |
query | text | Query based on which the input will be ranked | |
input | text[] | [] | Inputs to be ranked |
Returns
| Column | Type | Description |
|---|---|---|
text | text | The text from "input" |
logit_score | double precision | Score/rank of this text |
id | int | index that the text had in the input array |
Model configuration helper functions
These helper functions simplify creating JSONB configuration objects for aidb.create_model(). They provide proper parameter types, defaults, and validation.
aidb.embeddings_config
Creates configuration for embeddings model providers (embeddings, openai_embeddings, nim_embeddings).
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
api_key | TEXT | NULL | API key (can use credentials instead) |
basic_auth | TEXT | NULL | Basic auth credentials |
url | TEXT | NULL | Custom API URL |
max_concurrent_requests | INTEGER | NULL | Maximum concurrent requests |
max_batch_size | INTEGER | NULL | Maximum batch size |
input_type | TEXT | NULL | Input type for the model |
input_type_query | TEXT | NULL | Input type for queries |
tls_config | JSONB | NULL | TLS configuration |
is_hcp_model | BOOLEAN | NULL | Whether this is an HCP (Hybrid Manager) model |
Example
SELECT aidb.create_model( 'my_model', 'openai_embeddings', aidb.embeddings_config(model => 'text-embedding-3-small'), '{"api_key": "sk-..."}'::JSONB );
aidb.completions_config
Creates configuration for completions model providers (completions, openai_completions, nim_completions).
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
api_key | TEXT | NULL | API key (can use credentials instead) |
basic_auth | TEXT | NULL | Basic auth credentials |
url | TEXT | NULL | Custom API URL |
max_concurrent_requests | INTEGER | NULL | Maximum concurrent requests |
max_tokens | JSONB | NULL | Max tokens config (use aidb.max_tokens_config()) |
is_hcp_model | BOOLEAN | NULL | Whether this is an HCP (Hybrid Manager) model |
Example
SELECT aidb.create_model( 'my_model', 'openai_completions', aidb.completions_config(model => 'gpt-4o'), '{"api_key": "sk-..."}'::JSONB );
aidb.max_tokens_config
Creates the max_tokens configuration for completions models.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
size | INTEGER | Required | Maximum number of tokens |
format | TEXT | NULL | Format: 'default', 'legacy', or 'both' |
Example
aidb.completions_config( model => 'gpt-4o', max_tokens => aidb.max_tokens_config(size => 1024, format => 'default') )
aidb.bert_config
Creates configuration for the bert_local model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
revision | TEXT | NULL | Model revision |
cache_dir | TEXT | NULL | Cache directory path |
aidb.clip_config
Creates configuration for the clip_local model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
revision | TEXT | NULL | Model revision |
cache_dir | TEXT | NULL | Cache directory path |
image_size | INTEGER | NULL | Image size |
aidb.llama_config
Creates configuration for the llama_instruct_local model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
revision | TEXT | NULL | Model revision |
cache_dir | TEXT | NULL | Cache directory path |
system_prompt | TEXT | NULL | System prompt |
use_flash_attention | BOOLEAN | NULL | Use flash attention |
model_path | TEXT | NULL | Local model path |
seed | BIGINT | NULL | Random seed |
temperature | DOUBLE PRECISION | NULL | Sampling temperature |
top_p | DOUBLE PRECISION | NULL | Top-p sampling |
sample_len | INTEGER | NULL | Max tokens to generate |
use_kv_cache | BOOLEAN | NULL | Use KV cache |
repeat_penalty | REAL | NULL | Repetition penalty |
repeat_last_n | INTEGER | NULL | Tokens for repetition penalty |
aidb.t5_config
Creates configuration for the t5_local model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
revision | TEXT | NULL | Model revision |
temperature | DOUBLE PRECISION | NULL | Sampling temperature |
seed | BIGINT | NULL | Random seed |
max_tokens | INTEGER | NULL | Max tokens to generate |
repeat_penalty | REAL | NULL | Repetition penalty |
repeat_last_n | INTEGER | NULL | Tokens for repetition penalty |
model_path | TEXT | NULL | Local model path |
cache_dir | TEXT | NULL | Cache directory path |
aidb.gemini_config
Creates configuration for the gemini model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | TEXT | Required | The Gemini API key |
model | TEXT | NULL | The model identifier |
url | TEXT | NULL | Custom API URL |
max_concurrent_requests | INTEGER | NULL | Maximum concurrent requests |
thinking_budget | INTEGER | NULL | Thinking tokens budget |
aidb.nim_clip_config
Creates configuration for the nim_clip model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | TEXT | NULL | API key (can use credentials) |
basic_auth | TEXT | NULL | Basic auth credentials |
model | TEXT | NULL | The model identifier |
url | TEXT | NULL | Custom API URL |
is_hcp_model | BOOLEAN | NULL | Whether this is an HCP (Hybrid Manager) model |
aidb.nim_ocr_config
Creates configuration for the nim_paddle_ocr model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | TEXT | NULL | API key (can use credentials) |
basic_auth | TEXT | NULL | Basic auth credentials |
url | TEXT | NULL | Custom API URL |
model | TEXT | NULL | The model identifier |
is_hcp_model | BOOLEAN | NULL | Whether this is an HCP (Hybrid Manager) model |
aidb.nim_reranking_config
Creates configuration for the nim_reranking model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | TEXT | NULL | API key (can use credentials) |
basic_auth | TEXT | NULL | Basic auth credentials |
model | TEXT | NULL | The model identifier |
url | TEXT | NULL | Custom API URL |
is_hcp_model | BOOLEAN | NULL | Whether this is an HCP (Hybrid Manager) model |
aidb.openrouter_chat_config
Creates configuration for the openrouter_chat model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
api_key | TEXT | NULL | API key (can use credentials instead) |
url | TEXT | NULL | Custom API URL |
max_concurrent_requests | INTEGER | NULL | Maximum concurrent requests |
max_tokens | JSONB | NULL | Max tokens config (use aidb.max_tokens_config()) |
aidb.openrouter_embeddings_config
Creates configuration for the openrouter_embeddings model provider.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | TEXT | Required | The model identifier |
api_key | TEXT | NULL | API key (can use credentials instead) |
url | TEXT | NULL | Custom API URL |
max_concurrent_requests | INTEGER | NULL | Maximum concurrent requests |
max_batch_size | INTEGER | NULL | Maximum batch size |