How the Controllable RAG Agent works
mainThe agent uses a deterministic graph to act as a reasoning engine for complex RAG tasks. The workflow follows these stages:
- Data Processing: PDF loading, chapter splitting, text preprocessing, and LLM-based summarization of chapters.
- Indexing: Creation of a Book Quotes Database and encoding content/summaries into vector stores (FAISS).
- Question Processing:
- Anonymization: Replacing named entities with variables to prevent LLM bias from pre-trained knowledge.
- Planning: Generating a high-level plan for the anonymized question, then de-anonymizing it into specific tasks.
- Task Execution: For each task, the agent decides whether to retrieve information from vector stores or answer directly using Chain-of-Thought reasoning.
- Verification & Re-planning: Verifying that generated content is grounded in the context and updating the plan based on new information.
- Final Answer: Generating the final response using accumulated context and Chain-of-Thought reasoning.