[GENAI-001] · Databricks · Live
BSA/AML Regulatory RAG
Area · GenAI
Stack · LangChain · Gemini 2.0 · ChromaDB · BM25
Dataset · FFIEC BSA/AML Examination Manual
Live
Overview
Architecture
GitHub
The Problem
"Our compliance team spends hours searching the FFIEC manual to answer internal policy questions. We need a faster and more reliable way to query regulatory documentation."
Every financial institution operating in the United States must comply with the Bank Secrecy Act and Anti Money Laundering regulations. The documentation is dense: FinCEN guidelines, FFIEC manuals, SAR filing requirements, and compliance teams spend significant time navigating it manually.
This project builds a retrieval augmented generation system that answers regulatory questions in plain English, with every response citing the exact source document, section, and page number. The system uses a hybrid retrieval approach and is configured to run deterministically at temperature 0.0.
What It Delivers
Query speed
Regulatory questions that take 20 to 40 minutes to answer manually are answered in under 10 seconds.
Source citation
Every answer references the exact document, section, and page. Compliance officers can verify the source without relying on the model alone.
Pluggable stack
The LLM, embedding model, and vector store are all configurable via a single .env file. No code changes required to swap any component.
Deterministic output
Temperature is fixed at 0.0. The same question asked twice returns the same answer, which is a requirement in any compliance context.
Pipeline Overview
Fig. 1 · End to end pipeline. All layers are configurable via config.py and .env.
Key Decisions
Temperature 0.0
Regulatory answers must be deterministic. Any temperature above zero introduces variability, and the same question can return different answers, which is not acceptable in a compliance context.
Hybrid retrieval
Regulatory documents use precise legal terms such as "structuring" and "SAR". Pure semantic search does not reliably match these. BM25 keyword search covers what embeddings miss. The union of both returns better results than either alone.
Chunk size 500
Regulatory text is dense. Larger chunks mix multiple obligations into a single unit, reducing retrieval precision. 500 characters keeps each chunk semantically focused without losing context.
Mandatory citation
The generation prompt instructs the model to cite the source page for every claim. This is enforced at the prompt level, not trusted to model behavior alone.
Repository
bsa-aml-rag/
├── README.md
├── requirements.txt
├── .env.example
├── config.py
├── src/
│ ├── __init__.py
│ ├── ingestion.py
│ ├── processing.py
│ ├── embedding.py
│ ├── retrieval.py
│ └── generation.py
├── notebooks/
│ └── quickstart.ipynb
└── data/
└── BsaAmlManualSectionsPackage.pdf
Stack: LangChain, Gemini 2.0 Flash, Gemini Embedding 001, ChromaDB, BM25 (rank_bm25). Python 3.11 or higher. Requires a Google AI Studio API key, free at aistudio.google.com.