Open-source document intelligence engine for African AI systems. Structure-aware chunking for CBK circulars, SACCO policies, court judgments, land titles, and Kenyan legislation. HTTP API · CLI · Docker.
# Hekima
> *Hekima* (Swahili) — wisdom, intelligence
**Domain-specific document chunking engine for East African AI systems.**
---
## The Problem
AI retrieval systems (RAG pipelines) fail on East African documents because they use generic chunking strategies — fixed character counts or sentence boundaries — that destroy document structure.
A CBK circular split at 500 characters loses its numbered section context. A SACCO loan policy split at sentence boundaries separates penalty clauses from the grace period conditions they govern. A Kenyan court judgment chunked generically fragments the ORDER from the FINDINGS that justify it.
**The result:** AI systems built on these documents give wrong, incomplete, or hallucinated answers — even when the correct information is in the document.
---
## What Hekima Does
Hekima detects the document type first, then applies the correct structural cutting grammar for that specific type.
Each output chunk carries:
- `section` — the structural section it belongs to (e.g. "3. Customer Data Protection Requirements")
- `doc_type` — the detected document type
- `token_count` — estimated token count for embedding model context management
- `metadata` — document-type-specific fields (e.g. `part` for legislation)
- `filename` — source document
---
## Supported Document Types
| Type | Description | Boundary Signal |
|---|---|---|
| `cbk_circular` | Central Bank of Kenya circulars | Top-level numbered sections only — subsections stay inside parent |
| `sacco_policy` | SACCO loan and operational policies | ALL-CAPS heading lines |
| `court_judgment` | Kenyan court judgments and rulings | BACKGROUND, FACTS, ANALYSIS, FINDINGS, ORDER |
| `land_title` | Land registration documents | Blank line boundaries |
| `legislation` | Kenyan Acts and Statutes | Part headers + alphanumeric section numbers (4A, 33U, 51B) |
Detection is deterministic and stateless — no ML model. The same document always produces the same result.
---
## Quickstar …