Postgres Is Now a Vector Database, Too
SEATTLE — Bring generative AI and vector capabilities into what customers already use. That’s the story from Amazon Web Services with pgvector, an open source tool that brings vector similarity search into Postgres.
“So think of extensions as plugins,” said Sirish Chandrasekaran, general manager of Amazon relational database services, in this On the Road episode of The New Stack Makers recorded at Open Source Summit North America.
“You can bring your extension, and you can significantly alter the capabilities of Postgres. That’s one of the strengths of Postgres. So what pgvector does, is it allows you to store vector types in Postgres, and it also does something else: similarity search.”
With generative AI, he added, “You’re not looking for exact results, right? That’s not what a [large language model] does. But you’re looking for knowledge that is close. And the concept of similarity search, or approximate nearest neighbor, is what pgvector does really well.”
A Shoutout to the ‘Fantastic’ Developer
Chandrasekaran credited Andrew Kane, who he called “this fantastic developer” for pgvector: “He’s been at it for a few years. And we were the first cloud vendor to partner with him and offer it. It’s always been open source. But we offered it in Aurora and RDS early last year.”
pgvector originally had an indexing scheme called IVFFlat. It’s based on link lists and works well for building indexes fast, Chandrasekaran said.
But its query throughput does not perform as well when looking for higher rates of recall, like the percentage of the results you expect and end up getting, Chandrasekaran said.
With Kane, AWS started working on Hierarchical Navigable Small World (HNSW), which offers a graph-based approach compared to IVFFlat, which pgvector has used. According to the pgvector GitHub page, HNSW has better query performance than IVFFlat in terms of the speed-recall tradeoff, but slower build times and uses more memory.
“A big part of the work has been to make HNSW to be as performant as IVFFlat,” Chandrasekaran said. “It’s a fast-evolving space. So there’s a lot we don’t know. And so we’re just keeping a close ear to the ground on what customers are asking for.
“It’s about scale and performance, the usual things you’d ask and look for in a database. But in the context of vectors. the graph-based approach is what you see customers liking.”
The Advantages of Graphs
Graphs make it easier for customers to look for the nearest neighbors, a pillar of generative AI. The idea is to find similar points to a query, map the points and calculate the distances, which technologists say is an easier approach than complex machine learning algorithms.
Adding graphs creates the opportunity for graph-based, nearest-neighbor algorithms, a newer approach showing promising results.
Still, there’s a lot that we still need to learn.
“We learn a lot from our customers,” Chandrasekaran said. “That’s been one of our defining qualities. And the rate of innovation that we’ve seen in the generative AI space, frankly, from my experience, reminds me of the dot-com boom, like the late ’90s. The internet’s new world of possibilities are endless … and so our goal is to stay humble, stay nimble, listen to our customers, and keep innovating as they ask us to do more.”