bhargavsuhagiya/cfr-retrieval
CFR Retrieval
Hybrid retrieval over the US Code of Federal Regulations, with a measured ablation and mechanically verified citations.
Regulations are public, free, and almost unsearchable. The official interface is a keyword box, so a shop owner asking "how long can I keep waste oil on site?" finds nothing — the regulation says accumulation, not store, and 90 days, not how long. That vocabulary gap is the problem this system exists to close.
This is not a chat-with-your-PDF demo. The point is not that it answers questions; the point is that every architectural decision in it has a number attached, produced by a hand-built relevance set.
Quickstart
make install
make build # fetch ~340 CFR sections, chunk 4 ways, embed 2 of them
make serve # http://127.0.0.1:8000make build takes 30-45 minutes on CPU, almost all of it embedding (it commits per batch and resumes, so an interrupt costs one batch, not the run). Nothing here needs a GPU, an API key, or a paid service.
Generation is optional. Without GEMINI_API_KEY or GROQ_API_KEY the app runs retrieval-only, which is a supported state rather than a broken one — see Degradation.
The architecture
A funnel that runs wide, then narrow.
┌──────────────┐ top 100
┌────►│ BM25 (FTS5) ├──────────┐
query │ └──────────────┘ ▼
+ filters ──┤ ┌─────────┐ 100 ┌───────────────┐
│ ┌──────────────┐ │ RRF ├───────►│ cross-encoder │
└────►│ dense vectors├────►│ fusion │ │ rerank │
└──────────────┘ └─────────┘ └───────┬───────┘
top 100 │ top 8
---
Full source, method, and the measured ablation: <https://github.com/bored-apes/cfr-retrieval>
