DEV Community

Cover image for pgvector vs Pinecone: cost and performance

pgvector vs Pinecone: cost and performance

egor romanov on October 23, 2023

At Supabase, we believe that a combination of Postgres and pgvector serves as a better alternative to single-purpose databases like Pinecone for AI...
Collapse
 
awalias profile image
awalias

For anyone interested there's a good guide here on how to generate vector embeddings easily with pgvector on Supabase: supabase.com/docs/guides/ai/quicks...

and another guide here on how to build Q&A into something like a documentation site: supabase.com/docs/guides/ai/exampl...

Which can look something like this:

Image description

Lastly we have an awesome python library for interacting with vectors called vecs which you can find here: supabase.com/docs/guides/ai/python...

And works a bit like this:

# add records to the collection
docs.upsert(
    records=[
        (
         "vec0",           # the vector's identifier
         [0.1, 0.2, 0.3],  # the vector. list or np.array
         {"year": 1973}    # associated  metadata
        ),
        (
         "vec1",
         [0.7, 0.8, 0.9],
         {"year": 2012}
        )
    ]
)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
olirice profile image
Oliver Rice

pumped for the pgvector 0.5.1 rollout! It'll make HNSW index builds even faster

Collapse
 
egor_romanov profile image
egor romanov

btw vecs library is the one we use in all our postgres+pgvector bencmarks 😉

supabase.com/docs/guides/ai/python... 👀

Collapse
 
steve_val profile image
Steve_Val

is there any advantage to using Python vs Javascript when working with pgvector?

Thread Thread
 
egor_romanov profile image
egor romanov

not really, but python is just more widely used. also vecs for example, exposes nice apis to make your life easier when working with vectors

Collapse
 
kamilogorek profile image
Kamil Ogórek

It's getting so easy these days 😌

Collapse
 
dshukertjr profile image
Tyler Shukert

The AI chat bot example app is really nice. Everyone looked l liked it when I demoed it at Deno Fest Tokyo!

Collapse
 
loong profile image
Long Hoang

👀 👀 👀

Collapse
 
gregnr profile image
Greg Richardson

So happy we can generate embeddings directly in edge functions now 🔥

Collapse
 
thorwebdev profile image
Thor 雷神

This is so awesome, @huggingface for the win 🙌

Collapse
 
chasers profile image
Chase Granberry

Amazing

Collapse
 
monicakh profile image
Monica El Khoury

Awesome! 🚀

Collapse
 
thorwebdev profile image
Thor 雷神

The vecs library is great. Had me up and running building image search in no time 🚀

Collapse
 
nlake44 profile image
Navraj Chohan

I created a simple wrapper to pgvector that is inspired by Pinecone's simplicity: github.com/UpMortem/simple-pgvecto...

Collapse
 
timnpalmer profile image
timnpalmer

This is a game changer.