chapter two

2 Vector Similarity Search and Hybrid Search

 

This chapter covers

  • Introduction to embeddings, embedding models, vector space, and vector similarity search
  • How vector similarity fits in RAG applications
  • A practical walkthrough of a RAG application using vector similarity search
  • Adding fulltext search to the RAG application to see how enabling a hybrid search approach can improve results

Creating a knowledge graph can be an iterative process where you start with unstructured data and then add structure to it. This is often the case when you have a lot of unstructured data and you want to start using it to answer questions.

This chapter will look at how we can use RAG to answer questions using unstructured data. We’ll look at how to use vector similarity search and hybrid search to find relevant information and how to use that information to generate an answer.

In later chapters we’ll look at what techniques we can use to improve the retriever and generator to get better results when there’s some structure to the data.

In data science and machine learning, embedding models and vector similarity search are important tools for handling complex data. This chapter looks at how these technologies turn complicated data, like text and images, into uniform formats called embeddings.

This chapter will cover the basics of embedding models and vector similarity search, explaining why they are useful, how they are used, and the challenges they help solve in RAG applications.

2.1 Components of a RAG architecture

2.1.1 The Retriever

2.1.2 The Generator

2.2 RAG using vector similarity search

2.2.1 Application data setup

2.2.2 The text corpus

2.2.3 Text chunking

2.2.4 Embedding model

2.2.5 Database with vector similarity search function

2.2.7 Generating an answer using an LLM

2.3 Adding fulltext search to the RAG application to enable hybrid search

2.3.1 Fulltext search index

2.4 Concluding thoughts

2.5 Summary