News for hackers. Stuff that matters.
Re:Investing in new vector database development vs enhancing... by simonw on Saturday November 25, 2023 @06:20PM (#38417688)
Has anyone seen a convincing argument for why you would want a dedicated vector database in place of a normal database with a good, fast vector index implementation?

The existing DB + vector index option seems so obvious to me that I'm worried I'm missing something.

Re:Investing in new vector database development vs enhancing... by icyfox on Saturday November 25, 2023 @08:09PM (#38418343)
The only production case I've seen of someone switching to a vector database totally in-lieu of a RDBMS is when their raw data lives in parquet / arrow files and they need fast read-only searches in production. Then a periodic indexing daemon with some additional metadata bolted onto the vector definitions worked well and saved them from having to dip their toes into classic database optimization.

Every place where I'm deploying vector databases, though, I'm using them as an alternative index just for searches (indexing embedding/id only) and doing the full object value lookup in the RDBMS. It's easier to optimize their vector clustering / sort performance outside the constraints of postgres - which is perhaps why pgvector suffers more under higher load.

Re:Investing in new vector database development vs enhancing... by tveita on Saturday November 25, 2023 @08:05PM (#38418323)
There are good reasons to split embeddings off from your regular DB load. Embeddings can be quite large (kilobytes per item), and querying is CPU and IO intensive, so they are good candidate for scaling separately.

The embeddings are not primary data, they're derived from other content and can be recreated if necessary. The vectors will probably be fed or read in bulk by your ML pipeline at times.

I'd say you probably want the primary storage of your embeddings to be file storage like S3 or similar, and then feed them directly into a search engine like Vespa or Elasticsearch.

Re:Investing in new vector database development vs enhancing... by dylanjcastillo on Saturday November 25, 2023 @06:31PM (#38417778)
I guess that at a big enough scale it starts making sense. But not sure what “big” really is.

Pgvector seems to perform very poorly compared to Qdrant: https://nirantk.com/writing/pgvector-vs-qdrant/

Re:Investing in new vector database development vs enhancing... by simonw on Saturday November 25, 2023 @06:37PM (#38417836)
I absolutely believe that at the moment - Qdrant is clearly a fantastic piece of technology.

But if I was using Qdrant myself I'd treat it like ElasticSearch - I'd denormalize some of my data into it, but I'd still do most of my work in the relational database and treat Qdrant as effectively an external index for my stuff.

Maybe I'm getting hung up on the world "database" here as indicating that you use that instead of an RDBMS, when actually everyone selling a vector database expects you to use it as effectively an external indexing mechanism instead.

Re:Investing in new vector database development vs enhancing... by zmgsabst on Saturday November 25, 2023 @10:53PM (#38419036)
I personally read it as “vector cache”, because you can use it to, eg, store a phrasing to repeat later.
Re:Investing in new vector database development vs enhancing... by swyx on Sunday November 26, 2023 @03:07AM (#38420009)
i wish nirantk would add an addendum noting the pgvector issue was fixed or people like me will have to put up the counter response every single time https://youtu.be/MDxEXKkxf2Q?si=eUhNtghbiLRJ7yHB
Re:Investing in new vector database development vs enhancing... by dylanjcastillo on Sunday November 26, 2023 @05:56PM (#38425956)
Very interesting. I didn’t know about it. Thanks!
Re:Investing in new vector database development vs enhancing... by brigadier132 on Saturday November 25, 2023 @06:21PM (#38417703)
why do companies use databases like elastic search when they could just use inverted indexes in postgres?

Performance, features, and scalability

Re:Investing in new vector database development vs enhancing... by simonw on Saturday November 25, 2023 @06:38PM (#38417844)
I use Elasticsearch along with PostgreSQL, but I don't think of Elasticsearch as a database. It's an external index that I denormalize some of my data into.
Re:Investing in new vector database development vs enhancing... by tyre on Sunday November 26, 2023 @12:11AM (#38419335)
ES is a good parallel to a vector database.

run a search against ES => hydrate records from postgres

run a search against a vector database => hydrate LLM context from documents

Neither is a primary canonical datastore. Postgres is for ES and S3 is for documents.

Re:Investing in new vector database development vs enhancing... by riku_iki on Saturday November 25, 2023 @11:15PM (#38419118)
so, its just happened that there is no good implementation of full text search in postgres, but fundamentally nothing prevents from implementing such search, except horizontal scalability if it is needed.
Re:Investing in new vector database development vs enhancing... by johnthescott on Saturday November 25, 2023 @11:41PM (#38419218)
the pg extension called "rum" is very performant on millions of pdfs.

https://github.com/postgrespro/rum

Re:Investing in new vector database development vs enhancing... by riku_iki on Sunday November 26, 2023 @12:11AM (#38419334)
my case is tens of billions of short docs, and default search is fine except index creation is single threaded, so it takes multiple days to build index, and github page says rum is even slower..
Re:Investing in new vector database development vs enhancing... by aforwardslash on Sunday November 26, 2023 @04:19AM (#38420285)
I love Postgres, but you're comparing apples and oranges. You don't have the same level of query sophistication neither the same indexing quality you get from eg. elasticsearch. As a quick example, the other day I got a bug in PostgreSQL because "searching" does not perform diacritics conversion. Also, stuff like stop words, similarity search and whatnot either required dedicated indexes or are downright "round hole square peg" problems.
Re:Investing in new vector database development vs enhancing... by mkarrmann on Sunday November 26, 2023 @10:12AM (#38422162)
I believe they're being rhetorical, and agree that there are good reasons to use elasticsearch over postgres.
Re:Investing in new vector database development vs enhancing... by jhj on Saturday November 25, 2023 @11:31PM (#38419173)
The two main classes of approximate k-NN algorithms om high dimensional data would involve either (1) linear table scans (e.g., IVF / cell-probe indexes; brute-force exact indexing or the coarse quantizer for an IVF index) or (2) graph walking (HNSW, NN-Descent, CAGRA, etc). Some other approaches like LSH (depending on how it's represented as a data structure) can be in between the two.

For (1), all of the indexing features of a typical RDBMS are overkill for IVF, where the only indexing you need is by IVF bucket, and then you simply sequentially scan and evaluate distances for everything in those buckets.

However, if you want to perform filtering based on other criteria (e.g., filtering based on metadata associated with each vector), then multiple column indexes could be useful with a RDBMS, as you can more efficiently extract just the vectors that meet criteria prior to a sequential scan (e.g., give me all vectors which have a date in the range between X and Y and whose name contains the string "red").

For (2), these algorithms would be inefficient to express in a typical RDBMS. While you can easily encode a graph in a RDBMS, walking the graph sequentially based on criteria is another matter, because each time you'd have to hit the disk (or in-memory cache) to find the next row to look at, then repeat. Latency could be an issue unless it's all in memory, and if it's all in memory, a RDBMS-type representation is overkill versus more simple pointer chasing in memory.

I guess it also depends upon latency / throughput needs (caching in memory on front of a database could help, but a pure in-memory vector index would be faster), persistence / fault tolerance / replication needs (in memory databases would need some kind of persistent store), or update needs (adding/removing vectors, though adding/removing vectors from an IVF or graph-based index becomes non-trivial if you add or remove too many vectors). Traditional databbases that have been around for a while might provide better guarantees on reliability.

(I'm the author of the GPU half of the Faiss library)

Re:Investing in new vector database development vs enhancing... by anonymousDan on Sunday November 26, 2023 @07:27AM (#38421104)
Would a graph database (e.g. Neo4j) be any better?
Re:Investing in new vector database development vs enhancing... by toasted-subs on Sunday November 26, 2023 @08:17AM (#38421376)
I cannot think of a situation where neo4j does anything better than traditional relational databases
Re:Investing in new vector database development vs enhancing... by inkyoto on Sunday November 26, 2023 @09:47AM (#38421959)
Graph databases, neo4j including, handle many-to-many relationships better than any RDBMS.
Re:Investing in new vector database development vs enhancing... by simonw on Sunday November 26, 2023 @03:44PM (#38424858)
In what way do they handle them better?
Re:Investing in new vector database development vs enhancing... by simonw on Sunday November 26, 2023 @08:08AM (#38421320)
Thanks, that was really interesting!
Re:Investing in new vector database development vs enhancing... by VoVAllen on Sunday November 26, 2023 @09:55AM (#38422001)
It's kind of a tradeoff. Performance is just one factor when choosing the vector database. In pgvecto.rs https://github.com/tensorchord/pgvecto.rs, we store the index separately from PostgreSQL's internal storage, unlike pgvector's approach. This enable us to get multi-threaded indexing, async indexing without blocking the insertion, and faster search speed comparing to pgvector.

I don't see any fundamental reason why the index in Postgres would be slower than a specialized vector database. The query pattern of the vector database is simply a point query using an index, similar to other queries in an OLTP system.

The only limitation I see is scalability. It's not easy to make PostgreSQL distributed, but solutions like Citus exist, making it still possible.

(I'm the author of pgvecto.rs)

Re:Investing in new vector database development vs enhancing... by activescott on Sunday November 26, 2023 @01:06PM (#38423566)
Very useful for me to read this (and look up some of the mentioned concepts). Thank you!
Re:Investing in new vector database development vs enhancing... by dmezzetti on Sunday November 26, 2023 @12:00AM (#38419298)
txtai can use Postgres as a data store and combine that with a vector index like Faiss or Hnswlib.

In this case, you get the robustness of Postgres (which has been around a while) and Faiss (which is one of the most mature vector indexes).

https://neuml.hashnode.dev/external-database-integration

Re:Investing in new vector database development vs enhancing... by omneity on Sunday November 26, 2023 @10:55PM (#38427868)
txtai looks cool. Did you use it before in scenarios with all 4 components?

I’m curious about which use cases it enables.

Re:Investing in new vector database development vs enhancing... by dmezzetti on Monday November 27, 2023 @06:51AM (#38431211)
In case it wasn't clear, I'm the main author of txtai.

I use txtai in my everyday work. While txtai is open source, I also support a number of consulting projects that are txtai focused. In most cases, I've used SQLite + Faiss for the vector database config paired with an LLM for RAG support.

This setup has worked well and it's what I would start with until it didn't scale.

Re:Investing in new vector database development vs enhancing... by refulgentis on Sunday November 26, 2023 @12:43AM (#38419445)
Nah you nailed it. Beyond the tech even, I don't much understand why there's a cottage industry for it. Either you're touching people's personal documents and should be doing it locally and preferably in-memory, or you're touching people's personal documents and you should own where the data is stored.
Re:Investing in new vector database development vs enhancing... by prabhatjha on Sunday December 03, 2023 @07:20PM (#38512249)
Initially I thought we need a dedicated vector database but as we tried to build even a simple gen-ai applicaitons we realized that we need another "regular" database to build a complete application.

Instead with DataStax's Vector Search, we designed a document style API and corresponding clients that give you a Vector Native experience to do CRUD of vector and meta-data as well CRUD of other data models. Here is one client ref for example https://docs.datastax.com/en/astra/astra-db-vector/clients/p...