AI 320 — Applied AI, Retrieval and Reliable Automation · Weeks 15–16
A bounded retrieval assistant and operating plan
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. Complete the assigned source exercises relevant to your chosen workflow. Integrate CS 101 testing, CS 220 boundaries and AI 301 evaluation into a reproducible prototype.
A release gate for a bounded assistant
A release gate connects evidence to an operating decision. Specify the permitted corpus, claim types, action boundaries and failure response before evaluating. Include a transparent non-generative retrieval baseline so generation’s incremental contribution can be measured. A system that cites a passage is not necessarily faithful: it can cite an irrelevant passage or omit an exception.
Version the entire configuration, including model, prompt, retrieval settings, source snapshot and validator. A provider update can change outputs without an application deployment. Rerun representative evaluations after consequential changes and preserve a fallback that is actually tested.
Worked problem
An assistant answers 90 of 100 routine questions correctly but sends one unauthorized external request. The release rule permits no unauthorized actions in the test suite. Evaluate the gate.
Trace the complete reasoning
Routine answer accuracy is 90%, but it is not the only release criterion.
The unauthorized action violates the declared gate. Do not average it away as one error among 100 questions.
Disable or constrain external actions, repair the boundary and rerun both the failing case and related adversarial variants.
Document that passing a finite gate supports the bounded release decision; it does not prove that no future unauthorized action is possible. Maintain monitoring and a fallback.
Independent transfer problem
A new model version passes average accuracy but fails three previously passing exception-policy cases. What should the release comparison show?
Compare the transfer solution
Show case-level regressions, their severity and the applicable release criteria alongside the aggregate. A stable average can mask changed failure modes. Investigate the exceptions, keep the prior bounded configuration or fallback when required, and rerun the affected source/validation tests before release.
Learning objectives
- Explain and trace the mechanisms in a bounded retrieval assistant and operating plan.
- 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
The final project connects retrieval, output validation, evaluation and workflow control. Begin with fictional documents and local execution. Keep the first release narrow: answer policy questions with evidence or abstain, produce drafts for review and simulate actions rather than contacting people or changing records. This scope lets you test failure behavior without conflating a demonstration with permission to act.
Document the complete chain from question to final result. Which passages were eligible, which were retrieved, what context was supplied, which output was proposed, which checks passed and what a reviewer approved? Store only the information needed for diagnosis under a clear retention policy. A log containing raw private prompts can itself become a sensitive datastore. Keep secrets outside source code and browser bundles, and enforce limits at the server.
An operating plan specifies source updates, model and prompt versions, evaluation triggers, cost budgets, incident response and retirement. A model provider update can change behavior without an application code change. Repeat representative checks when dependencies change. Provide a useful fallback, such as source search without generation. Judge readiness by demonstrations of supported answers, correct abstention, denied access, safe retries and recovery after interruption, not by a claim that the assistant is autonomous.
Worked example
def evidence_answer(question, documents):
matches = retrieve(question, documents)
if not matches:
return {"status":"insufficient_evidence", "sources":[], "text":"No matching passage found."}
first = matches[0]
return {"status":"source_excerpt", "sources":[first["id"]], "text":first["text"]}
assert evidence_answer("unicorn", []) ["status"] == "insufficient_evidence"This non-generative baseline returns an attributed passage rather than synthesizing unsupported claims. It is not a complete answer-verification system: lexical matching can still return an irrelevant passage. Its purpose is to make the contribution of generation measurable. The retrieve function is defined in the preceding unit; include it or import it when running this snippet.
Check your understanding
What is the strongest readiness evidence for this prototype?
- Reproducible task tests including abstention, denied access and recovery
- A single persuasive generated demonstration
- A claim that all future prompts will behave correctly
Answer and reasoning for every option
Correct: Reproducible task tests including abstention, denied access and recovery Observable behavior under failures is stronger than presentation alone.
Reconsider: A single persuasive generated demonstration A selected demonstration gives little evidence about error rates.
Reconsider: A claim that all future prompts will behave correctly No finite evaluation guarantees every future behavior.
Transfer laboratory: Recovery from an ambiguous external action
A workflow times out after issuing a payment request. It has a durable operation ID but no confirmed result. Specify the next safe state and reconciliation steps.
Work through the full solution
Enter outcome_unknown and query the external system’s authoritative record using the stable operation ID or documented reconciliation mechanism. Do not automatically issue a new payment with a new ID. Record the confirmed result or escalate for authorized review when it cannot be established. Durable local state helps coordinate workers but does not itself reveal whether the external effect occurred.
Evidence of understanding
Keep the operation identity, reconcile remote state and avoid duplicate effects.
Complete on-site teaching readings
These are full attributed source sections, not previews. Read them alongside the original Academy explanation and code.
- 11. Model persistence · The scikit-learn developers
- 10.2. Computational Performance · The scikit-learn developers
- 12. Common pitfalls and recommended practices · The scikit-learn developers
- logging — Logging facility for Python · Python Software Foundation and Python documentation contributors
- hashlib — Secure hashes and message digests · Python Software Foundation and Python documentation contributors
- venv — Creation of virtual environments · Python Software Foundation and Python documentation contributors
- HTTP caching · Mozilla Contributors
- Page Summary · Martin Zinkevich and Google Developers contributors
- LLM03:2025 Supply Chain · OWASP GenAI Security Project contributors
Open the complete practice sequence and cumulative assessment →