Knowledge engineering
A dual GraphRAG architecture: a semantic memory and a knowledge graph that integrate to serve fidelity before intelligence.
The semantic memory
Texts are split into passages stored with multilingual semantic embeddings alongside a lexical index of the term. The retrieval is hybrid: it merges meaning-based and term-based results by rank fusion, capturing both the colloquial question and the seminary term together.
The knowledge graph
From the texts, entities are extracted — concepts, figures, questions, evidences, and texts — and relations among them: relies on, critiques, explains, studied under, his ruling, argues by text. Each relation carries a short verbatim evidence snippet from the text itself with its page number — so the whole graph is auditable by humans, thread by thread.
A principle: emptiness is legitimate
The extractor is forbidden from inferring beyond the text; a passage with no explicit relation in it stays without relations. Precision takes precedence over completeness.
Human review
New concepts enter the graph tagged ‘under review’ until scholarly oversight approves them, and merging of synonyms passes through automated nomination then human confirmation.
Why the duality?
The semantic memory answers: what did he say about X? And the graph answers: what is the relation between X and Y, and who said what about what? — together they cover the direct question, the relational question, and the overall map of a topic.
→ Arabic and Persian with one heart: how do the two languages meet in the graph?
For the curious: architectural details
What precedes is deliberately simplified. Here — for those who wish — the names and stages are stated as they are in the actual architecture, in a collapsible layer.
Book-embedding stages — the semantic memory6 stages
From a book to a searchable vector: six stages, with the source and page preserved at every step.
-
Ingestion & chunking
Books are split into passages; each passage carries precise metadata: book title, author, authority tier, volume, page number, and classification.
-
Dense semantic embedding
Each passage is turned into a dense vector that carries meaning across languages.
-
Sparse lexical indexing
Alongside meaning, sparse lexical vectors (BM25-style) via a custom Arabic analyzer — for verbatim matching of the seminary term.
-
Hybrid search in QDrant
A vector database with specialized collections — fatwas, expanded thought, deep fiqh, speeches — and the two arms (meaning and term) are merged by rank fusion.
-
Semantic re-ranking
The model lifts the most precisely relevant to the question to the top.
-
Caching & a quality gate
Caching for repeated queries, and a quality gate with calibrated relevance thresholds that prevents a weak result from being presented as an answer.
- A source and page for every passage.
- Semantic and lexical matching together.
- Re-ranking that lifts the most relevant.
- Relevance thresholds that block weak results.
Entity extraction & concept linking — the knowledge graph7 steps
From text to a web of entities and relations, all of it attributed and open to human review.
Typed nodes and colored typed relations — every thread backed by a verbatim snippet and a page number.
-
Entity & relation extraction
A language model extracts concepts, figures, issues, evidences, and texts, and typed relations among them, with a short verbatim snippet and a page number for every relation.
-
A rich web of typed relations
Dozens of typed relation kinds connect the entities to one another — shown below.
-
No inference allowed
The extractor is forbidden from inferring beyond the text; a passage with no explicit relation stays without relations. Precision before completeness.
-
A unified reference lexicon
Figures and concepts with their synonyms, auto-enriched from encyclopedic sources, and all names pass through a unified Arabic/Persian normalization function (unifying hamzas, ya, and kaf, removing diacritics…).
-
Two-layer entity alignment
Deterministic first: matching by normalized name and synonyms, and fuzzy matching by Sørensen-Dice via APOC. Then a language-model judge rules on ambiguous candidates with structured output (decision + confidence + reason) — conservative: when in doubt, it does not merge. New concepts enter tagged ‘under review’.
-
Structure discovery
Graph algorithms detect knowledge communities, rank importance, and measure betweenness — to offer concept maps and interconnected clusters.
-
Composite retrieval at query time
Four tools, the suitable one chosen by question type: vector (hybrid + re-rank), graph (generates a Cypher query then renders the relation readably with its source), communities, and fatwa.
Some of the typed relations
Answers are indicative and do not replace the Sharia Inquiry Office.