AI

Designing LLM systems that survive production

Patterns for evaluation, guardrails, observability and cost control in regulated industries.

Back to Engineering Journal

Engineering guide · General design considerations, not a client case study or a claim of certified compliance.

Define the task before choosing a model

A production LLM workflow needs a bounded task: extracting fields from an invoice is different from answering questions over internal documents. Specify the allowed inputs, expected output structure and actions the system must never take. Establish a conventional baseline, such as search or deterministic parsing, so an evaluation can show whether a model adds useful capability rather than simply producing fluent text.

Evaluate retrieval and answers separately

Build a representative test set with expected answers, ambiguous questions and questions that cannot be answered from the available material. For document search, measure whether retrieval finds the relevant passages before judging the generated answer. Require source references and a refusal when supporting evidence is absent. Keep development and held-out examples separate; otherwise prompt changes can appear to improve quality while only fitting familiar examples.

Treat model output as untrusted input

Retrieved documents can contain instructions that conflict with the application’s task. Keep those documents separate from system instructions and enforce permissions outside the model. Validate generated JSON against a schema. Tool calls should use narrowly scoped credentials, allowlisted operations and explicit human approval for consequential actions. Neither a confident answer nor a valid JSON object proves that a requested action is authorised.

Operate with measurable limits

Record model and prompt versions, latency, token usage, retrieval failures and review outcomes without logging unnecessary personal data. Set request budgets and timeouts, and define a fallback for provider outages. Roll out a new prompt or model to a small traffic segment before replacing the baseline. An operational checklist should identify who reviews failures, how a release is rolled back and when the workflow must defer to a person.