Why a Citation Validator Beats a Better Prompt
Telling a model "never invent a citation" helps. Checking every citation after it writes is what actually makes the guarantee. How 3arif verifies verses and ḥadīth in code.
The problem with prompt-only guarantees
Every RAG system tells its model the same thing: cite only what you were given. Models mostly comply. "Mostly" is not good enough when a wrong ḥadīth number or a misquoted verse has religious weight.
So 3arif.ai treats the prompt as a request and the code as the guarantee. After the model writes an answer, deterministic checks run over the text before the user sees it.
What gets checked
Ḥadīth references. Every ḥadīth the answer links must correspond to a record that was actually retrieved for this question. The report records how many were verified and lists any that were not.
Verse references. Each reference such as [Q 17:85] is parsed and compared with the verses retrieved. A verse that is real but was not retrieved is reported as not retrieved rather than silently trusted. A reference to a verse that does not exist is reported as invalid.
Verse quotations. When the answer quotes a verse in English, the quoted words are compared with the stored text of that verse (our English text is Pickthall, 1930, which is public domain). If the model paraphrased inside quotation marks, the quotation is replaced with the real wording, or relabelled as a paraphrase. A quote that cannot be matched is kept and flagged.
What the report looks like
Each streamed answer ends with a structured report. In one live research-mode answer the report listed five verse quotations as matching the stored text exactly, and four further verses (real, but outside the retrieved set) as not retrieved. Nothing was hidden, and nothing was changed that did not need to be.
Fail-safe by construction
Validation must never make an answer worse. Every step returns the original text on any error. A timeout in the checker means the user sees the model's answer, not an error page.
Why not just improve the prompt?
We did, and it helped. But a prompt cannot give a guarantee, and it cannot tell us how often it fails. The validator does both: it fixes what it can, and it produces numbers (verified, unverified, replaced) that we can track week over week.
The rule we follow: anything with a scholarly or legal consequence is fixed in code, with a test, not only in a prompt.
Every response on 3arif.ai shows which passages were retrieved and used. You can verify every claim against its source.