AI, ML and RAG systems governance
Govern machine-learning and retrieval-augmented generation systems: data access, evaluation, safety and cost.
17 min readWhy AI systems need extra governance
ML and LLM features behave probabilistically: the same input can yield different outputs, quality drifts as data changes, and failures are often plausible-sounding rather than obvious. They also concentrate risk around data: training sets and retrieval indexes can leak confidential information, and prompts can be manipulated by user content. Treat models as components with their own lifecycle, owners, evaluations and change control, just like a database or a public API. Assign each model an owner, a documented purpose and approved data sources, recorded in a model registry.
RAG architecture and access control
Retrieval-augmented generation answers questions by searching a document index and passing the most relevant chunks to an LLM. The pipeline: ingest documents, split into chunks, embed with an embedding model, store vectors in a vector database, then at query time embed the question, retrieve the top-k chunks (often hybrid keyword plus vector search with a reranker), and generate an answer with citations. The governance trap is permissions: the index must store each chunk's access control list, and retrieval must filter by the caller's permissions before anything reaches the model.
- Filter by permission at retrieval time, never after generation
- Re-index or update ACLs when source permissions change
- Cite sources so users can verify answers
Evaluation and change control
Changing a prompt, model version, chunk size or embedding model is a deployment and needs the same discipline. Maintain an evaluation set of a few hundred representative questions with expected answers or graded criteria, and run it in CI for every change. Track retrieval metrics (recall@k), answer faithfulness to sources, refusal rates and latency. Roll out model changes behind feature flags with shadow traffic or A/B tests, and keep the previous version deployable for quick rollback. Version datasets alongside models so any result can be reproduced.
Safety, privacy and cost
Prompt injection, where instructions hidden in retrieved documents or user input hijack the model, is the defining LLM security risk (top of the OWASP LLM Top 10). Mitigate by treating model output as untrusted, limiting the tools and data an agent can reach, and requiring confirmation for side effects. Redact personal data before sending it to third-party models and check the provider's retention terms. LLM calls cost per token, so set per-feature budgets, cache frequent answers and route simple tasks to smaller, cheaper models.
Key takeaways
- Treat models and prompts as versioned components with owners, evaluations and rollback.
- In RAG, enforce document permissions at retrieval time, before content reaches the model.
- Run an evaluation set in CI for every prompt, model or chunking change.
- Defend against prompt injection, redact personal data and budget token spend per feature.
Sign in to track lessons and earn badges.