From the course: Advanced RAG Applications with Vector Databases

Demo: Querying

From the course: Advanced RAG Applications with Vector Databases

Demo: Querying

- [Instructor] Querying the vector database is part of what goes on behind the scenes in a RAG application. The LLM queries the vector_store to get some context back to create a response. When we interact with the RAG app, we never see this query. In this video, we're going to take a peek behind the scenes to see what the LLM sees. When we query a vector database, we get some top_k results back. For langchain FAISS, the default k is 4, as shown here. The first step to perform a vector_store query in langchain is to take our vector_store and call the as_retriever function on it. This prepares the vector_store to be queried with strings and abstracts out the necessity of turning a string into an embedding and calling a query function directly. Then, we call the invoke function of the retriever and pass a string. The result is the top four results that are in our vector_store as according to the embedding model we defined earlier.

Contents