# LangChain Advanced RAG

An HR policy question-answering example built with LangChain LCEL that classifies whether a question is in scope before retrieving from a local FAISS index, refusing to answer out-of-scope questions.

LangChain Advanced RAG is an example project, organized from an original notebook teaching case into a full GitHub project with an API and tests, that answers questions about an HR policy handbook. It reads a Markdown employee handbook, splits it into semantic sections by heading, and builds a local FAISS vector index; when a question comes in, an LLM first classifies whether the question is within HR scope using recent conversation history, and a LangChain RunnableBranch then routes it to retrieval-and-answer or a direct refusal.

Compared to a naive RAG pipeline that only retrieves and generates, this project adds the scope classification guardrail, conditional routing, and a rolling window of the last 50 messages for multi-turn context, with the executed path shown in the frontend. The current version uses single-path vector similarity retrieval only, without hybrid BM25 search, query rewriting, or a reranking model, which the README notes explicitly as scope not yet included, despite the name "Advanced" referring to its orchestration rather than its retrieval technique.

It exposes a FastAPI REST API with Swagger docs and a responsive web UI, and includes unit tests and GitHub Actions.

Website: https://github.com/marc-ing/langchain-advanced-rag
