The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add gte-small measurements in blog post
Greg Richardsonc602a3895781
diff --git a/apps/www/_blog/2023-08-03-fewer-dimensions-are-better-pgvector.mdx b/apps/www/_blog/2023-08-03-fewer-dimensions-are-better-pgvector.mdxindex fadd0562a8a..7946321ac78 100644--- a/apps/www/_blog/2023-08-03-fewer-dimensions-are-better-pgvector.mdx+++ b/apps/www/_blog/2023-08-03-fewer-dimensions-are-better-pgvector.mdx@@ -85,7 +85,7 @@ Take a look at dot product for example:Dot product is the product of each vector element pair summed together into a single result. Fewer dimensions in the vector means fewer calculations for every computed distance .-We've compared `text-embedding-ada-002` from OpenAI (1536 dimensions) with open-source `all-MiniLM-L6-v2` (384 dimensions), using the following configuration:+We compared the performance of `text-embedding-ada-002` from OpenAI (1536 dimensions) with open-source `all-MiniLM-L6-v2` (384 dimensions) by measuring requests per second at a constant precision and configuration:- **Database size:** with 2vCPU (ARM) and 8GB RAM - `large` add-on for Supabase project.- **Version:** Postgres v15 and pgvector v0.4.0@@ -93,7 +93,7 @@ We've compared `text-embedding-ada-002` from OpenAI (1536 dimensions) with open-- **Index:** The index was generated for `inner-product` (dot product) distance function with `lists=1000`.- **Process:** We followed [our optimization guide and tips](https://supabase.com/docs/guides/ai/going-to-prod#performance-tips-when-using-indexes).-We observed pgvector with `all-MiniLM-L6-v2` outperforming (at requests per second) `text-embedding-ada-002` by 78% when holding the precision@10 constant at 0.99. This gap increases as you lower the precision. Postgres was using just 4GB of RAM with 384d vectors generated by `all-MiniLM-L6-v2` compared to 7.5GB with `text-embedding-ada-002`.+We observed pgvector with `all-MiniLM-L6-v2` outperforming `text-embedding-ada-002` by 78% when holding the precision@10 constant at 0.99. This gap increases as you lower the precision. Postgres was using just 4GB of RAM with 384d vectors generated by `all-MiniLM-L6-v2` compared to 7.5GB with `text-embedding-ada-002`.<div><img@@ -121,6 +121,21 @@ We observed pgvector with `all-MiniLM-L6-v2` outperforming (at requests per seco/></div>+After that, we decided to try the recently published [gte-small](https://huggingface.co/thenlper/gte-small) (also 384 dimensions), and the results were even more astonishing. With `gte-small`, we could set `probes=10` to achieve the same level of `precision@10 = 0.99`. Consequently, we observed more than a 200% improvement in requests per second for pgvector with embeddings generated by `gte-small` compared to `all-MiniLM-L6-v2`.++<div>+ <img+ alt="multi database"+ className="dark:hidden"+ src="/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-light.png"+ />+ <img+ alt="multi database"+ className="hidden dark:block"+ src="/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-dark.png"+ />+</div>+## Choosing an embedding modelUltimately the choice of embedding model will depend on your specific use case and requirements. You would likely want to consider:diff --git a/apps/www/public/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-dark.png b/apps/www/public/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-dark.pngnew file mode 100644index 00000000000..f368b6adbeeBinary files /dev/null and b/apps/www/public/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-dark.png differdiff --git a/apps/www/public/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-light.png b/apps/www/public/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-light.pngnew file mode 100644index 00000000000..3c55592a012Binary files /dev/null and b/apps/www/public/images/blog/2023-08-03-fewer-dimensions-are-better-pgvector/performance-comparison-gte-small-99-light.png differ