Pipelines reference - Retrievers

This section provides reference documentation for Pipelines Retrievers. It includes information on the functions and views available in the aidb extension related to Retrievers.

Tables

aidb.retrievers

The aidb.retrievers table stores information about the retrievers that have been created in the database.

ColumnTypeDescription
idinteger
nametext
vector_table_nametext
vector_table_key_columntext
vector_table_vector_columntext
model_nametext
topkinteger
distance_operatoraidb.distanceoperator
optionsjsonb
source_table_nameregclass
source_table_data_columntext
source_table_data_column_typeaidb.retriever_data_type
source_table_key_columntext

Functions

aidb.register_retriever_for_table

Registers a retriever for a given table.

Parameters

ParameterTypeDefaultDescription
p_nameTEXT
p_source_table_nameregclass
p_source_table_data_columnTEXT
p_source_table_data_column_typeaidb.RetrieverSourceDataFormat
p_source_table_key_columnTEXT'id'
p_vector_table_nameTEXTNULL
p_vector_table_vector_columnTEXT'embeddings'
p_vector_table_key_columnTEXT'id'
p_model_nameTEXTNULLMandatory argument since NULL is not allowed.
p_topkINTEGER1
p_distance_operatoraidb.distanceoperator'L2'
p_optionsJSONB'{}'::JSONB

Example

SELECT aidb.register_retriever_for_table(
               p_name => 'test_retriever',
               p_source_table_name => 'test_source_table',
               p_source_table_data_column => 'content',
               p_source_table_data_column_type => 'Text',
               p_model_name => 'simple_model'
       );

aidb.register_retriever_for_volume

Registers a retriever for a given PGFS volume.

Parameters

ParameterTypeDefaultDescription
p_nameTEXTName of the retriever.
p_source_volume_nameTEXTName of the volume.
p_vector_table_nameTEXTNULLName of the vector table.
p_vector_table_vector_columnTEXT'embeddings'Name of the vector column.
p_vector_table_key_columnTEXT'id'Name of the key column.
p_model_nameTEXTNULLName of the model.
p_topkINTEGER1Number of results to return.
p_distance_operatoraidb.distanceoperator'L2'Distance operator.
p_optionsJSONB'{}'::JSONBOptions.

Example

SELECT aidb.register_retriever_for_volume(
               p_name => 'demo_vol_retriever',
               p_source_volume_name => 'demo_bucket_vol',
               p_model_name => 'simple_model'
       );

aidb.enable_auto_embedding_for_table

Enables automatic embedding generation for a given table.

Parameters

ParameterTypeDefaultDescription
p_nameTEXTName of registered table which should have auto-embedding enabled.

Example

SELECT aidb.enable_auto_embedding_for_table('test_retriever');

aidb.disable_auto_embedding_for_table

Enables automatic embedding generation for a given table.

Parameters

ParameterTypeDefaultDescription
p_nameTEXTName of registered table which should have auto_embedding disabled.

Example

SELECT aidb.enable_auto_embedding_for_table('test_retriever');

aidb.bulk_embedding

Generates embeddings for all data in a given table if there is existing data in the table.

Parameters

ParameterTypeDefaultDescription
retriever_nameTEXTName of retriever which which should have embeddings generated.

Example

edb=# select aidb.bulk_embedding('test_retriever');
Output
INFO:  bulk_embedding_text found 3 rows in retriever test_retriever
 bulk_embedding
----------------

(1 row)

aidb.retrieve_key

Retrieves a key from matching embeddings without looking up the source data.

Parameters

ParameterTypeDefaultDescription
retriever_nameTEXTName of retriever which should be used for retrieval.
query_stringTEXTQuery string to be used for retrieval.
number_of_resultsINTEGER0Number of results to be returned.

Example

SELECT * FROM aidb.retrieve_key('test_retriever', 'shoes', 2);
Output
key  |      distance
-------+--------------------
 43941 | 0.2938963414490189
 19337 | 0.3023805122617119
(2 rows)

aidb.retrieve_text

Retrieves the source text data from matching embeddings by joining the embeddings with the source table.

Parameters

ParameterTypeDefaultDescription
retriever_nameTEXTName of retriever which should be used for retrieval.
query_stringTEXTQuery string to be used for retrieval.
number_of_resultsINTEGER0Number of results to be returned.

Returns

ColumnTypeDescription
keytextKey of the retrieved data.
valuetextValue of the retrieved data.
distancedouble precisionDistance of the retrieved data from the query.

Example

SELECT * FROM aidb.retrieve_text('test_retriever', 'jacket', 2);
Output
key  |                       value                        |      distance
-------+----------------------------------------------------+--------------------
 19337 | United Colors of Benetton Men Stripes Black Jacket | 0.2994317672742334
 55018 | Lakme 3 in 1 Orchid  Aqua Shine Lip Color          | 0.3804609668507203
(2 rows)

aidb.delete_retriever

Deletes only the retriever's configuration from the database.

Parameters

ParameterTypeDefaultDescription
retriever_nameTEXTName of retriever which should be deleted.

Example

select aidb.delete_retriever('test_retriever');
Output
 delete_retriever
------------------

(1 row)

Could this page be better? Report a problem or suggest an addition!