The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Internal linking.
Ramiro Nuñez Dosio8f066ccd9510
diff --git a/apps/www/_blog/2023-09-05-pgvector-v0-5-0-hnsw.mdx b/apps/www/_blog/2023-09-05-pgvector-v0-5-0-hnsw.mdxindex 3f858a158ea..4bd5db2d4cc 100644--- a/apps/www/_blog/2023-09-05-pgvector-v0-5-0-hnsw.mdx+++ b/apps/www/_blog/2023-09-05-pgvector-v0-5-0-hnsw.mdx@@ -15,7 +15,7 @@ image: 2023-09-05-pgvector-v0-5-0-hnsw/pgvector-v0-5-0-og.pngthumb: 2023-09-05-pgvector-v0-5-0-hnsw/pgvector-v0-5-0-thumb.png----Vector search in Supabase is about to get a lot faster. Starting today, new Supabase databases will ship with pgvector v0.5.0 which adds a new type of index: Hierarchical Navigable Small World (HNSW).+[Supabase Vector](https://supabase.com/vector) is about to get a lot faster. Starting today, new Supabase databases will ship with pgvector v0.5.0 which adds a new type of index: Hierarchical Navigable Small World (HNSW).HNSW is an algorithm for approximate nearest neighbor search, often used in high-dimensional spaces like those found in embeddings.@@ -40,7 +40,7 @@ Compared to inverted file (IVF) indexes which use [clusters](https://supabase.co- **Hierarchical (H):** The algorithm operates over multiple layers- **Navigable Small World (NSW):** Each vector is a node within a graph and is connected to several other nodes-### **Hierarchical**+### HierarchicalThe hierarchical aspect of HNSW builds off of the idea of skip lists.@@ -86,7 +86,7 @@ To understand the performance improvements that HNSW offers, we decided to expanIn the first test, we used [224,482 vectors by OpenAI](https://huggingface.co/datasets/Supabase/wikipedia-en-embeddings) (1536 dimensions). You can find our previous benchmark with additional information on how vector dimensions may affect performance in [pgvector: Fewer dimensions are better](https://supabase.com/blog/pgvector-performance).-In this test we used a Supabase project with a large compute add-on (2-core CPU and 8GB RAM) and built the HNSW index with the following parameters:+In this test, we used a Supabase project with a large compute add-on (2-core CPU and 8GB RAM) and built the HNSW index with the following parameters:- `m`: 32- `ef_construction`: 64@@ -250,8 +250,15 @@ The index build time has decreased by over 50%, and this ratio remains consisten## When should you use HNSW vs IVF?-In most cases today, HNSW offers a more performant and robust index over IVFFlat. It's worth noting though that HNSW indexes will almost always be slower to build and use more memory than IVFFlat, so if your system is memory constrained and you don't foresee the need to rebuild your index often, you may find IVFFlat to be more suitable. It's also worth noting that product quantization (compressing index entries for vectors) is expected for IVF in the next versions of pgvector which should significantly improve performance and lower resource requirements. Regardless of the type of index you use, we still recommend [reducing the number of dimensions](https://supabase.com/blog/fewer-dimensions-are-better-pgvector) in your embeddings when possible.+In most cases today, HNSW offers a more performant and robust index over IVFFlat. It's worth noting though that HNSW indexes will almost always be slower to build and use more memory than IVFFlat, so if your system is memory-constrained and you don't foresee the need to rebuild your index often, you may find IVFFlat to be more suitable. It's also worth noting that product quantization (compressing index entries for vectors) is expected for IVF in the next versions of pgvector which should significantly improve performance and lower resource requirements. Regardless of the type of index you use, we still recommend [reducing the number of dimensions](https://supabase.com/blog/fewer-dimensions-are-better-pgvector) in your embeddings when possible.## Start using HNSW-All new Supabase databases will automatically ship with pgvector v0.5.0 which includes the new HNSW indexes. If you have an existing database, please reach out to [support](https://supabase.com/dashboard/support/new) and we'll be more than happy to assist you in an upgrade.+All {new Supabase databases}(https://database.new/) will automatically ship with pgvector v0.5.0 which includes the new HNSW indexes. If you have an existing database, please reach out to [support](https://supabase.com/dashboard/support/new) and we'll be more than happy to assist you in an upgrade.++## More pgvector and AI resources++- [How to build ChatGPT Plugin from scratch with Supabase Edge Runtime](https://supabase.com/blog/building-chatgpt-plugins-template)+- [Docs pgvector: Embeddings and vector similarity](https://supabase.com/docs/guides/database/extensions/pgvector)+- [Choosing Compute Add-on for AI workloads](https://supabase.com/docs/guides/ai/choosing-compute-addon)+- [pgvector: Fewer dimensions are better](https://supabase.com/blog/fewer-dimensions-are-better-pgvector)