Private-Domain RAG
a domain-adapted 3B model that beats the honestly-measured frontier — and where the real ceilings are
github.com/cuibuaa/private-domain-rag · code, paper, and every results file
Two reproducible, open-data studies on retrieval-augmented generation over a corpus a frontier model has never seen. Everything runs from the code; every number traces to a committed results file.
Study 1 — Beating the frontier under clean retrieval
On a private domain the frontier has no memorized advantage: it has to read the retrieved documents, same as a small model. Measured that way, a systematically adapted 3B model wins.
| configuration | clean | noisy | latency |
|---|---|---|---|
| 3B off-the-shelf + retrieval | 77.1 | 67.3 | 65 ms |
| 3B + distractor-RAFT | 82.3 | 75.2 | 94 ms |
| 7B off-the-shelf + retrieval | 82.3 | 71.8 | 139 ms |
| frontier-RAG, strict (honest baseline) | 77.0 | 76.4 | API |
| frontier-RAG, hybrid (public-benchmark leak) | 90.5 | — | API |
- Clean retrieval: the adapted 3B beats the honest frontier, 82.3 vs 77.0 — at ~1/5 the cost, ~94 ms, on-prem.
- Noisy retrieval: a near-tie (75.2 vs 76.4, frontier marginally ahead). I don’t claim more than that.
- Measuring the frontier honestly matters most. Its usual 90.5 drops to 77.0 once it may only read the retrieved page — 13.5 points were public-benchmark leakage, not reading.
- Domain adaptation substituted for scale here (a tuned 3B matched an off-the-shelf 7B at 2/3 the latency), and robustness to noisy retrieval turned out to be a training property, not a size one.
Study 2 — A groundedness guardrail
A distilled ModernBERT cross-encoder that flags answers the retrieved context doesn’t support, evaluated on human gold with contamination controls. It reaches 58.89 min-AUROC across the panel, above the open-detector reference (LettuceDetect, 57.3), but still trails a frontier judge at the frozen operating point — a confidence-gated cascade closes the gap at a controllable deferral cost.
The findings I was least expecting
- Adaptive routing doesn’t deliver. A calibrated router captures only 5.6–35.8% of the routing oracle’s advantage, and the savings it does reach are unsafe: cutting serving cost 5× raised served confidently-wrong answers from 0.1% to 33.5%.
- Groundedness is not correctness (44.8 AUROC as a correctness signal) — a cheap answer can be perfectly faithful to a stale retrieved page. It’s an abstention signal, not a router.
- The ceiling is usually retrieval, not the model. And when answer-recall looked stuck at ~90%, the cause was a corpus-extraction bug (dropped infoboxes), not a retrieval limit — fixing it moved recall to ~95%.