Explaining Vector Databases in 3 Levels of Difficulty Definition: What’s a Vector Database? Vector Databases: Explain It Like I’m 5 (ELI5) Explaining Vector Databases to Digital Natives and Tech Enthusiasts Explaining Vector Databases to Engineers and Data Professionals Enjoyed This Story?

-

As you may see, vector embeddings are pretty cool.

Let’s return to our example and say we embed the content of each book within the library and store these embeddings in a vector database. Now, when you must discover a “children’s book with a predominant character that likes food”, your query can be embedded, and the books which might be most just like your query are returned, corresponding to “The Very Hungry Caterpillar” or possibly “Goldilocks and the Three Bears”.

What are the use cases of vector databases?

Vector databases have been around before the hype around Large Language Models (LLMs) began. Originally, they were utilized in advice systems because they’ll quickly find similar objects for a given query. But because they’ll provide long-term memory to LLMs, they’ve also been utilized in question-answering applications recently.

Should you could already guess that vector databases are probably a solution to store vector embeddings before opening this text and just need to know what vector embeddings are under the hood, then let’s get into the nitty-gritty and discuss algorithms.

How do vector databases work?

Vector databases are capable of retrieve similar objects of a question quickly because they’ve already pre-calculated them. The underlying concept is known as Approximate Nearest Neighbor (ANN) search, which uses different algorithms for indexing and calculating similarities.

As you may imagine, calculating the similarities between a question and each embedded object you’ve gotten with an easy k-nearest neighbors (kNN) algorithm can grow to be time-consuming when you’ve gotten tens of millions of embeddings. With ANN, you may trade in some accuracy in exchange for speed and retrieve the roughly most similar objects to a question.

— For this, a vector database the vector embeddings. This step maps the vectors to an information structure that can enable faster searching.

You possibly can consider indexing as grouping the books in a library into different categories, corresponding to creator or genre. But because embeddings can hold more complex information, further categories could possibly be “gender of the predominant character” or “predominant location of plot”. Indexing can thus assist you retrieve a smaller portion of all of the available vectors and thus quickens retrieval.

We is not going to go into the technical details of indexing algorithms, but for those who are excited about further reading, it is advisable to start by looking up Hierarchical Navigable Small World (HNSW).

To seek out the closest neighbors to the query from the indexed vectors, a vector database applies a similarity measure. Common similarity measures include cosine similarity, dot product, Euclidean distance, Manhattan distance, and Hamming distance.

What’s the advantage of vector databases over storing the vector embeddings in a NumPy array?

An issue I actually have come across often (already) is: After all, you may for those who don’t have many embeddings or for those who are only working on a fun hobby project. But as you may already guess, vector databases are noticeably faster when you’ve gotten lots of embeddings, and also you don’t must hold all the things in memory.

I’ll keep this short because Ethan Rosenthal has done a significantly better job explaining the difference between using a vector database vs. using a NumPy array than I could ever write.

ASK DUKE

What are your thoughts on this topic?
Let us know in the comments below.

4 COMMENTS

0 0 votes
Article Rating
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

4
0
Would love your thoughts, please comment.x
()
x