Skip to content
S/N
Selected work
09 — AI & Applied Technology

Every answer cited. Every doubt handed to a person.

Type
technical
Role

Designed and built the whole reference implementation end to end

Context
In government, AI earns trust only when it is accurate, explainable and secure. A policy answer has to point to its source, admit when it is unsure, and hand over to a person. This project shows that whole discipline in one working system.

01The brief

Answers questions about the UAE AI Charter, International Stance on AI Policy, AI Ethics guidelines and PDPL, with a citation on every sentence, groundedness checks and a human reviewer for low-confidence answers. Built end to end: retrieval, agent, safety, security, release gates, monitoring and documentation.

In government, AI earns trust only when it is accurate, explainable and secure. A policy answer has to point to its source, admit when it is unsure, and hand over to a person. This project shows that whole discipline in one working system.

Azure OpenAI and Azure AI Search (hybrid BM25 plus vector, Arabic and English analyzers) behind a Semantic Kernel agent, served by FastAPI on Azure Container Apps. A fine-tuned multilingual DistilBERT query classifier is tracked with MLflow, registered in Azure Machine Learning and served as ONNX. Infrastructure is Bicep, delivery is GitHub Actions with an evaluation gate, and the Fabric lakehouse holds the governed gold layer.

Challenges

  • Answers must be grounded in official text, in Arabic and in English, and checkable by the reader
  • Unsafe input, prompt injection and personal data (Emirates ID, +971 numbers, IBAN) must be stopped, and the system must fail closed
  • A quality drop must be caught before users see it, not after
  • Everything must be explainable and documented for a government reviewer, not just working

02How it works

Purpose

Turn official public PDFs into clean, searchable passages in both languages.

Inputs

  • → 8 official documents in English and Arabic: UAE AI Charter, International Stance on AI Policy, AI Ethics Principles and Guidelines, PDPL

Outputs

  • ← 196 passages with page numbers
  • ← A bilingual search index (Arabic and English analyzers, vectors)

Considerations

  • Azure Document Intelligence reads the PDFs, then an Arabic-aware chunker splits them
  • The PDPL site blocks automated downloads, so it was added from its official text as cleaned Markdown
  • Data-quality gates (metadata, classification label, length, language, duplicates, OCR) stop a bad batch before embedding

03Approach

My role

  • Designed and built the whole reference implementation end to end

Approach

  • Hybrid retrieval over a single bilingual index, so a question in either language finds sources in both
  • An agent that plans, retrieves, answers and then checks itself, with a human review queue for low confidence
  • Safety and privacy built into the request path: Content Safety, Prompt Shields, and PII masking before logging
  • An evaluation gate in the release pipeline, with golden and red-team test sets, so a quality drop blocks deployment
  • Documentation as a deliverable: decision records, model and data cards, a threat model, a risk register and a runbook
Check the answer before trusting it
Every sentence carries a citation with a page number. A second model call judges whether the answer is grounded in what was retrieved, and a low score sends it to a person instead of the user.
A release gate, not a hope
The evaluation runs on every release against a golden set and a red-team set. The first version failed it, which is the point of having it.
Small model for the easy part
A fine-tuned DistilBERT classifier, served as int8 ONNX at about 20 ms per question on a CPU, skips the large model when a question is clearly out of scope. It only acts when it is at least 90% confident.
Container Apps, not AKS
The live app runs on Container Apps, which scales to zero. The Helm chart is still validated on a Kubernetes cluster in CI on every push.
Keyless by default
Managed identity, Key Vault and OIDC deployment, so there are no stored secrets to leak.

04Results

  • 0.98

    Groundedness

  • 0.90

    Retrieval recall@5

  • 23 of 24

    Red-team questions handled

  • $0.0017

    Cost per question

  • 8

    Documents indexed

  • 0.81

    Classifier accuracy

  • The first evaluation run failed its own gate at a 0.72 answer rate. The causes (free-tier throttling, a narrow planner scope, over-cautious handling of numbered lists) were found and fixed, and the second version passed
  • On the current 8-document corpus: groundedness 0.98, recall@5 0.90, and 23 of 24 red-team attacks handled correctly
  • About $0.0017 per question, with latency of about 14 seconds at the median
  • A fine-tuned query classifier with 0.81 accuracy on 228 English and Arabic test questions, and 0.96 on in-scope questions

05Honest limits

  • A reference implementation on public documents. It is not an official government service and not legal advice.
  • A small corpus: 8 documents, 196 passages.
  • No reranker is enabled in the live app, because Azure's semantic ranker is not on the free tier.
  • Kubernetes is validated on a temporary cluster in CI. The live app does not run on AKS.
  • 41 unit tests plus the evaluation gate and a cluster smoke test. There is no separate integration or end-to-end suite yet.
  • The model runs as Global Standard, so inference may happen outside the UAE. The review queue is lost on restart, and the same model family writes and judges answers.
  • Azure OpenAI
  • Azure AI Search
  • Semantic Kernel
  • FastAPI
  • Azure Machine Learning
  • MLflow
  • ONNX
  • Bicep
  • GitHub Actions
  • Microsoft Fabric
  • OpenTelemetry