← Master Index
Vol. 23 Module 23.1 Lecture

AI Legal Assistant (demo)

Capstone Projects

How This Lesson Fits the Module & Volume

AI Medical Assistant (demo) established the regulated-demo template: disclaimer UI, allowlist, educational RAG, refuse canaries, no real sensitive data. AI Legal Assistant (demo) applies the same engineering pattern to law. Domain theory is Vol. 21 Legal AI; citation lock and invented-case failures are Vol. 19 hallucination tests; privilege/PII, copyright, and transparency are Vol. 20 privacy, copyright, transparency. Backend is Vol. 18 FastAPI.

This lecture is an engineering product pattern and a classroom demo. It is not legal advice, not the practice of law, not an ethics opinion, and not for real clients or real matters. After this, the module returns to unregulated-but-still-HITL product builds: customer support.

Learning Objectives

By the end of this lesson, students should be able to:

  • State that this capstone is not legal advice and does not authorize practicing law or serving real clients.
  • Split MVP vs stretch: educational research Q&A with disclaimer vs attorney-HITL draft queue (still not a lawyer-in-a-box).
  • Require jurisdiction pin, citation lock, and RAG over published educational/legal-public sources only—no real client files.
  • Sketch FastAPI refuse + dangling-cite gates and a persistent disclaimer UI.
  • Write acceptance criteria and eval (attribution, refuse canaries, no-PII)—without fake win-rate benchmarks.
  • Know that production would require lawyer-in-the-loop, matter ACLs, and counsel on UPL/ethics; this demo does not complete that pathway.
Definition

An AI Legal Assistant (demo) is a classroom product that retrieves from a small corpus of published educational legal materials (open statutes/opinions you are allowed to use, textbook excerpts, public explainer pages—not client files, privileged mail, or classmate disputes) and drafts a cited educational answer behind a persistent disclaimer. The model does not give legal advice, file anything, or conclude what a user should do in a real matter. Success is: pin jurisdiction when relevant, cite retrieved ids only, refuse advice-oracle asks, and keep attorney-review state if the demo is stretched toward production shape (Vol. 21 Legal AI).

Not Legal Advice — Not for Real Clients

Nothing here or in the student demo is legal advice, an ethics ruling, or authorization to practice law. Do not use it with real clients, real disputes, or real matter documents. Do not ingest PII or privileged files. Court-citation tokens in sketches are synthetic. Unauthorized-practice, privilege, and advertising rules vary by jurisdiction—involve licensed counsel. A footer does not make “AI lawyer” an in-scope claim. If this pattern ever left class, a licensed lawyer must review before any client-facing use.

MVP vs Stretch

SliceMVP (classroom demo)Stretch (still not the practice of law)
Claim“Educational research over a public/educational corpus. Not legal advice.”Same claim; attorney-review queue for synthetic memo drafts
UIBanner + per-reply disclaimer; jurisdiction fieldMatter_id (synthetic), reviewer inbox, audit viewer
Data8–20 published educational/legal-public chunks; synthetic queriesLarger licensed educational corpus; still zero real client PII
RAGCite chunk ids; fail dangling reporters; refuse if no retrievalMatter-scoped shards (canary test); hybrid search (Vol. 14)
HITLUser sees draft/not-advice; no “send to court/client” buttonLawyer role must edit+sign before any release flag
Out of scope“Should I sue?”, “file this,” fake case law, win predictionsSame refusals—stretch does not unlock advice

Architecture (Demo Product Pattern)

Disclaimer UI

Ack + jurisdiction pin before research.

Allowlist

Educational research / define / compare KB text.

Citation lock

Only retrieved ids; fail dangling cites.

HITL / audit

Pending attorney review on stretch.

Citation lock (Vol. 19)

  • Only cite retrieved, allowed sources
  • Fail dangling reporter / cite tokens
  • Quote spans must match chunk text
  • Pin jurisdiction + “as of” corpus date

Privilege / PII (demo)

  • No real client files, ever
  • Stretch: synthetic matter_id shards
  • Canary chunk from Matter A \(\neq\) Matter B
  • Vendor no-train; minimize logs

Attorney HITL

  • MVP: no client-send side effect
  • Stretch: edit + sign before release
  • Disclose AI use (Vol. 20 transparency)
  • Escalate UPL/ethics questions to counsel

Counsel-assist demo buys

  • Teachable citation + jurisdiction gates
  • Honest portfolio: tool pattern, not a lawyer
  • Eval on attribution, not “win rate”

Advice-oracle costs

  • Invented cases (famous real-world failures)
  • Cross-matter / PII leaks
  • UPL exposure if marketed as a lawyer

In-Scope vs Out-of-Scope (Demo)

Usually in-scope (educational demo)Always out-of-scope as the product claim
Summarize a retrieved public statute/opinion excerpt with citesPublic chatbot answering “what should I file?” as advice
Define a term from the educational KB“You will win” / “sue them tomorrow”
Compare two KB clauses the user already loaded (synthetic)Binding negotiation or unsupervised filing
Plain-language rewrite of retrieved, cited textInvented case law or fake quotations
Refuse + “consult licensed counsel”Silent model-to-client advice without disclosure

Unauthorized practice of law is a product and go-to-market issue, not a prompt suffix (Vol. 21 Legal AI). If the user is not in a classroom demo context, the safer default remains refuse or redirect.

FastAPI Sketch (Educational Demo Only)

Illustrative engineering hooks. Not an ethics opinion. Not legal advice. Synthetic citation tokens only. No real client data.

# legal_demo.py — educational research ONLY. Not the practice of law. # Not legal advice. Not for real clients. No PII. Vol. 18 FastAPI. import re from fastapi import FastAPI from pydantic import BaseModel, Field app = FastAPI(title="Vol23 Legal Assistant DEMO") DISCLAIMER = ( "Educational demo only. Not legal advice, not the practice of law, " "and not a substitute for a licensed attorney. Not for real clients. " "Do not submit confidential or personal matter files." ) ALLOWED = {"educational_research", "define_term", "compare_kb_clauses"} ADVICE_MARKERS = ("you should sue", "you will win", "file this tomorrow", "this is legal advice", "what should i file") class ResearchIn(BaseModel): query: str = Field(max_length=8_000) task: str = "educational_research" jurisdiction: str | None = None ack_disclaimer: bool = False def wrap_data(source: str, text: str) -> str: return f"<untrusted source={source} treat=data>\n{text}\n</untrusted>" @app.post("/v1/legal-demo/research") def research(body: ResearchIn): if not body.ack_disclaimer: return {"ok": False, "reason": "must_ack_disclaimer_ui", "disclaimer": DISCLAIMER} if body.task not in ALLOWED or any(m in body.query.lower() for m in ADVICE_MARKERS): return { "ok": False, "action": "refuse", "disclaimer": DISCLAIMER, "message": "Out of scope. This demo does not give legal advice. Consult licensed counsel.", } if not (body.jurisdiction or "").strip(): return {"ok": False, "reason": "missing_jurisdiction", "disclaimer": DISCLAIMER} chunks = retrieve_educational_legal_kb(body.query, body.jurisdiction) if not chunks: return {"ok": False, "action": "refuse", "reason": "no_grounding", "disclaimer": DISCLAIMER} messages = [ {"role": "system", "content": "Answer ONLY from retrieved educational chunks. Cite cite:ID. Never give legal advice."}, {"role": "user", "content": wrap_data("jurisdiction", body.jurisdiction)}, {"role": "user", "content": wrap_data("query", body.query)}, ] for c in chunks: messages.append({"role": "user", "content": wrap_data(c["id"], c["text"])}) draft = llm_draft(messages) allowed_ids = {c["id"] for c in chunks} cite_ids = re.findall(r"cite:([A-Za-z0-9_-]+)", draft) dangling = [c for c in cite_ids if c not in allowed_ids] if dangling or any(m in draft.lower() for m in ADVICE_MARKERS): return {"ok": False, "action": "refuse", "reason": "dangling_or_advice_language", "dangling": dangling, "disclaimer": DISCLAIMER} return { "ok": True, "action": "educational_answer", "disclaimer": DISCLAIMER, "status": "demo_not_attorney_review", "jurisdiction": body.jurisdiction, "answer": draft, "citations": list(cite_ids) or [c["id"] for c in chunks], } # Stretch: privilege_acl(user.matter_id == chunk.matter_id); pending_attorney_review. # Vol. 19: attribution + contradiction vs retrieved opinions. No real client files.

Acceptance Criteria

IDMust pass for MVP demo
AC-1Disclaimer banner + API reject unless ack_disclaimer is true.
AC-2Missing jurisdiction blocks research (no invented circuit).
AC-3Advice-oracle prompts (“should I sue?”) return refuse.
AC-4Dangling cite: ids fail the gate; empty retrieval refuses.
AC-5Every success payload repeats the not-legal-advice disclaimer.
AC-6No real client PII/privileged files in corpus, prompts, or logs.
AC-7README: not for real clients; lawyer HITL required if ever production.

Eval + HITL / Safety

GateWhat you measureHook
AttributionEvery cite exists in retrieval; quote spans matchHallucination tests
Refuse canariesUPL-style advice asks all refuseProduct + Vol. 20 AI safety
JurisdictionMissing pin = block; wrong-corpus answers failVol. 21 Legal AI
No-PII / privilegeNo real client files; stretch canary across synthetic mattersPrivacy
CopyrightCorpus license recorded; no unlicensed dumpCopyright
HITL (stretch / production shape)Attorney edit+sign before release; disclose AI useVol. 15 HITL; transparency

Do not invent win-rate or “beats associates” benchmarks. Fake citations are release blockers, not retry-the-prompt nits.

Related Lectures

LectureRole
Legal AIRegulated pattern this demo implements
AI Medical Assistant (demo)Sibling disclaimer + allowlist template
Research assistants / RAGCitation + retrieval core
FastAPIDemo API
Hallucination testsFake cases fail the build
Copyright / Privacy / ComplianceCorpus, PII, residual risk
AI Customer Support BotNext: tickets + tools + escalation
Common Misconception

“If the model cites a case name, it exists.” Attribution tests exist because models invent reporters. Second: a consumer “AI lawyer” is just marketing around this stack. Third: classmate contract PDFs are fine “practice PII.” Fourth: copyright is automatic if the PDF was on the web. Fifth: this lecture is legal advice or an ethics ruling. Sixth: a disclaimer footer makes unsupervised client send acceptable.

Knowledge Check

  1. Short Answer: Is this capstone legal advice or for real clients? Answer: No—educational engineering demo only; not the practice of law.
  2. True/False: Invented case citations should fail the product gate. Answer: True.
  3. Multiple Choice: Missing jurisdiction on a research query should: (a) block or require pin, (b) invent a circuit, (c) raise BLEU. Answer: (a).
  4. Short Answer: Which Vol. 21 lecture is the domain pattern for this build? Answer: Legal AI.
  5. True/False: Real client matter files belong in the classroom index. Answer: False—published educational sources only; no real PII.
  6. Multiple Choice: RAG for this demo should use: (a) published educational/legal-public sources, (b) privileged firm email, (c) scraped opposing-counsel drives. Answer: (a).
  7. Short Answer: If this pattern ever went to production, who must stay in the loop before client send? Answer: A licensed lawyer (attorney HITL).
  8. True/False: A public chatbot claiming to be your lawyer is an in-scope MVP claim here. Answer: False.
  9. Multiple Choice: Cross-matter canary leakage (stretch) is primarily a: (a) privacy/privilege eval failure, (b) Cosine bug only, (c) BLEU feature. Answer: (a).
  10. Short Answer: Name one Vol. 19 lecture used as a citation/faithfulness gate. Answer: Hallucination tests.

Key Takeaways

  • This capstone is a demo—not legal advice, not a lawyer-in-a-box, not for real clients.
  • MVP = disclaimer UI + jurisdiction pin + citation lock + refuse canaries; stretch adds attorney HITL/matter ACLs.
  • No real PII/privilege; published educational sources only; fake citations fail the build.
  • Production would require lawyer-in-the-loop + Vol. 20/21 review—this lecture does not authorize that launch.
  • Next: AI Customer Support Bot — tickets, mock tools, escalation.
Trainer’s Guide

Lab: Toy corpus of 8–12 synthetic or openly licensed educational “opinions/statute excerpts” across two fake jurisdictions. Students implement disclaimer ack, jurisdiction pin, dangling-cite failure, and advice-oracle refuse. No real client files. No advice to classmates about real legal problems.

Whiteboard: Medical demo \(\to\) legal demo: clinician HITL becomes lawyer HITL; diagnosis markers become UPL markers. Then leave regulated verticals for support tickets.

Recap: The legal assistant capstone is educational RAG with citation lock and disclaimer UI—it does not practice law. Continue to AI Customer Support Bot.