Learn how to build an advanced Retrieval Augmented Generation (RAG) system that leverages self-querying retrieval to improve search relevance. This tutorial covers extracting metadata filters from natural language queries, combining metadata filtering with vector search, and generating structured outputs using LLMs. The guide focuses on developing an investment assistant to answer financial questions using MongoDB as the vector store and LangGraph for orchestration.
Table of contents
What is metadata? Why is it important for RAG?Extracting metadata filters from natural languageBuilding a RAG system with self-querying retrievalStep 1: Decide what metadata to extractStep 2: Install required librariesStep 3: Set up prerequisitesStep 4: Partition, chunk, and embed PDF filesStep 5: Add custom metadata to the processed documentsStep 6: Write the processed documents to MongoDBStep 7: Define graph stateStep 8: Define graph nodesStep 9: Define conditional edgesStep 10: Build the graphStep 11: Execute the graphConclusionSort: