Lawfare Academy

AI 320 — Applied AI, Retrieval and Reliable Automation · Weeks 12–14

Evaluation, adversarial cases and cost accounting

Full teaching sequence and cumulative subject work

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.

Recover a durable action after the effect–record crash window — primary material, constructed-response tasks, complete worked model and changed-case examination →

Evaluation, prompt injection and actual benefit

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.

Trace the complete reasoning
  1. Draft savings are 800×45=36,000 seconds, or 10 hours.

  2. Review and correction total 800×75=60,000 seconds, or 16⅔ hours.

  3. Net labor change is an additional 6⅔ hours monthly before maintenance. Faster drafts do not establish a labor-saving workflow.

  4. 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.

Independent transfer problem

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?

Compare the transfer solution

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.

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.

Study the mechanism

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 example

draft_minutes_saved = 10
review_minutes_added = 15
monthly_cases = 200
net_hours = (draft_minutes_saved - review_minutes_added) * monthly_cases / 60
assert round(net_hours, 4) == -16.6667

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.

Check your understanding

Why can an average score conceal unacceptable behavior?

  1. It can hide rare severe errors and subgroup or scenario failures
  2. Every error has the same consequence
  3. A high score automatically grants action permission
Answer and reasoning for every option

Correct: It can hide rare severe errors and subgroup or scenario failures Error type and consequence matter alongside frequency.

Reconsider: Every error has the same consequence A formatting mistake and a disclosure are not interchangeable.

Reconsider: A high score automatically grants action permission Permission is established by authorization, not by a benchmark.

Transfer laboratory: Averages conceal an authorization failure

A system answers 99 of 100 cases correctly but leaks one restricted document. Explain why a 99% headline is inadequate for release.

Work through the full solution

The disclosure belongs to a distinct severe failure category and may independently violate the release policy. Report it directly, identify the trust boundary and correct access filtering before model context construction. Rerun targeted and regression checks. Averaging it with spelling or formatting defects obscures consequence and does not establish acceptable behavior.

Evidence of understanding

Classify the disclosure separately and require an access-control correction rather than a cosmetic score improvement.

Complete on-site teaching readings

These are full attributed source sections, not previews. Read them alongside the original Academy explanation and code.

  1. 3.1. Cross-validation: evaluating estimator performance · The scikit-learn developers
  2. 3.4. Metrics and scoring: quantifying the quality of predictions · The scikit-learn developers
  3. 5.2. Permutation feature importance · The scikit-learn developers
  4. unittest — Unit testing framework · Python Software Foundation and Python documentation contributors
  5. statistics — Mathematical statistics functions · Python Software Foundation and Python documentation contributors
  6. Page Summary · Martin Zinkevich and Google Developers contributors
  7. LLM09:2025 Misinformation · OWASP GenAI Security Project contributors
  8. LLM10:2025 Unbounded Consumption · OWASP GenAI Security Project contributors

Open in My Learning to record progress →