ai·rete·RAG combines Rete rule engine with Retrieval‑Augmented Generation for auditable decisions and natural‑language explanations

Core proposition: deterministic decisions with natural‑language explanations

ai·rete·RAG delivers auditable, repeatable decisions while automatically generating human‑readable explanations grounded in your own documents. The system couples a classic Rete rule engine (the "what") with Retrieval‑Augmented Generation (the "why"), letting you keep the precision of rule‑based logic and add the fluency of large language models.


Architecture at a glance

Three live wiring patterns let you choose how rules and retrieval interact:

  1. Rules → Retrieval – Rules act as filters before retrieval, limiting the document set to the most relevant domain (e.g., cardiology). This reduces hallucination risk.
  2. Retrieval → Rules – Retrieved documents are parsed into facts (entities, dates, obligations) and asserted into the Rete working memory; rules then fire on these facts.
  3. Decision → Narrative – The rule engine produces a decision trace first; a language model is invoked afterward solely to generate a narrative explanation anchored in the source texts.

All three patterns run live on the demo site, and each verdict is accompanied by a full audit trail.


Auditable decision pipeline

Every decision is traceable to the exact rule(s) that fired and the ones that almost fired.

  • Policy rule catalog – Users can browse the complete rule set per domain, including conditions, salience, and verdicts, without digging through raw YAML files.
  • Decision audit view – Clicking a decision reveals which rule matched, the concrete fact values that satisfied the condition, and why other rules did not.
  • Conflict detection – Static analysis flags rules that could produce contradictory verdicts on the same case, preventing production surprises.

Practical demo: credit‑approval policy

The live demo shows a classic loan‑approval policy. Adjusting the credit‑score slider from 745 to a lower value instantly flips the verdict from approved to declined, and the accompanying explanation cites the exact rule and the supporting documents that justified the change.


Community insights from Hacker News

"It's been a while since I used a Rete rule engine… we used an internal fork of Drools paired with a Merkle‑tree data structure to store lending decisions." – chews

This comment highlights that enterprises have already combined Rete engines with immutable data structures for auditability. ai·rete·RAG builds on that heritage by adding LLM‑driven explanations.

"I don't understand. If you're already building the rules, why have a clanker summarize and guess why the result happened when you can display the rules that passed/failed?" – nickphx

The concern is addressed by ai·rete·RAG’s post‑hoc narrative mode, which does not replace rule visibility but augments it with a natural‑language summary that is grounded in retrieved source documents, making the explanation accessible to non‑technical stakeholders.

"I've used Rete‑based CEP tools for utility‑operations event management… linking it to possible operating procedures based on a broader understanding of the state would be very useful." – lunatuna

This suggests a promising extension: feeding domain‑specific SOP documents into the retrieval component so that the generated narrative can suggest concrete actions, not just explain decisions.

"This is a really interesting concept. Could be quite useful for agents. I worked on something similar, but more abstract; you managed to take it to the next level." – awfm9

The comment reinforces the relevance of ai·rete·RAG for autonomous agents that need both deterministic policy enforcement and explainable reasoning.


Why the hybrid matters

  • Rule engines excel at precise, repeatable logic but lack natural‑language justification.
  • Large language models excel at fluent explanation but can hallucinate and lack deterministic guarantees.
  • ai·rete·RAG bridges the gap by using retrieval to anchor LLM output in verified documents, ensuring that explanations are both accurate and understandable.

Getting started

  1. Prepare your rule set in a Rete‑compatible format (e.g., Drools DRL or a JSON representation).
  2. Collect domain documents (policies, SOPs, regulations) that the retrieval component will index.
  3. Deploy the engine (the demo is publicly accessible; the website offers a "no‑signup" sandbox).
  4. Choose a wiring pattern based on whether you need rule‑driven retrieval, retrieval‑driven facts, or post‑hoc narratives.

Outlook

ai·rete·RAG demonstrates that deterministic decision systems can be made transparent to end users without sacrificing auditability. As more organizations adopt hybrid AI stacks, the pattern of rules → retrieval → LLM is likely to become a standard architecture for regulated domains such as finance, healthcare, and compliance.

Sources

Related

  • Project
  • Project
  • Project
  • Dispatch
  • Dispatch