Generic RAG fails in sensitive domains. When a user asks about fiqh, the cost of a confident-but-wrong answer is not a bug report — it is real harm. So we designed Masrif's retrieval pipeline around three principles: cite or abstain, prefer primary sources, and defer to qualified humans at the boundary.
Layered corpus, not a flat index
Our corpus is stratified: primary texts (Quran, canonical hadith collections) sit at layer one; classical tafsir and fiqh at layer two; contemporary commentary at layer three. Retrieval weights layers by authority and surfaces the layer in every citation, so users always know what kind of source they are reading.
Chunking is done along scholarly boundaries — ayah, hadith matn, chapter headings — never by arbitrary token windows that would sever context.
Abstention as a feature
When retrieval confidence falls below threshold, or a question touches ijtihad-level discourse, the assistant says so — plainly — and routes the user toward qualified human sources. We evaluate abstention quality as a first-class metric alongside answer quality.
“An AI that knows what it does not know is more trustworthy than one that always answers.”
Evaluation with scholars
Every model and pipeline change runs against an evaluation set reviewed with subject-matter consultants. We measure citation accuracy, source-layer correctness, harmful-confident-answer rate, and abstention appropriateness before anything reaches production.