Emergence of Vector Databases
Tags: vectordatabase, llm, database, machinelearning
Published: 2024-04-08 05:34:25

## But First, Why ?

Traditional databases have served us well for decades. They excel at storing and retrieving structured data like customer records, financial transactions, or product inventories. Think of them as giant spreadsheets with rows and columns, perfectly suited for precise queries and updates.

However, the world of data has evolved. Large language models (LLMs) like GPT-4 and others revolutionize how computers understand and generate human-like text. These models operate on concepts and relationships rather than simple keywords or perfect matches. They rely on nuanced meaning and contextual similarities  – something traditional databases struggle to convey.

---

## Inception of Vector Database

![inception-vectordb-lastcrown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zuf712j9vy2xy30tbgso.jpg)

Let's imagine you want to recommend a book similar to a user's favorite. A traditional database might look for exact matches for title, author, or genre. An LLM needs to `understand the book's themes, writing style, mood, and the subtle connections` that make readers say, "If you liked that, you'll love this!"

Vector databases were built to address this very need.  Instead of rows and columns, they store data as mathematical vectors ( lists of numbers/arrays ) that represent complex characteristics.  

### How is Data Stored 

![storage-vectordb-lastcrown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9dfa7a1yvx8x11ma6g9v.jpg)

Vector databases can't store raw data like PDFs or music. Lets break down the steps involved where the object to be stored is a text document  

- **Preprocessing**: This involves cleaning (lowercase conversion, removing noise and stop words), tokenizing  text into words or sentences, potentially applying [stemming or lemmatization](https://www.ibm.com/topics/stemming-lemmatization?ref=ref=https%3A%2F%2Fdev.to%2Farchie_lc) to reduce word variations.

- **Vector Embedding**: Once the data has been cleaned it goes through vectorization methods which transform preprocessed documents into high-dimensional vectors suitable for storage. Once tranformed these vectors capture the essence of the original data in a high-dimensional space. Models (like Word2Vec) convert the data into numerical vectors in a high-dimensional space. 

- **Store the Vector**: The vector, along with some metadata, is then stored in the database enabling  accurate and efficient similarity-based searches and operations. Similar vectors are stored closer to each other ( which also results in  low latency high availablity). 

> **Similarity, not Mathematical Equality**

Vector databases shine because they don't rely on exact matches. They employ distance metrics to `find items that are closest to a query, even if they don't share a single identical piece of information`.
This allows vector databases to find similar items (like recommending similar music) based on their vector distance, not just exact matches.

--- 

## How Vector Databases Empower LLMs & more 


Let's return to the book recommendation example. 

![vectordb-llm-lastcrown-archie_lc](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dssajxk0o9k53oyfrwn0.png)
 
A vector database could store the essence of each new vector representing the user's preferences based on their reading , quickly identifying books with vectors closest to the user's preference vector.

By representing books and reading preferences as vectors, `subtle nuances in theme, style and mood can be captured`. This allows the LLM to transcend basic genre/author matching and suggest books that resonate with a reader's unique taste & preference, leading to  novel literary discoveries.

**Vector databases hold immense potential and uses far beyond just book recommendation**

- **Semantic Search**: Finding relevant documents based on meaning, not just on the basis of title.  

- **Image Similarity Search**: Discover visually similar images, even with variances in angle or background conditions gaining a better context for image classification. 

- **Fraud Detection**: Spot patterns and anomalies in vast data sets that traditional systems might not be designed for.  
 
- **Personalized Recommendations**: Recommendations and  tailored products for individual users, not just broad categories in an infinite pool of products.


--- 

## The Contenders : Rising Vector DBs

![Vector-dbs-lastcrown-pinecone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ewwt5ouaiwt08vkgkdkf.png)

The rapid growth in Artificial Intelligence and Large language models have necessitated new solutions for storage and vector databases have spurred innovation, with several exciting solutions .

- **Chroma DB**: An open-source vector database known for its ease of use and focus on developer experience. Chroma offers both local and cloud-based deployment options.
[ChromaDB-🔗](https://docs.trychroma.com/?ref=https%3A%2F%2Fdev.to%2Farchie_lc)

- **Milvus**: An open-source vector database designed for flexibility and scalability. Milvus has seen substantial growth, with its parent company Zilliz recently securing $43 million in Series B funding.
[Milvus-🔗](https://milvus.io/?ref=https%3A%2F%2Fdev.to%2Farchie_lc)
    
- **Pinecone**: A fully-managed vector database offering a cloud-based solution for easy deployment and integration. Pinecone has garnered significant interest, raising a $10 million seed round.
[Pinecone-🔗](https://www.pinecone.io/?ref=https%3A%2F%2Fdev.to%2Farchie_lc)
    
- **Weaviate**: Another open-source vector database with strong modularity, allowing it to be combined with various machine learning models, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability​. 
[Weaviate-🔗](https://weaviate.io/?ref=https%3A%2F%2Fdev.to%2Farchie_lc)
    
- **Qdrant**: A high-performance vector database emphasizing speed and efficiency. Qdrant is open-source and has seen growing adoption within the community.
[Qdrant-🔗](https://qdrant.tech/?ref=https%3A%2F%2Fdev.to%2Farchie_lc)

These are just a few examples, with numerous other notable players emerging. The vast amount of code contribution and  substantial funding rounds highlight the growing belief in the importance of vector databases for the future of AI-powered applications.

---

If your business has a problem that could leverage the potential of vector database & LLMs then reach out to us for deployment and integrations . 
   
Reach Out to us

[Book a Consultation](https://cal.com/lastcrown)

[LastCrown on LinkedIn](https://www.linkedin.com/company/lastcrown)
[LastCrown on Facebook](https://facebook.com/lastcrown.in) 
[LastCrown on Instagram](https://instagram.com/lastcrown.in)