惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
G
Google Developers Blog
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
F
Full Disclosure
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
Help Net Security
Help Net Security
The Hacker News
The Hacker News
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
V
Visual Studio Blog
博客园 - 聂微东
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Security Archives - TechRepublic
Security Archives - TechRepublic
Simon Willison's Weblog
Simon Willison's Weblog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Last Week in AI
Last Week in AI
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
N
News | PayPal Newsroom
A
About on SuperTechFans
S
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
雷峰网
雷峰网
T
The Exploit Database - CXSecurity.com
罗磊的独立博客
K
Kaspersky official blog
The Cloudflare Blog
I
Intezer

Supabase Blog

AI Agents Know About Supabase. They Don't Always Use It Right. Custom OIDC Providers for Supabase Auth 100,000 GitHub stars Supabase docs over SSH Navigating Regional Network Blocks Supabase Joins the Stripe Projects Developer Preview Log Drains: Now available on Pro Supabase Storage: major performance, security, and reliability updates Supabase incident on February 12, 2026 Hydra joins Supabase X / Twitter OAuth 2.0 is now available for Supabase Auth BKND joins Supabase Supabase is now an official Claude connector Supabase PrivateLink is now available Introducing: Postgres Best Practices When to use Read Replicas vs. bigger compute Introducing TRAE SOLO integration with Supabase Supabase Security Retro: 2025 Sync Stripe Data to Your Supabase Database in One Click Building ChatGPT Apps with Supabase Edge Functions and mcp-use Own Your Observability: Supabase Metrics API Introducing iceberg-js: A JavaScript Client for Apache Iceberg Introducing Supabase for Platforms Adding Async Streaming to Postgres Foreign Data Wrappers Build "Sign in with Your App" using Supabase Auth Introducing Seven New Email Templates for Supabase Auth The new Supabase power for Kiro Introducing Supabase ETL Introducing Analytics Buckets Introducing Vector Buckets Snap, Inc. Launches Snap Cloud, Powered by Supabase Triplit joins Supabase Supabase Series E 1000 Y Combinator Founders Choose Supabase gm 👋 web3, welcome aboard to Sign in with Web3 (Solana, Ethereum) Announcing the Supabase Remote MCP Server Enterprise speed, enterprise standards with Bolt Cloud + Supabase PostgREST 13 Lovable Cloud + Supabase: The Default Platform for AI Builders Processing large jobs with Edge Functions, Cron, and Queues Defense in Depth for MCP Servers OrioleDB Patent: now freely available to the Postgres community Supabase Launch Week 15 Hackathon Winner Announcement The Vibe Coder's Guide to Supabase Environments Testing for Vibe Coders: From Zero to Production Confidence The Vibe Coding Master Checklist Vibe Coding: Best Practices for Prompting Supabase Auth: Build vs. Buy Top 10 Launches of Launch Week 15 Supabase Launch Week 15 Hackathon Storage: 10x Larger Uploads, 3x Cheaper Cached Egress, and 2x Egress Quota Persistent Storage and 97% Faster Cold Starts for Edge Functions Algolia Connector for Supabase New Observability Features in Supabase Improved Security Controls and A New Home for Security Introducing Branching 2.0 Stripe-To-Postgres Sync Engine as standalone Library Supabase Analytics Buckets with Iceberg Support Create a Supabase backend using Figma Make Introducing JWT Signing Keys Supabase UI: Platform Kit Build a Personalized AI Assistant with Postgres Announcing Multigres: Vitess for Postgres Building on open table formats Open Data Standards: Postgres, OTel, and Iceberg Simplifying back-end complexity with Supabase Data APIs PostgreSQL Event Triggers without superuser access Top 10 Launches of Launch Week 14 Supabase MCP Server Data API Routes to Nearest Read Replica Declarative Schemas for Simpler Database Management Realtime: Broadcast from Database Keeping Tabs on What's New in Supabase Studio Edge Functions: Deploy from the Dashboard + Deno 2.1 Automatic Embeddings in Postgres Introducing the Supabase UI Library Supabase Auth: Bring Your Own Clerk Postgres Language Server: Initial Release Migrating from Fauna to Supabase Migrating from the MongoDB Data API to Supabase Dedicated Poolers Postgres as a Graph Database: (Ab)using pgRouting AI Hackathon at Y Combinator Calendars in Postgres using Foreign Data Wrappers Supabase Launch Week 13 Hackathon Winners How to Hack the Base! Running Durable Workflows in Postgres using DBOS database.build v2: Bring-your-own-LLM Restore to a New Project Hack the Base! with Supabase Top 10 Launches of Launch Week 13 Supabase Queues High Performance Disk Supabase Cron Supabase CLI v2: Config as Code Supabase Edge Functions: Introducing Background Tasks, Ephemeral Storage, and WebSockets Supabase AI Assistant v2 OrioleDB Public Alpha Executing Dynamic JavaScript Code on Supabase with Edge Functions ClickHouse Partnership, improved Postgres Replication, and Disk Management
Supabase Vecs: a vector client for Postgres
Oliver Rice · 2023-05-29 · via Supabase Blog

Supabase Vecs: a vector client for Postgres

Vecs is a new Python library for managing embeddings in your Postgres database with the pgvector extension.

It handles:

  • Creating and indexing tables
  • Querying vectors by cosine distance, l2 distance, and max inner dot product
  • Filtering based on user-defined metadata

Our goal for vecs is to provide an interface that lets Postgres + pgvector look and feel like a dedicated vector store. It works with any Postgres database (or platform) that supports pgvector. It was designed with ease-of-use, interactivity, and exploratory data analysis in mind, but works equally well as a search workhorse.

If you're interested in the nuts and bolts of what's going on, it's trivial to drop into the SQL layer and see what's happening. Alternatively, folks who don't want to know what's happening in the database, don't need to care.

Vecs makes it easy to create a collection (table) and insert a few records - just 5 lines of code.

Connecting#


_10

import vecs

_10

_10

DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"

_10

_10

# create vector store client

_10

vx = vecs.create_client(DB_CONNECTION)

_10

_10

# create a collection of vectors with 3 dimensions

_10

docs = vx.get_or_create_collection(name="docs", dimension=3)


The get_or_create_collection call sets up a table in the Postgres database specified by DB_CONNECTION in a schema named vecs with the user defined name docs.

Or, more specifically:


_10

create table vecs.docs (

_10

id text primary key,

_10

vec vector(3) not null,

_10

metadata jsonb not null default '{}'::jsonb

_10

);


Insert/Update#

We can insert a few records in that new SQL table/vecs collection using Collection.upsert.


_10

# add records to the collection

_10

docs.upsert(

_10

vectors=[

_10

(

_10

"vec0", # the records user defined identifier

_10

[0.1, 0.2, 0.3], # the vector. A list or np.array

_10

{"year": 1973} # associated metadata

_10

)

_10

]

_10

)


which will add the records to our table if the id "vec0" does not exist, or updates the existing record if it does exist.

Query#

You can query a vecs collection at any time without an index, but it's a best practices to create an index on your collection after inserting data.

Where index optionally takes an argument for the distance measure to index.

Finally, we can search the collection for similar vectors using the query method:


_10

docs.query(

_10

query_vector=[0.10,0.21,0.29], # required

_10

limit=1, # (optional) number of records to return

_10

filters={"year": {"$eq": 1973}}, # (optional) metadata filters

_10

measure="cosine_distance", # (optional) distance measure to use

_10

include_value=False, # (optional) should distance measure values be returned?

_10

include_metadata=False, # (optional) should record metadata be returned?

_10

)


Which returns:


_10

[("vec1", 0.000697, {"year": 1973})]


Since all metadata is stored in a jsonb column, there's a lightweight but flexible DSL wrapped around it for filtering.

When you're done, disconnect with:

And 90% of the time, that minimal interface is all you'll need to touch.

For more in-depth information about vecs, checkout the API Quickstart, celebrity look-alike demo, or OpenAI integration example

As usual, if you combine supabase/vecs with the rest of Supabase, you get more than the sum of the parts. Once you're happy with your vecs collection, you can make it accessible to your front-end through a supabase client library by exposing the collection as a view in your public schema.

For example, you could create a view


_10

create view public.docs as

_10

select

_10

id,

_10

embedding,

_10

metadata, # Expose the metadata as JSON

_10

(metadata->>'url')::text as url # Extract the URL as a string

_10

from

_10

vecs.docs


And then access it with the supabase-js client library within your applications:


_10

const { data, error } = await supabase

_10

.from('docs')

_10

.select('id, embedding, metadata')

_10

.eq('url', '/hello-world')


For more deployment options, including enterprise scalable architecture, check out the engineering for scale guide.

Currently, vecs is unopinionated about where vectors come from or how they're produced. While there will always be a need for generic vector storage and querying, it's becoming clear that text and image vectorization make up +95% of usage. That gives us the opportunity to streamline those workflows for users.

One option we're exploring is to optionally assign transformation pipelines to collections along the lines of:


_14

# This is mock code only, not currently functional

_14

_14

docs: Collection =vx.get_or_create_collection(

_14

docs='docs',

_14

dimension=512,

_14

transform = TextPreprocessor( # this is new

_14

model="sentence-transformers/all-Mini-L6-v2"

_14

)

_14

)

_14

_14

docs.upsert([

_14

("id_0", "# Some markdown", {}),

_14

("id_1", "# Some more markdown", {})

_14

])


so users can choose to work with their preferred media type without ever thinking about vectors.

Another direction we're considering is adding an async client to avoid blocking when waiting on the database or network i.e.


_10

# This is mock code only, not currently functional

_10

_10

await docs.upsert([

_10

("id_0", [0.1, 0.2, 0.3], {}),

_10

])


Both possibilities are still up for debate. If you have view on either, feel free to weigh in on the Feature Request: Preprocessing Transform and Feature Request: Async Client GitHub issues.