Supercharge your PostgreSQL database with AI capabilities. Supports:
- Automatic creation and synchronization of vector embeddings for your data
- Seamless vector and semantic search
- Retrieval Augmented Generation (RAG) directly in SQL
- Ability to call out to leading LLMs like OpenAI, Ollama, Cohere, and more via SQL.
- Built-in utilities for dataset loading and processing
All with the reliability, scalability, and ACID compliance of PostgreSQL.
- Install pgai with Docker: run pgai in a container environment.
- Install pgai from source: install pgai from source.
Vectorizer automates the embedding process within your database management by treating embeddings as a declarative, DDL-like feature — like an index.
Overview: Automate AI embedding with pgai Vectorizer - a comprehensive overview of Vectorizer features, demonstrating how it streamlines the process of working with vector embeddings in your database.
- Quickstart guides:
- Vectorizer quickstart for Ollama: setup your developer environment, create and run a vectorizer.
- Vectorizer quickstart for OpenAI: setup your developer environment, create and run a vectorizer using OpenAI.
- Vectorizer quickstart for Voyage: setup your developer environment, create and run a vectorizer using Voyage.
- References:
- pgai Vectorizer API reference: API reference for Vectorizer functions
- Documentation for vectorizer worker: explain how to run vectorizers on a self-hosted PostgreSQL instance.
- Develop:
Model calling allows you to call out to LLM models from SQL. This lets you leverage the power of LLMs for a variety of tasks, including classification, summarization, moderation, and other forms of data enrichment.
The following models are supported (click on the model to learn more):
Model | Tokenize | Embed | Chat Complete | Generate | Moderate | Classify | Rerank |
---|---|---|---|---|---|---|---|
Ollama | ✔️ | ✔️ | ✔️ | ||||
OpenAI | ✔️️ | ✔️ | ✔️ | ✔️ | |||
Anthropic | ✔️ | ||||||
Cohere | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ||
Voyage AI | ✔️ | ||||||
Huggingface (with LiteLLM) | ✔️ | ||||||
Mistral (with LiteLLM) | ✔️ | ||||||
Azure OpenAI (with LiteLLM) | ✔️ | ||||||
AWS Bedrock (with LiteLLM) | ✔️ | ||||||
Vertex AI (with LiteLLM) | ✔️ |
- Usage examples:
- Delayed embed: run pgai using pgai or TimescaleDB background actions.
- Moderate comments using OpenAI: use triggers or actions to moderate comments using OpenAI.
- Load dataset from Hugging Face: load datasets from Hugging Face's datasets library directly into your PostgreSQL database.
- Chunking: chunking algorithms you can use from withinSQL.
- Secure pgai with user privilages: grant the necessary permissions for a specific user or role to use pgai functionality.
- A guide to securely handling API keys: learn how to securely handle API keys in your database.