Semantic Search in RAG Applications: Vector Databases

Faraaz Khan
4 min readFeb 13, 2024

As we continue developing ASKTOPDF, it’s time to understand the concept of a vector database. After preprocessing the data and applying chunking techniques, we will store this processed data for similarity search. But before that, let’s understand what a vector database is.

In the next post, we’ll discuss embeddings, which are the numerical representations we’ll create for our data before storing them in the vector database.

In the era of big data, the demand for efficient and scalable databases capable of handling high-dimensional data is greater than ever. Traditional relational databases fall short when it comes to processing complex data types like images, audio, and text. This is where vector databases come into play, offering a paradigm shift in how we store, retrieve, and analyze data.

Understanding Vector Databases

Vector databases, also called vector stores, are databases designed for handling high-dimensional vectors. These vectors represent data points in a space where each direction stands for a different aspect of the data.

Imagine you have a bunch of houses, and you want to store information about them, like size, location, and price. In a vector database, each house would be represented as a point in a space where one direction represents size, another direction represents location, and so on.

Now, let’s say you want to find houses similar to a given one. Instead of searching for exact matches like traditional databases, a vector database uses special methods to find houses that are similar based on their positions in this multi-dimensional space.

So, in simple terms, a vector database helps find similar things based on their features, not just their exact values.

Let’s simplify it further in context with ASKTOPDF

Imagine you have a bunch of text documents, like articles or emails. Each document has its own unique characteristics, like the words it contains and how often those words appear.

Now, think of each document as a point in space, where each dimension represents a different word.

For example, if you have three words — “cat”, “dog”, and “fish” — then each document can be represented as a point with three coordinates, indicating how many times each word appears.

So, if you want to find documents that are similar to a given one, a vector database helps by looking at how close these points are in space. It doesn’t just look for documents with the exact same words, but ones that are similar based on the words they contain.

In simpler terms, a vector database helps find similar text documents by comparing the words they use, rather than just matching them exactly.

How Do Vector Databases Work?

How ASKTOPDF uses Vector Database behind the scenes :

User Query:
When you ask a question or request something in the ASKTOPDF app, your input is sent for further processing

Embedding Creation:
The application converts your input into a numerical form called vector embeddings. This is a mathematical representation of your query.

Database Comparison :
Now in the Vector database, we compare user query embeddings with the embeddings which are already stored in the database and search for the most similar vectors/values.

Response :
Once the most similar codes are found, the application puts together a response with information related to your question. This response is sent back to you.

When you ask more questions later on, new codes are made for them. These new codes are used to find similar ones in the database and so on

By leveraging vector databases for similarity search, the document chat application can deliver personalized and contextually relevant message recommendations, enhancing the user experience and increasing engagement.

Conclusion
Vector databases represent a groundbreaking approach to managing high-dimensional data and enabling similarity search across various domains. Whether it’s powering recommendation systems, content discovery platforms, or chat applications, the adoption of vector databases is poised to drive innovation and unlock new possibilities in data-driven applications.

Next Steps: Generating Embeddings

In our next post, we’ll delve deeper into the intricacies of generating embeddings for our ASKTOPDF application. We’ll explore various techniques and methodologies to create embeddings that effectively capture the essence of our data, paving the way for robust similarity search capabilities.

Stay tuned as we continue to unlock the full potential of ASKTOPDF by harnessing the power of vector databases and embeddings to deliver unparalleled search experiences.

--

--