A personal “second brain” that lets you query your Markdown notes with a Corrective RAG (CRAG) pipeline: multi-query retrieval, relevance grading, optional web search, cross-encoder reranking, and a grounded final answer with sources.
-
Ingest notes once into a local vector index (FAISS)
-
Ask questions via a LangGraph pipeline:
- Multi-query retrieval (LangChain
MultiQueryRetriever) - Grade/filter irrelevant chunks
- If nothing relevant → web search + scrape and append
- Cross-encoder rerank → keep top-k
- LLM generates answer grounded in retrieved context, with sources
- Multi-query retrieval (LangChain
-
Frontend with Streamlit
second-brain/
│
├── app.py # Streamlit UI
├── rag_graph.py # LangGraph CRAG pipeline
├── retriever.py # FAISS loader, retriever, reranker, generator
├── grader.py # LLM relevance grader (yes/no)
├── ingest.py # Build FAISS index from Markdown notes
├── web_search.py # Web search + scraping helpers
│
├── data/
│ └── notes/ # Your Markdown notes
│
└── vectorstore/ # FAISS index (local only)
python -m venv venv
.\venv\Scripts\Activate.ps1pip install -U pip
pip install streamlit langgraph langchain langchain-community langchain-openai langchain-huggingface sentence-transformers faiss-cpu python-dotenvCreate a .env file in the root:
OPENROUTER_API_KEY=your_key_herePlace your Markdown notes inside:
second-brain/data/notes/
Then run:
python ingest.pyThis builds/updates the FAISS index in:
second-brain/vectorstore/
python rag_graph.pystreamlit run app.pyIf you encounter:
ModuleNotFoundError: No module named 'torchvision'
Run Streamlit with file-watcher disabled:
streamlit run app.py --server.fileWatcherType nonevectorstore/index.pkluses pickle- Loading FAISS with
allow_dangerous_deserialization=Truecan be unsafe - Treat
vectorstore/as local-only - Do NOT commit model/index artifacts
venv/
__pycache__/
*.pyc
second-brain/vectorstore/
(Add any private note folders if needed)
Apache-2.0
A personal Second Brain built with a Corrective RAG (CRAG) pipeline: multi-query retrieval, grading, optional web search, cross-encoder reranking, and a Streamlit UI for querying Markdown notes.