10 Query generation, routing and retrieval post-processing
This chapter covers
- Generate metadata queries directly from user questions
- Convert user questions into database-specific queries (e.g., SQL, SPARQL)
- Route questions to the appropriate handler based on intent
- Enhance result relevance using Reciprocal Rank Fusion (RRF)
In chapters 8 and 9, you improved RAG answer accuracy using advanced indexing and query transformations. Indexing strengthens embedding effectiveness for broader chunks, adding richer context, while query transformations boost the precision of vector store retrieval.
Now, you’ll dive into three more advanced RAG techniques. First, you’ll learn to generate queries specific to the type of content store in use. For instance, you’ll see how to generate SQL from a user's natural language question to retrieve data from a relational database. Your setup might include several types of content stores—such as vector stores, a relational database, or even a knowledge graph database. You’ll use the LLM to direct the user’s question to the right content store.
Finally, you’ll refine the retrieved results to send only the most relevant content for synthesis, filtering out unnecessary data to maintain clarity and relevance.