DEV Community

Cover image for Building a Zero-Hallucination Academic GraphRAG: 1,379 Nodes, Multi-Agent Orchestration & Local SLMs
Gervais Marie
Gervais Marie

Posted on

Building a Zero-Hallucination Academic GraphRAG: 1,379 Nodes, Multi-Agent Orchestration & Local SLMs

📌 The Problem: Why Naive RAG Fails on 15+ Years of Academic Research

If you feed 450+ Master's theses and Ph.D. dissertations into a standard vector-based RAG pipeline (e.g., standard LangChain or LlamaIndex with cosine similarity over document chunks), you will quickly hit a wall.

Ask a naive vector RAG:

"How many Ph.D. theses in biomathematics were supervised by Dangbe or Kamgang between 2020 and 2025?"

The vector database retrieves isolated chunks mentioning "Dangbe", "Kamgang", "Ph.D.", and "biomathematics". Then, the LLM starts guessing:

  • It hallucinates counts.
  • It conflates Master's theses with Ph.D. dissertations.
  • It cannot aggregate, group by date ranges, or traverse relationship trees.

Vector similarity finds topical proximity, not relational ground truth.

To preserve, query, and valorize 15+ years of scientific research at the Department of Mathematics and Computer Science (DMI) of the University of Ngaoundéré (Cameroon), we architected K1-MATHINFO (v3.2): a sovereign, zero-hallucination Multi-Agent GraphRAG system backed by Neo4j, OKF Ontologies, and local Small Language Models (SLMs) fine-tuned with GRPO.


System Architecture & Multi-Agent Orchestration

Instead of relying on a single monolithic LLM prompt, we built a deterministic multi-agent supervisor pipeline:

                 +--------------------------------+
                 |       User Natural Query       |
                 +---------------+----------------+
                                 |
                     [Input Guardrail & Anti-PII]
                                 |
                     +-----------v------------+
                     |  SupervisorAgent v4.0  |
                     |  Intent & Complexity   |
                     +-----------+------------+
                                 |
      +--------------------------+--------------------------+
      |                          |                          |
+-----v------------+   +---------v--------+   +-------------v----+
|  GraphRAGAgent   |   | MathFormalisme   |   |     OKFAgent     |
| (Neo4j Cypher &  |   | (KaTeX Certified |   | (Ontology Fact   |
| Multi-Hop Paths) |   | Specifications)  |   |  Store v0.2)     |
+-----+------------+   +---------+--------+   +-------------+----+
      |                          |                          |
      +--------------------------+--------------------------+
                                 |
                     +-----------v------------+
                     | CriticFactCheckerAgent | <--- Strict Tier-1 Audit Gate
                     | (Refutes Unproven Data)|      (No Hallucination Allowed)
                     +-----------+------------+
                                 |
                 +---------------v----------------+
                 | Certified Answer + KaTeX LaTeX |
                 +--------------------------------+
Enter fullscreen mode Exit fullscreen mode

📂 Document Ingestion & Knowledge Graph Construction

How did we turn 15 years of dusty university archives into a live relational graph?

  1. Multimodal Extraction & OCR: Ingestion of 451 PDFs and scanned defense monographs spanning 2008 to 2026.
  2. Semantic Entity Normalization: Disambiguating variations of supervisor names, juries, laboratory tags (LAMAP, LAMEX, LARI, LASE), and research domains.
  3. Graph Instantiation: Generating declarative Cypher statements into Neo4j:
    • 1,379 Nodes (Documents, Authors, Supervisors, Algorithms, Models, Datasets)
    • 3,871 Certified Relationships (SUPERVISED_BY, AUTHORED_BY, APPLIES_ALGO, FORMULATES_MODEL)
    • 19 Strict Labels ensuring type safety.

The OKF Ontology (v0.2) & WikiSkill Architecture

To prevent semantic drift, we deployed a dual-grounding mechanism:

  • OKF (Ontology of Known Facts v0.2): A curated repository of 83 formal scientific ontology sheets mapping departments, sub-disciplines, methodologies, and institutional constraints.
  • WikiSkill Layer: Modular, self-contained procedural skills loaded dynamically by agents (e.g., fractional calculus derivation skill, Post-Quantum cryptography verification skill, Cypher query builder skill).

Local SLMs Fine-Tuned via GRPO (Group Relative Policy Optimization)

Rather than bleeding proprietary academic data into public cloud APIs, we run 4B parameter Small Language Models (SLMs) completely locally on edge workstations.

  • Why GRPO over PPO? Traditional RLHF with PPO requires a separate reward model taking up critical VRAM. GRPO (Group Relative Policy Optimization) samples multiple candidate reasoning paths for mathematical and graph queries, evaluating them comparatively against our deterministic Neo4j graph ground truth.
  • Result: The local 4B model achieves near-zero hallucination on specialized academic prompts, with sub-2-second inference on standard hardware.

Real-World Complex Benchmarks (Stress Tests)

Here are three complex queries that consistently break standard commercial LLMs, but succeed deterministically on K1-MATHINFO:

Test Case 1: Filtered Ph.D. Counting with Multiple Supervisors & Date Window

Query: "How many Ph.D. theses in biomathematics were supervised by Dangbe or Kamgang between 2020 and 2025 at DMI?"

MATCH (s:Supervisor)<-[:SUPERVISED_BY]-(d:Document)-[:AUTHORED_BY]->(a:Author)
WHERE d.degree IN ['Doctorat', 'Ph.D']
  AND (toLower(s.name) CONTAINS 'dangbe' OR toLower(s.name) CONTAINS 'kamgang')
  AND d.year >= 2020 AND d.year <= 2025
RETURN d.title AS title, d.year AS year, s.name AS supervisor, a.name AS student
ORDER BY d.year DESC
Enter fullscreen mode Exit fullscreen mode

Outcome: Returns exactly 5 certified dissertations (Fotso Christophe 2025, Laye Paul 2025, Kamgang Jean Claude 2023, Mbounja Besseme 2021, Tchappi Haman Igor 2020). Zero hallucination.

Test Case 2: Multi-Hop Student Trajectory (Supervisor Switching)

Query: "Are there students who changed supervisors between their Master's thesis and their Ph.D. dissertation?"

  • Vector RAG: Fails completely (unable to correlate student IDs across multiple degree cycles).
  • K1-MATHINFO: Traverses (a:Author)-[:AUTHORED_BY]->(d1:Master)-[:SUPERVISED_BY]->(s1) vs (a)-[:AUTHORED_BY]->(d2:PhD)-[:SUPERVISED_BY]->(s2) where s1 <> s2, isolating the exact trajectory.

Test Case 3: Departmental Discipline Ratios

Query: "What is the exact ratio between Computer Science and Mathematics theses defended at DMI?"

  • Outcome: Resolves the exact breakdown: 345 Computer Science (76.5%) vs 106 Mathematics (23.5%) (Ratio 3.25:1, 42 vs 18 Ph.D. theses).

Formal Mathematical Modeling (Native KaTeX)

Academic validation requires exact symbolic notation. The MathFormalismeAgent injects mathematically certified formulas rendered directly via KaTeX:

  • Caputo Fractional Differential SEIR Model:

    DtαS(t)=Λ−βSIN−μS \mathcal{D}_t^\alpha S(t) = \Lambda - \beta \frac{S I}{N} - \mu S
  • Artin Braid Group Definition (Post-Quantum Cryptography):

    Bn=⟨σ1,…,σn−1∣σiσi+1σi=σi+1σiσi+1⟩ B_n = \langle \sigma_1, \dots, \sigma_{n-1} \mid \sigma_i \sigma_{i+1} \sigma_i = \sigma_{i+1} \sigma_i \sigma_{i+1} \rangle
  • Also includes native formalisms for Garside Normal Forms, Supersingular Isogenies (SIDH/CSIDH), and Hilbert Space-Filling Curves.


The Zero-Hallucination Arbiter: CriticFactCheckerAgent

In scientific research, an AI model must never output unverified text directly to the end user.

The CriticFactCheckerAgent acts as an institutional gatekeeper:

  1. Source Graph Audit: Every name, year, formula, and thesis title generated by sub-agents is verified against the Neo4j graph.
  2. Tier-1 Certification Seal: Responses grounded by 100% verified facts receive a TIER-1 : OFFICIELLEMENT CERTIFIÉ seal.
  3. Institutional Boundary Enforcement: When queries probe out-of-scope subjects (e.g., asking for Chemistry dissertations in a Math/CS faculty, or historical external scientists like Turing or Einstein), the system issues a polite, certified institutional refutation instead of hallucinating fictitious works.

Replicability: Sovereign AI for Higher Education in Africa

What we built for the University of Ngaoundéré was intentionally engineered as a reusable blueprint.

Across Africa, hundreds of faculties of Engineering, Medicine, and Pure Sciences possess decades of high-value research sleeping on physical shelves. By packaging:

  • A generic academic Neo4j property graph schema,
  • Modular agentic supervisors & fact-checkers,
  • Containerized local SLM inference (Docker + GGUF),

...any university can deploy its own Sovereign Research Memory within days, keeping its intellectual property completely safe, local, and accessible.


What's Next?

Our architecture is completing its final validation phase before the official public defense before the DMI academic jury.

Have you tackled multi-hop aggregation with GraphRAG in production? How do you ensure mathematical precision without hallucinations? Let's discuss below! 👇

Top comments (0)