A control-freak RAG agent that actually reads the manual
Built to answer complex questions that simple vector search cannot solve, using a controllable graph that plans, anonymizes, and verifies.

What it does
This project implements a Retrieval-Augmented Generation agent that answers involved questions from your own documents using a deterministic graph architecture. It preprocesses PDFs into chunks, chapter summaries, and a quotes database, then executes multi-step plans to retrieve and reason over the content. The agent evaluates its own output with Ragas metrics for correctness, faithfulness, and relevancy.
The interesting bit
Before planning, the agent anonymizes questions by replacing named entities with variables, which forces the LLM to sketch a generic reasoning path without leaning on its pre-trained knowledge. It then de-anonymizes the plan into concrete retrieval or answering tasks, verifies that generated content is grounded in the original context, and re-plans remaining steps based on what it finds.
Key highlights
- Deterministic graph-based “brain” that breaks complex queries into manageable sub-tasks and adapts the plan as new information arrives
- Question anonymization to prevent the LLM from exploiting pre-trained knowledge instead of retrieved documents
- Multi-layered retrieval across chunked content, chapter summaries, and specific book quotes
- Hallucination checks that verify answers are grounded in source context before final generation
- Built-in Ragas evaluation for answer correctness, faithfulness, relevancy, recall, and similarity
Verdict
Worth exploring if you are researching multi-step RAG architectures or need a reference implementation for controllable document Q&A. Skip it if you are looking for a drop-in library or a production-ready backend service.
Frequently asked
- What is NirDiamant/Controllable-RAG-Agent?
- Built to answer complex questions that simple vector search cannot solve, using a controllable graph that plans, anonymizes, and verifies.
- Is Controllable-RAG-Agent open source?
- Yes — NirDiamant/Controllable-RAG-Agent is open source, released under the Apache-2.0 license.
- What language is Controllable-RAG-Agent written in?
- NirDiamant/Controllable-RAG-Agent is primarily written in Jupyter Notebook.
- How popular is Controllable-RAG-Agent?
- NirDiamant/Controllable-RAG-Agent has 1.6k stars on GitHub.
- Where can I find Controllable-RAG-Agent?
- NirDiamant/Controllable-RAG-Agent is on GitHub at https://github.com/NirDiamant/Controllable-RAG-Agent.