Activate PGVector Extension in PostgreSQL for RAG
generative-ai
implementation
Imported and normalized from a Notion article.
Last time we have seen how to setup PostgreSQL in mac OS. The following article is to enable an extension called PGVector, which is used to
Step 1: Install pgvector from the source
cd /tmp
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudoStep 2: Restart PostgreSQL service
brew services restart postgresql@15Step 4: Create extension
# Start PostgreSQL service
brew services start postgresql@15
# Connect to your database
psql -d <db-name> -U <username>
# Create the vector extension
CREATE EXTENSION vector;
# Verify installation
\dx vectorIf the installation succeed, we should see the following output after executing \dx vector:
List of installed extensions
Name | Version | Schema | Description
--------+---------+--------+------------------------------------------------------
vector | 0.8.0 | public | vector data type and ivfflat and hnsw access methodsCheck Postgres log:
tail -f /opt/homebrew/var/log/postgresql@15.log