Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 6 min read Announcement mediumAdept

Automatic Embeddings in Postgres

Supabase moves embedding generation coordination into Postgres. Insert and update triggers enqueue jobs in pgmq, pg_cron batches them, and pg_net calls an Edge Function that hits an embedding API, then writes results into a pgvector column. The design avoids drift between content and vectors and keeps slow inference off the write path. Embeddings are briefly null after a write until the async job completes. A generated-column approach is rejected because it blocks writes unless the model is local and fast.

Related posts

  • Storing OpenAI embeddings in Postgres with pgvector

    Supabase mediumAdept

    pgvector adds a vector data type and distance operators (Euclidean <->, negative inner product <#>, cosine <=>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database. The walkthrough creates a documents table, a match_documents SQL function that filters by a cosine-similarity threshold, and an IVFFlat index sized at roughly 4 * sqrt(rows) lists. It then generates embeddings in JavaScript and builds Deno Edge Functions for semantic search and for retrieval-augmented answers with text-davinci-003, keeping injected context under about 1500 tokens to fit the 4000-token limit.

  • Hugging Face is now supported in Supabase

    Supabase mediumAdept

    Supabase adds first-class Hugging Face support for generating embeddings stored in pgvector, as an open-source, self-hostable alternative to OpenAI's text-embedding-ada-002. The Python vecs client gains "adapters" that chunk text and embed it automatically on upsert and query. Edge Functions can run Transformers.js inference in Deno, and small models can even run in the browser and query pgvector through PostgREST and RLS. Supabase recommends lower-dimension models such as gte-small for cheaper storage and faster retrieval, and notes current limits: 2-6s cold starts from model downloads, and no turnkey audio/image decoding in Deno.

  • Introducing Vector Buckets

    Supabase mediumAdept

    Supabase Vector Buckets are a new Storage bucket type that keeps embeddings in S3-backed object storage with built-in k-NN similarity search, supporting up to 50M vectors per index, cosine distance and metadata filtering. Indexes are queried through the Supabase SDKs or from Postgres via a foreign data wrapper, so results can be joined with relational tables. They target sub-second (hundreds of milliseconds) rather than single-digit-millisecond latency, so the recommended pattern is to keep hot, latency-sensitive or transactional vectors in pgvector and move large warm or cold archives to Vector Buckets. The feature is in free Public Alpha for Pro projects in five AWS regions.

  • ChatGPT plugins now support Postgres & Supabase

    Supabase mediumAdept

    Supabase contributed Postgres and Supabase datastore providers to OpenAI's ChatGPT Retrieval Plugin, storing text-embedding-ada-002 embeddings in pgvector. The Postgres provider connects directly via psycopg2, while the Supabase provider goes through PostgREST to enable Row Level Security. Both share the same documents schema and use a plpgsql match function that filters by source, author and date and ranks results by inner product distance. A walkthrough ingests the PostgreSQL 15 docs (about 7,904 chunks), adds an approximate ivfflat index with lists ≈ rows/1000, and registers the local plugin with ChatGPT to answer documentation questions.

  • AI Inference now available in Supabase Edge Functions

    Supabase mediumAdept

    Supabase Edge Functions gain a built-in Supabase.ai.Session API for running AI inference in a few lines of code, starting with gte-small embeddings for storage in pgvector and experimental, invite-only Llama and Mistral LLMs with streaming responses. Embeddings run on a native Edge Runtime extension that calls ONNX Runtime through the Rust Ort wrapper, replacing the slow WASM boot of Transformers.js. A typical embedding request finishes in under 1s even from a cold start and uses 100-200ms of CPU, and Supabase claims this is about 10x cheaper than OpenAI's embedding API with comparable MTEB scores. LLM requests are routed to GPU-accelerated Ollama servers, and database webhooks can trigger embedding generation automatically when rows are inserted.

The quest for software engineering knowledge.

Look:
Layout: