Menu

1 / 2

pgvector: Build RAG Retrieval Inside the Postgres You Already Run

DEV Community: python·M.T.Ramkrushna·5 days ago
#3fG9KT4T
#devtopython#devto#dev#pgvector#vector
Reading 0:00
15s threshold

This week's AI tool: pgvector , an open-source Postgres extension that adds vector similarity search to the database you probably already run.

Why it's worth 15 minutes of your time: the retrieval step of a RAG app is "store embeddings, find the nearest ones to a query, filter by who is allowed to see what." If your documents, users and permissions already live in Postgres, pgvector lets you do all three in one SQL query, with the transactions, backups, JOINs and point-in-time recovery you already rely on. No second database to sync.

Here's exactly how to use it.

1. Install and enable the extension

pgvector supports Postgres 13+. It's available through Docker, Homebrew, APT, Yum, PGXN and conda-forge, and it comes preinstalled on many hosted Postgres providers (see the installation section of the README ). Then, once in each database where you want it:

CREATE EXTENSION vector ;

Enter fullscreen mode

Exit fullscreen mode

2.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.