The problem
Teachers in Kuwait write lesson plans, short quizzes and worksheets every week. Each subject department expects a strict paper format and the content has to follow the official textbook page by page. Generic LLMs fail three ways: they invent facts that aren’t in the book, ignore the format, and break right-to-left Arabic print layout.
What I built
- Arabic RAG pipeline. A deterministic lesson resolver maps a school lesson to the exact book pages, then hybrid retrieval (BGE embeddings + BM25, fused with RRF) scoped by grade, subject, term and lesson, then cross-encoder reranking.
- Guardrails in code. A pre-generation similarity gate refuses before the model is called; every citation must be a retrieved chunk; every quoted span must exist in the cited chunk; exam questions must be answerable from specific pages.
- Verification chain. Worksheets: a fast GPT model drafts, a stronger GPT model blind-solves and judges, then deterministic rules check them (no ambiguous items, key ↔ blank alignment, page fill ≥ 95%).
- The product around it. Provider-agnostic AI gateway (keys moved off the mobile app), PDF + Word renderer with RTL validators, feature flags, kill switches, staging → production with immutable releases and one-line rollback.