AI & Vectors
pgvector, embeddings, semantic and hybrid search, RAG.
7 pages · start with AI and vectors on SupaHost
- 01AI and vectors on SupaHostBuild semantic search, recommendations and RAG on SupaHost with pgvector in each project's Postgres, embeddings generated in Edge Functions, and RLS on every query.
- 02Vector columns with pgvectorEnable pgvector in a SupaHost project, add vector and halfvec columns, pick a distance operator, and insert and read embeddings from SQL and supabase-js.
- 03Generating embeddingsGenerate embeddings for SupaHost project rows in an Edge Function that calls an embeddings API with a key from function secrets, then keep them up to date automatically with a trigger and pg_cron.
- 04Semantic searchSearch a SupaHost project by meaning: embed the user's query in an Edge Function, match it against stored vectors with a database function that respects RLS, and call it from supabase-js.
- 05Hybrid searchCombine Postgres full-text search and pgvector similarity in one SupaHost database function using reciprocal rank fusion, so exact terms and meaning both count in the results.
- 06Vector indexes (HNSW and IVFFlat)Speed up pgvector similarity search on SupaHost with HNSW or IVFFlat indexes: choosing one, operator classes, build settings for shared instance memory, query tuning and filtered search.
- 07Retrieval-augmented generation (RAG)Answer questions from your own content on SupaHost: chunk and embed documents, retrieve the relevant chunks with an RLS-aware match function, and pass them to a chat model from an Edge Function.