This project shows how to build an Agentic RAG pipeline using LangGraph, FAISS, and DuckDuckGo Search.
The system is applied to Reinforcement Learning: An Introduction (Sutton & Barto) to answer questions grounded in the textbook, with web augmentation if the book is insufficient. You can put a book of your interst if you want.
- PDF Ingestion: Parse, chunk, and embed a textbook into FAISS for retrieval.
- Multi-hop Planning: LLM breaks down complex queries into sub-queries.
- Dual Retrieval: Search textbook first, fall back to DuckDuckGo if needed.
- Synthesis: Generate answers with inline citations to book pages and web links.
- Self-Check: Judge whether answers are evidence-grounded, revise if necessary.
- Graph Memory: Store knowledge triples to enrich future searches.
- Streamlit UI: Simple web interface to interact with the system.
git clone https://github.com/your-username/agentic-rag-rl.git
cd agentic-rag-rl
pip install -r requirements.txtCreate a .env file with your OpenAI key:
OPENAI_API_KEY=sk-xxxx
OPENAI_MODEL=gpt-xx
# optional for web search keysPlace your RL PDF (or any book) in data/ and run:
python scripts/build_index.py --pdf data/reinforcement_learning.pdf --out index/This creates:
index/pdf.index→ FAISS embeddingsindex/meta.json→ chunk metadata
Launch the Streamlit UI:
streamlit run app.pyAsk questions like:
- “Explain the Bellman optimality for Q and its intuition.”
- “What is the difference between value iteration and policy iteration?”
The system retrieves from the book, augments with web if needed, and returns a grounded answer with citations.
Read the full step-by-step tutorial here: 👉 Medium / Blog Link
Feel free to fork, open issues, or submit PRs to extend functionality (e.g., Neo4j memory backend, LaTeX rendering).
MIT License © 2025