Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RAG That Works in South Africa: Cheap, Fast, an...

RAG That Works in South Africa: Cheap, Fast, and Compliant Approaches Any Company Can Implement

A practical roadmap for building RAG systems under real-world South African constraints — POPIA compliance, load shedding, and ZAR/USD cost volatility. Walks through a 7-phase maturity model from simple local RAG through hybrid search, multimodal parsing, multi-step reasoning, GraphRAG, and agentic RAG, plus a governance framework for role-based access control and a benchmarking approach for proving your system isn't hallucinating. Originally presented at DevConf South Africa 2026.

Avatar for Abed Matini

Abed Matini

August 19, 2026

More Decks by Abed Matini

Other Decks in Technology

Transcript

  1. [ DevConf 2026 ] RAG that works in South Africa:

    cheap, fast, and compliant approaches any company can implement 29-Jun-26 By Abed Matini 1 Senior Backend Developer at
  2. [ DevConf 2026 ] Why global RAG advice breaks in

    South Africa? • Regulatory (POPIA) Strict rules restrict sending sensitive data to foreign cloud APIs. • Currency Risk ZAR/USD volatility makes cloud token costs unpredictable. • Connectivity Load shedding and unreliable internet disrupt cloud-only operations. • Legacy Infrastructure 29-Jun-26 Scanned PDFs and messy tables break standard parsers. 3
  3. [ DevConf 2026 ] The South African reality just became

    draft law • Draft SA National AI Policy gazetted on 10 April 2026. • Public comments close: 10 June 2026. • The 3-Year Plan: ✓ Year 1 (2025/26): Finalize Policy & target unacceptable risks. ✓ Year 2 (2026/27): Guidelines & high-risk regulations. 29-Jun-26 ✓ Year 3 (2027/28): Full implementation & audits. 4
  4. [ DevConf 2026 ] Draft AI Policy Framework for RAG

    • Data Sovereignty (9.3.2) Local RAG is the primary defense against prohibited RAG citations provide the "interpretable and "data extraction". contestable" architecture required for high-risk AI. 29-Jun-26 • Human-in-the-loop (9.6.1) 5 • Explainability (9.6.2) • Liability (7.1) Agentic frameworks must include manual Hallucinations are now legal liabilities, overseen by checkpoints for critical decisions. the new AI Ombudsperson.
  5. [ DevConf 2026 ] The POPIA & connectivity matrix Local

    Deployment Required for highly sensitive data under strict POPIA rules or areas with poor internet. Cloud Deployment Safe for low-risk or public data backed by reliable fibre connectivity. Hybrid RAG (Default) 29-Jun-26 Routes safe queries to the cloud while strictly keeping sensitive data local. 6
  6. [ DevConf 2026 ] The Reality of ZAR vs. USD

    (Cost Over Time) • Cloud RAG Low initial setup, but long-term scaling costs are inflated by ZAR/USD exchange rate volatility. • Local RAG Higher upfront hardware investment, but guarantees stable and predictable operational costs over time. • Hybrid Advantage: 29-Jun-26 Balances the initial hardware investment with controlled, predictable monthly costs. 7
  7. [ DevConf 2026 ] Phase 1: Secure Local RAG The

    Concept: A 100% private, offline search engine built on RBAC. The Trigger: Zero API budget + strict POPIA mandates. The Governance Trap: Local storage is not enough; you must protect against internal threats. The Fix (Locks on the inside): • Never raw-dump data; access control precedes retrieval. • Attach metadata tags (e.g., Dept: HR, Clearance: L3) to vector chunks. { "chunk_id": "doc1_part3", 29-Jun-26 "text": "...", 9 "allowed_groups": ["hr","managers"], "owner": "john.doe“ } • Verify Active Directory credentials first, making unauthorized data mathematically invisible. Suggested Stack: Llama 3 (8B) via Ollama + Qdrant/Milvus
  8. [ DevConf 2026 ] Phase 2: Solving the Connectivity &

    Budget Squeeze (Chunk-Rank) • The Concept: A "smart filter" that mathematically scores and filters relevant documents before sending them to the LLM. • The Trigger: Basic search retrieves irrelevant data, wasting expensive compute resources. • The Financial Win: By actively preventing the system from processing useless data, you avoid massive token usage and mitigate ZAR/USD exchange rate volatility. Suggested Stack: • Combine BM25 Keyword Search + Vector Search. 29-Jun-26 • Local Reranker like BAAI/bge-reranker-v2-m3. 10
  9. [ DevConf 2026 ] Phase 3: Solving the "Ugly Data"

    Crisis (Multi-Vector RAG) • The Concept: Search easy-to-read text summaries, but retrieve the original "messy" visual files for the AI to analyze. • The Trigger: Standard parsers break when reading scanned Home Affairs IDs and blurry SARS ITA34 tax documents. 29-Jun-26 • How it Works: The system creates a clean text summary of the scanned PDF to make it searchable, but hands the raw image to a Vision LLM to preserve rich visual context. 11 • Suggested Stack: Unstructured.io / ColPali for parsing, Llama-3.2-Vision (Local).
  10. [ DevConf 2026 ] Phase 4: Solving Complex Cross-Referencing (Multi-Step

    RAG) • The Concept: Breaking complex questions into smaller "search missions". • The Trigger: The AI fails when asked to compare disparate data, like "Compare 2023 vs 2024 Policy". • How it Works: • Step 0: "Query Rewriting” • Finance: Splits "Q1 vs Q2" into two distinct retrievals. 29-Jun-26 • HR: Compares "2023 vs 2024 Policy" sequentially. 12 • Suggested Stack: LlamaIndex (Query Pipelines) or LangChain.
  11. [ DevConf 2026 ] Phase 5: Solving the Macro-Summary Bottleneck

    (Map-Reduce RAG) • The Concept: Summarizing massive document batches simultaneously without hitting token limits. • The Trigger: Stakeholders need "big picture" macro-level insights across 500+ reports. Process: • Map: Batch documents -> Generate mini-summaries. • Reduce: Synthesize mini-summaries -> Final master report. 29-Jun-26 • Suggested Stack: LangChain MapReduceDocumentsChain 14
  12. [ DevConf 2026 ] Phase 6: Solving Hidden Compliance Webs

    (GraphRAG) • The Concept: Building a "detective string-board" Knowledge Graph to uncover hidden structural relationships. • The Trigger: Mapping complex webs like procurement fraud, vendor relationships, or POPIA impact zones. How it Works: • Extraction: LLMs extract Entities (People, Systems) and Relationships (Ownership, Access). • Knowledge Graph: Connects the dots across disparate, disconnected documents. 29-Jun-26 • Suggested Stack: Microsoft GraphRAG, Neo4j, LlamaIndex Property Graphs , or PostgreSQL + Apache AGE for standard Cypher queries. 15 Warning: LLM-generated GraphRAG is incredibly expensive, slow, difficult to maintain, and often yields weak production ROI.
  13. [ DevConf 2026 ] Phase 7: Solving the Automation Bottleneck

    (Agentic RAG) • The Concept: Giving the AI "hands" to interact with company systems (e.g., executing SQL, logging Jira tickets, emailing site managers). 29-Jun-26 • Suggested Stack: Gemini 2.5 Pro or GPT-4o with LangChain/CrewAI. 16 • The Warning: Because we established metadata filtering and RBAC in Phase 1, the Agent cannot go rogue on sensitive systems. Human-in-the-loop checkpoints are mandatory.
  14. [ DevConf 2026 ] Phase 7b: The Compliance Key for

    Agents (Agentic Consent) Ensuring agents act with us, not instead of us. • Dynamic Consent : Move from static checkboxes to context-aware, living contracts. • Identity Verification: Cryptographically verify agent actions against Active Directory clearance. • Granular & Transaction-Based Access: Restrict agents to specific actions (e.g., read-only) for a 29-Jun-26 narrow transaction window. 17 • Just-in-Time Prompting (The Human-in-the-Loop): Mandate explicit human consent before processing sensitive data. • POPIA alignment: Ensure agent actions are transparent, revokable, and customizable by the user.
  15. SAMPLE FOOTER TEXT We locked our data in a local

    vault to comply with POPIA. 29-Jun-26 But who is protecting your data from the inside? 18
  16. [ DevConf 2026 ] The governance trap (context before retrieval)

    The Risk: AI bypassing standard folder restrictions to answer unauthorized internal queries. The Fix: Metadata + RBAC (Role-Based Access Control) • Attach permission tags (Department, Clearance Level) to stored vector chunks. • Mandated by AI Policy: Data Minimisation & Purpose Limitation The Golden Rule: Access control must precede retrieval; never 29-Jun-26 raw-dump data. 19 Suggested Stack: Qdrant, Milvus, or Weaviate
  17. [ DevConf 2026 ] Proving It Works (Benchmarking) The Concept:

    Mathematically proving your AI is accurate, safe, and hallucination-free. The Trigger: The executive team asks, "How do we know it works?" • Step 1: The Golden Dataset • 30–50 difficult, real-world business questions with expert-verified answers. • Step 2: The RAG Triad 1. Context Relevance: Did it retrieve the right document? 2. Faithfulness: Did it stick strictly to the facts (no hallucinations)? 3. Answer Relevance: Did it actually answer the user's question? 29-Jun-26 Cost hack: Use Regex for citation checking. 21 Suggested Stack: Ragas or TruLens. Mandated by AI Policy: Achieving 'Sufficient Explainability'
  18. [ DevConf 2026 ] The 5-Minute Sanity Check (No Code

    Required) 29-Jun-26 The Goal: Troubleshooting your Local RAG database. 22 • Test 1 (Blind Test): Ask the question without data. It should fail. (Ensures the AI isn't just guessing from its training). • Test 2 (Copy-Paste Test): Paste the entire document into the chat. If it passes, the LLM is smart enough to understand your data • Test 3 (RAG Test): Run it through the system. If it fails now (but passed Test 2), your chunking/retrieval is the problem.
  19. [ DevConf 2026 ] The South African RAG Cheat Sheet

    (Summary) 1. Simple RAG: Zero Budget / POPIA? Run it locally. 2. Chunk-Rank: Accuracy failing? Add a local Reranker & Hybrid Search. 3. Multi-Vector: Scans & Tables? Summarize for search, read raw visuals. 4. Multi-Step: Need Comparisons? Split prompts into missions. 5. Map-Reduce: 500+ Document Summary? Batch and merge summaries. 6. GraphRAG: 29-Jun-26 7. Agentic RAG: 23 Hidden Fraud/Links? Build a Relationship Graph. Need to Automate? Connect tools (SQL, Email, Jira).
  20. [ DevConf 2026 ] Monday morning action plan Step 1:

    The POPIA & Data Audit Assess sensitivity to rule out pure Cloud RAG. Step 2: The "Ugly Data" Test Run text extraction tests on messy, real-world docs (IDs, SARS ITA34). Step 3: The Local Sandbox Deploy Llama 3 locally, ensuring metadata tagging is active for compliance. (Chunking rule: Use 512 tokens, 25% overlap) Step 4: The Executive Pitch Run a "Golden Dataset" to mathematically prove zero hallucinations and 29-Jun-26 calculate OPEX savings against volatile USD cloud pricing. 24 Prove Safety: Use TruLens to generate a printable report proving Faithfulness— mathematically.