AI pipelines#
Pipelines can ingest, prepare and vectorize data for semantic retrieval and RAG applications. They integrate pgvector iterative index scans search capabilities and can keep the knowledge base synchronized with your source data automatically.
Example: a knowledge base for RAG#
This walkthrough builds a knowledge base over internal support articles and shows each retrieval stage independently. For the complete version, see End-to-end example: Knowledge base for RAG , which adds model registration, a reranking demo where the cross-encoder corrects a wrong vector-search result, and a single statement that retrieves, reranks, and generates an answer with verified output.
Set up the pipeline#
The source is a support_articles table holding 16 short articles
about database operations — take the CREATE TABLE and INSERT
statements from the full example’s source data step . The pipeline embeds
each article body with bge-small-en-v1.5-f16 , one of the built-in
llama.cpp embedding models — pre-registered, runs locally, and its model
file downloads automatically on first use:
SELECT aidb.create_pipeline(
name => support_kb,
source => support_articles,
source_key_column => id,
source_data_column => body,
step_1 => KnowledgeBase,
step_1_options => aidb.knowledge_base_config(
model => bge-small-en-v1.5-f16,
data_format => Text
),
auto_processing => Disabled
);
Run the pipeline#
With auto_processing => 'Disabled' , nothing runs until you say so.
Process all existing rows once:
SELECT aidb.run_pipeline(support_kb);
Retrieve: semantic search#
Every article body is now embedded and indexed. Paste raw error text into a semantic search — the top match is the resolution, found by meaning rather than keywords:
``sql SELECT key, value, distance::numeric(5,3) AS distance FROM aidb.retrieve_text('support_kb', 'application logs show: FATAL: sorry, too many clients already', 3); __OUTPUT__ key | value | distance -----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
# AI pipelines`
Available step types: ChunkText, ParseHtml, ParsePdf, PerformOcr, SummarizeText, KnowledgeBase. |
|
Auto-processing modes, background workers, observability, and error handling. |
|
Full API reference for pipeline types, views, CRUD functions, and config helpers. |
|
End-to-end worked examples. |
- Creating pipelines
- Pipeline steps
- Orchestration
- Pipelines API reference
- Types
- Domains
- Views
- Functions
- Error log functions
- Pipeline step config helpers
- aidb.chunk_text_config
- Parameters
- Example
- aidb.summarize_text_config
- Parameters
- Example
- aidb.ocr_config
- Parameters
- Example
- aidb.html_parse_config
- Parameters
- Example
- aidb.pdf_parse_config
- Parameters
- Example
- aidb.knowledge_base_config
- Parameters
- Example
- aidb.knowledge_base_config_from_kb
- Parameters
- Example
- aidb.inference_config
- Parameters
- Example
- Vector index config helpers
- aidb.vector_index_hnsw_config
- Parameters
- Example
- aidb.vector_index_ivfflat_config
- Parameters
- Example
- aidb.vector_index_chord_hnsw_config
- Parameters
- Example
- aidb.vector_index_chord_vchordq_config
- Parameters
- Example
- aidb.vector_index_hsphere_optimized_config
- Parameters
- Example
- aidb.vector_index_disabled_config
- Example
- Model config helpers
- Configuration
- Examples