Pipelines knowledge bases reference
This reference documentation for Pipelines knowledge bases includes information on the functions and views available in the aidb extension related to knowledge bases.
Views
aidb.knowledge_bases
Also referenceable as aidb.kbs
, the aidb.knowledge_bases
view provides a list of all knowledge bases in the database. It includes information about the knowledge base name, the model used, and the source data type.
Column | Type | Description |
---|---|---|
id | integer | |
name | text | Name of the knowledge base. |
vector_schema | text | Schema for vector_table. |
vector_table | text | Name of the table where the embeddings are stored. Gets newly created if it doesn’t exist. Managed by aidb. |
vector_key_column | text | Column to use to store the key that references the key in source data when computing embeddings. We recommend using the default and letting aidb manage this table. |
vector_data_column | text | Column to store embeddings in. We recommend using the default and letting aidb manage this table. |
model_name | text | Name of the model to use for embedding computation and retrievals. |
topk | integer | Default number of results to return during a retrieve. Similar to LIMIT in SQL. |
distance_operator | aidb.DistanceOperator | During retrieval, the vector operation to use to compare the vectors. |
options | jsonb | Unused. |
auto_processing | aidb.PipelineAutoProcessingMode | Auto-processing mode. |
owner_role | text | The Postgres role who created this pipeline. Background auto-processing will run the pipeline as this role. |
batch_size | integer | How many records to process concurrently when running this pipeline. |
background_sync_interval | interval | Used for background auto-processing. This is the interval between pipeline executions. |
source_type | text | Indicates whether this pipeline uses a table or volume as data source. |
source_schema | text | Schema for source_table. |
source_table | text | Name of the table used as input for the pipeline. Unused if the knowledge base uses a volume as source. |
source_data_column | text | Column name in the source table that Pipelines computes embeddings for. This is also the column that's returned in retrieve operations. |
source_data_format | aidb.PipelineDataFormat | Format of the data the knowledge base is working with. Uses type aidb.PipelineDataFormat . |
source_key_column | text | Column to use as key for storing the embedding in the vector table. This provides a reference from the embedding to the source data. |
source_volume_name | text | Name of the volume to use as a data source. Only applicable to knowledge bases configured with aidb.create_volume_knowledge_base(). |
aidb.knowledge_base_stats
Also referenceable as aidb.kbstat
, the aidb.knowledge_base_stats
view provides current statistics about auto processing for knowledge base pipelines.
Column | Type | Description |
---|---|---|
knowledge base | text | Name of the knowledge base. |
auto processing | aidb.PipelineAutoProcessingMode | Auto-processing mode. |
table: unprocessed rows | bigint | For table knowledge bases: The number of unprocessed rows that are new or might have changed since the last execution. |
volume: scans completed | bigint | For volume knowledge bases: The number of full listings of the source volume that were performed so far. |
count(source records) | bigint | The number of records in the source of the knowledge base. For volume knowledge bases, this is number of records seen during the last full scan. |
count(embeddings) | bigint | The number of embeddings stored in the destination table. |
Types
aidb.DistanceOperator
The aidb.DistanceOperator
type is an enum that represents the distance operators that can be used during retrieval.
Value | Description |
---|---|
L2 | Euclidean distance |
Inner | Inner product |
Cosine | Cosine similarity |
L1 | L1 distance |
Hamming | Hamming distance |
Jaccard | Jaccard distance |
SQL definition:
CREATE TYPE DistanceOperator AS ENUM ( 'L2', 'InnerProduct', 'Cosine', 'L1', 'Hamming', 'Jaccard' );
aidb.PipelineDataFormat
The aidb.PipelineDataFormat
type is an enum that represents the data formats that can be used as source data.
Value | Description |
---|---|
Text | Text data |
Image | Image data |
PDF data |
SQL definition:
CREATE TYPE PipelineDataFormat AS ENUM ( 'Text', 'Image', 'Pdf' );
aidb.PipelineAutoProcessingMode
The aidb.PipelineAutoProcessingMode
type is an enum used to define how auto processing for a Pipeline shoud behave (e.g. a knowledge base or a Preparer).
Value | Description |
---|---|
Live | New data is processed immediately while being added (using Postgres Triggers) |
Background | Continuous processing in the background (using Postgres background workers) |
Disabled | No automated processing |
CREATE TYPE PipelineAutoProcessingMode AS ENUM ( 'Live', 'Background', 'Disabled' );
Functions
aidb.create_table_knowledge_base
Creates a knowledge base for a given table.
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
name | TEXT | Required | Name of the knowledge base. |
model_name | TEXT | Required | Name of the model to use. |
source_table | regclass | Required | Name of the table to use as source. |
source_data_column | TEXT | Required | Column name in source table to use. |
source_data_format | aidb.PipelineDataFormat | Required | Format of data in that column ("Text", "Image", "PDF"). |
source_key_column | TEXT | 'id' | Unique column in the source table to use as key to reference the rows. |
vector_table | TEXT | NULL | |
vector_data_column | TEXT | 'embeddings' | |
vector_key_column | TEXT | 'id' | |
topk | INTEGER | 1 | |
distance_operator | aidb.distanceoperator | 'L2' | |
options | JSONB | '{}'::JSONB | Unused |
auto_processing | aidb.PipelineAutoProcessingMode | 'Disabled' | Configure auto-processing for this pipeline. |
index_type | TEXT | 'vector' | Type of index to use for the vector table. |
batch_size | int | 100 | How many records to process concurrently. |
background_sync_interval | interval | '30 seconds' | Interval between pipeline executions if background auto-processing is configured. |
Index_types
If
index_type
is set tovector
, the system will automatically create a hnsw index on the vector table based on the distance operator used in the knowledge base. This is the default index type. Thevector
index type is only able to support 2000 dimensions or less. If more dimensions are needed, the index type should be set todisabled
.distance_operator index_type L2 vector_l2_ops
InnerProduct vector_ip_ops
Cosine vector_cosine_ops
L1 vector_l1_ops
If
index_type
is set toivfflat
, the system will create a IVFFlat index on the vector table.If
index_type
is set todisabled
, no index will be created.