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.

Verified sources
Processing & tagging
Semantic memory + knowledge graph
The faithful-answer layer

→ 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.

  1. Ingestion & chunking

    Books are split into passages; each passage carries precise metadata: book title, author, authority tier, volume, page number, and classification.

  2. Dense semantic embedding

    Each passage is turned into a dense vector that carries meaning across languages.

    Cohere embed-multilingual-v3.01024-dim
  3. Sparse lexical indexing

    Alongside meaning, sparse lexical vectors (BM25-style) via a custom Arabic analyzer — for verbatim matching of the seminary term.

    BM25-style sparseArabic analyzer
  4. 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.

    QDrantRRF · Reciprocal Rank Fusion
  5. Semantic re-ranking

    The model lifts the most precisely relevant to the question to the top.

    Cohere rerank-multilingual-v3.0
  6. 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.

    Redis cachequality gate
  • 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.

Concept Figure Text Evidence Issue
Exposition Support & evidence Critique & opposition Structure & correspondence

Typed nodes and colored typed relations — every thread backed by a verbatim snippet and a page number.

  1. 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.

    Neo4jLLM extractor
  2. A rich web of typed relations

    Dozens of typed relation kinds connect the entities to one another — shown below.

    Typed Relations
  3. No inference allowed

    The extractor is forbidden from inferring beyond the text; a passage with no explicit relation stays without relations. Precision before completeness.

  4. 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…).

    CanonicalEntryArabic/Persian normalization
  5. 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’.

    Sørensen-DiceAPOCGroq qwen3 · LLM Judge
  6. Structure discovery

    Graph algorithms detect knowledge communities, rank importance, and measure betweenness — to offer concept maps and interconnected clusters.

    Neo4j GDSLeidenPageRankBetweenness
  7. 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.

    vectorgraph · Cyphercommunitiesfatwa

Some of the typed relations

Affirms Relies on Opposes Branches from Corresponds to Argues by text Explains Critiques Employs a tradition Applies to reality Applied Interpreted Studied under Answers

Answers are indicative and do not replace the Sharia Inquiry Office.