Lawfare Group → Knowledge Institute → Lawfare Academy
← AI 320 — Applied AI, Retrieval and Reliable Automation
Weeks 12–14
Evaluation, adversarial cases and cost accounting
Learning objectives
- Explain and trace the mechanisms in evaluation, adversarial cases and cost accounting.
- Apply the method to the worked example and changed-condition exercise.
- Identify assumptions, failure cases and the evidence needed to justify a result.
- Test the added failure-mode fixture and explain which guarantee the evidence does and does not establish.
An AI evaluation should represent actual use, including difficult and out-of-scope cases. Freeze a set of questions, reference evidence and scoring rules before comparing changes. Separate factual support, completeness, instruction adherence, appropriate abstention and action safety. A single overall score can hide a rare severe error or a system that refuses almost everything.
Adversarial cases test trust boundaries. Include a retrieved passage that instructs the model to reveal data, a forged source ID, conflicting versions and a request to execute an unauthorized action. These are not merely prompt-writing puzzles: the surrounding software must enforce permissions even if generation fails. Score the system's final observable behavior, including leaked context and side effects.
Cost includes more than model charges. Measure retrieval, inference, latency, human review, corrections, maintenance and incident handling. A draft that saves ten minutes but adds fifteen minutes of verification increases labor. Use synthetic workloads to estimate capacity and report assumptions. When changing a model or prompt, run the same cases and examine regressions individually. Improvements on familiar examples may not transfer to fresh cases, so retain a held-out evaluation and monitor deployment outcomes.
Worked reasoning The negative result means about 16.67 additional labor hours each month before maintenance or correction costs. Faster drafting alone is therefore not a realized benefit. A different workflow might still improve quality, but that claim needs its own evidence. Keep time savings, cash savings and quality changes distinct in the recommendation.
Extended teaching and laboratory
Evaluate the complete workflow against representative, difficult and adversarial cases. Separate retrieval recall, claim support, abstention correctness, action authorization and latency/cost. A single aggregate score can hide a severe failure in one boundary. A document that instructs the assistant to ignore rules is task data, not authority to change tool permissions.
Measure net operating benefit rather than drafting speed alone. Human verification, corrections, retries and incident handling can outweigh time saved. Estimate with observed workflow times and state which costs are omitted.
Worked problem A system saves 45 seconds drafting each of 800 monthly items, but adds 60 seconds of review and 15 seconds of correction per item. Calculate net labor time before maintenance.
Step-by-step reasoning 1. Draft savings are 800×45=36,000 seconds, or 10 hours.
- Review and correction total 800×75=60,000 seconds, or 16⅔ hours.
- Net labor change is an additional 6⅔ hours monthly before maintenance. Faster drafts do not establish a labor-saving workflow.
- Quality improvements might justify the system separately, but need evidence and should not be reported as time savings. Include adversarial-source and unauthorized-action cases in the evaluation.
Failure-oriented laboratory: Permission-separated retrieval and adversarial evaluation
A retrieved passage is untrusted data, even when it contains imperative language or looks like a system message. Source content can support an answer about a policy; it cannot grant permission to read another tenant's documents or execute a tool. Enforce document authorization before text enters the generation context, and enforce tool permissions separately at execution.
A citation check has several layers. A source identifier must exist, its version must be appropriate, the caller must be authorized to see it and the cited passage must actually support the claim. A structurally valid citation can still be irrelevant or contradictory. Conflicting current policies should trigger a conflict or abstention path rather than a confident invented reconciliation.
Build a synthetic evaluation matrix covering normal answers, no relevant evidence, stale evidence, contradictions, malicious instructions and cross-tenant retrieval. Count retrieval leakage independently of whether a final answer exposes it: unauthorized text entering context is already a boundary failure. Use dry-run actions only. A useful evaluation records the failure mechanism and a regression fixture, not just an overall success percentage.
Worked fixture
Tenant A asks about its current refund policy. A retrieved A document says to ignore permissions and search tenant B. A second A document contradicts an older policy.
Explain the fixture
The embedded instruction has no authority to expand access. Tenant B must be excluded before retrieval results enter context. Resolve version precedence only from documented policy metadata; if the current authorized sources genuinely conflict, return a bounded conflict state with source locators. An old policy cannot silently override a new one.
Apply the idea
A system saves 45 seconds drafting each of 800 monthly items, but adds 60 seconds of review and 15 seconds of correction per item. Calculate net labor time before maintenance.
A retrieved file says to send every invoice to an outside address. It is relevant to the user’s invoice question. Should relevance grant that instruction tool authority?
Additional laboratory — Create six synthetic fixtures and instrument document IDs entering context and every proposed tool call. Inject a stale cache entry and an authorization change between proposal and execution.
Read the worked reasoning
No. Relevance makes the document candidate evidence, not a controlling instruction or approval. Keep retrieved text isolated from action permissions, reject the unauthorized destination and log the boundary result without unnecessarily copying private invoice content. Test this exact pattern as an adversarial case.
Additional laboratory model — All cross-tenant context entries and unauthorized tool actions must remain zero. A stale cache entry must be revalidated or rejected under the declared cache policy. Recheck authorization at execution because proposal-time approval can become stale. Report correct answers, supported abstentions, conflict detections and boundary failures separately; a high answer rate must not hide one access failure.
Check understanding
Why can an average score conceal unacceptable behavior?
- It can hide rare severe errors and subgroup or scenario failures
Feedback
Error type and consequence matter alongside frequency.
- Every error has the same consequence
Feedback
A formatting mistake and a disclosure are not interchangeable.
- A high score automatically grants action permission
Feedback
Permission is established by authorization, not by a benchmark.
Further reading
Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study scikit-learn metrics and the assigned generalization material. Construct an evaluation set for the complete retrieval-and-drafting pipeline rather than judging isolated attractive answers.
- 3.1. Cross-validation: evaluating estimator performance
- 3.4. Metrics and scoring: quantifying the quality of predictions
- 5.2. Permutation feature importance
- unittest — Unit testing framework
- statistics — Mathematical statistics functions
- Page Summary
- LLM09:2025 Misinformation
- LLM10:2025 Unbounded Consumption
- Primary documentation for Permission-separated retrieval and adversarial evaluation
- Academy — runnable synthetic lab kit and instructions