Skip to content

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

Supabase 7 min read Announcement mediumAdept

Hugging Face is now supported in Supabase

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.

Related posts

  • 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.

  • 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.

  • 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.

  • Supabase Vecs: a vector client for Postgres

    Supabase mediumAdept

    Vecs is a Python client that makes Postgres with the pgvector extension behave like a dedicated vector store, handling collection (table) creation, indexing, upserts, and similarity queries by cosine, L2, or max inner product with a jsonb-backed metadata filter DSL. Each collection maps to a plain table in a `vecs` schema (text id, vector column, jsonb metadata), so users can drop down to SQL when needed. On Supabase, collections can be exposed as public views and queried from supabase-js. Possible future work includes built-in text/image embedding transforms and an async client.

  • Automatic Embeddings in Postgres

    Supabase mediumAdept

    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.

The quest for software engineering knowledge.

Look:
Layout: