Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

postgresml

> 数据库
Open source

Postgres with GPUs for ML/AI apps.

6.8K stars0 likes1 views
WebsiteGitHub

About

Postgres with GPUs for ML/AI apps.

Postgres + GPUs for ML/AI applications.

| Documentation | Blog | Discord |


Why do ML/AI in Postgres?

Data for ML & AI systems is inherently larger and more dynamic than the models. It's more efficient, manageable and reliable to move models to the database, rather than constantly moving data to the models.

  • Getting started
    • PostgresML Cloud
    • Self-hosted
    • Ecosystem
  • Large Language Models
    • Hugging Face
    • OpenAI and Other Providers
  • RAG
    • Chunk
    • Embed
    • Rank
    • Transform
  • Machine Learning

Architecture

Features at a glance

  • In-Database ML/AI: Run machine learning and AI operations directly within PostgreSQL
  • GPU Acceleration: Leverage GPU power for faster computations and model inference
  • Large Language Models: Integrate and use state-of-the-art LLMs from Hugging Face
  • RAG Pipeline: Built-in functions for chunking, embedding, ranking, and transforming text
  • Vector Search: Efficient similarity search using pgvector integration
  • Diverse ML Algorithms: 47+ classification and regression algorithms available
  • High Performance: 8-40X faster inference compared to HTTP-based model serving
  • Scalability: Support for millions of transactions per second and horizontal scaling
  • NLP Tasks: Wide range of natural language processing capabilities
  • Security: Enhanced data privacy by keeping models and data together
  • Seamless Integration: Works with existing PostgreSQL tools and client libraries

Getting started

The only prerequisites for using PostgresML is a Postgres database with our open-source pgml extension installed.

PostgresML Cloud

Our serverless cloud is the easiest and recommend way to get started.

Sign up for a free PostgresML account. You'll get a free database in seconds, with access to GPUs and state of the art LLMs.

Self-hosted

If you don't want to use our cloud you can self host it.

bash
docker run \
    -it \
    -v postgresml_data:/var/lib/postgresql \
    -p 5433:5432 \
    -p 8000:8000 \
    ghcr.io/postgresml/postgresml:2.10.0 \
    sudo -u postgresml psql -d postgresml

For more details, take a look at our Quick Start with Docker documentation.

Ecosystem

We have a number of other tools and libraries that are specifically designed to work with PostgreML. Remeber PostgresML is a postgres extension running inside of Postgres so you can connect with psql and use any of your favorite tooling and client libraries like psycopg to connect and run queries.

PostgresML Specific Client Libraries:

  • Korvus - Korvus is a Python, JavaScript, Rust and C search SDK that unifies the entire RAG pipeline in a single database query.
  • postgresml-django - postgresml-django is a Python module that integrates PostgresML with Django ORM.

Recommended Postgres Poolers:

  • pgcat - pgcat is a PostgreSQL pooler with sharding, load balancing and failover support.

Large language models

PostgresML brings models directly to your data, eliminating the need for costly and time-consuming data transfers. This approach significantly enhances performance, security, and scalability for AI-driven applications.

By running models within the database, PostgresML enables:

  • Reduced latency and improved query performance
  • Enhanced data privacy and security
  • Simplified infrastructure management
  • Seamless integration with existing database operations

Hugging Face

PostgresML supports a wide range of state-of-the-art deep learning architectures available on the Hugging Face model hub. This integration allows you to:

  • Access thousands of pre-trained models
  • Utilize cutting-edge NLP, computer vision, and other AI models
  • Easily experiment with different architectures

OpenAI and other providers

While cloud-based LLM providers offer powerful capabilities, making API calls from within the database can introduce latency, security risks, and potential compliance issues. Currently, PostgresML does not directly support integration with remote LLM providers like OpenAI.

RAG

PostgresML transforms your PostgreSQL database into a powerful vector database for Retrieval-Augmented Generation (RAG) applications. It leverages pgvector for efficient storage and retrieval of embeddings.

Our RAG implementation is built on four key SQL functions:

  1. Chunk: Splits text into manageable segments
  2. Embed: Generates vector embeddings from text using pre-trained models
  3. Rank: Performs similarity search on embeddings
  4. Transform: Applies language models for text generation or transformation

For more information on using RAG with PostgresML see our guide on Unified RAG.

Chunk

The pgml.chunk function chunks documents using the specified splitter. This is typically done before embedding.

postgresql
pgml.chunk(
    splitter TEXT,    -- splitter name
    text TEXT,        -- text to embed
    kwargs JSON       -- optional arguments (see below)
)

See pgml.chunk docs for more information.

Embed

The pgml.embed function generates embeddings from text using in-database models.

postgresql
pgml.embed(
    transformer TEXT,
    "text" TEXT,
    kwargs JSONB
)

See pgml.embed docs for more information.

Rank

The pgml.rank function uses Cross-Encoders to score sentence pairs.

This is typically used as a re-ranking step when performing search.

postgresl
pgml.rank(
    transformer TEXT,
    query TEXT,
    documents TEXT[],
    kwargs JSONB
)

Docs coming soon.

Transform

The pgml.transform function can be used to generate text.

postgresql
SELECT pgml.transform(
    task   => TEXT OR JSONB,     -- Pipeline initializer arguments
    inputs => TEXT[] OR BYTEA[], -- inputs for inference
    args   => JSONB              -- (optional) arguments to the pipeline.
)

See pgml.transform docs for more information.

See our Text Generation guide for a guide on generating text.

Machine learning

Some highlights:

  • 47+ classification and regression algorithms
  • 8 - 40X faster inference than HTTP based model serving
  • Millions of transactions per second
  • Horizontal scalability

Training a classification model

Training

postgresql
SELECT * FROM pgml.train(
    'Handwritten Digit Image Classifier',
    algorithm => 'xgboost',
    'classification',
    'pgml.digits',
    'target'
);

Inference

postgresql
SELECT pgml.predict(
    'My Classification Project',
    ARRAY[0.1, 2.0, 5.0]
) AS prediction;

NLP

The pgml.transform function exposes a number of available NLP tasks.

Available tasks are:

  • Text Classification
  • Zero-Shot Classification
  • Token Classification
  • Translation
  • Summarization
  • Question Answering
  • Text Generation
  • Text-to-Text Generation
  • Fill-Mask

Issues· 148 open

View all issuesOpen on GitHub
  • #1698

    Redirections to github of any link on readme.md

    Updated Apr 15, 2026
  • #1697

    Best way to install postgresML on windows

    Updated Mar 18, 2026
  • #1680

    Working docker image for latest release for ubuntu 24

    Updated Jan 29, 2026
  • #1695

    Docs still point to postgresml.org

    Updated Dec 26, 2025
  • #1392

    Issues with Docker container on port 5432

    questionUpdated Dec 12, 2025
  • #628

    Invalid model can be "deployed", if there is no prior trained model for a project

    buggood first issueUpdated Nov 5, 2025
  • #1690

    Access to postgresml cloud environment

    Updated Jul 15, 2025
  • #1688

    Will postgresml continue to be updated and iterated?

    Updated Jul 7, 2025
  • #1686

    Add model Export & Load as part of the full model lifecycle

    Updated Jun 11, 2025
  • #1674

    Invalid pgml.so binary for version 2.10 amd64 .deb package

    bugUpdated Mar 17, 2025

> Tags

Rustaiannapproximate-nearest-neighbor-searchartificial-intelligence

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库