Inferensys

Prompt

Legal RAG Answer with Citation Prompt Template

A practical prompt playbook for using Legal RAG Answer with Citation Prompt Template in production AI workflows.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the production context, ideal user, and critical boundaries for deploying the Legal RAG Answer with Citation Prompt Template.

This prompt template is designed for legal AI builders who need to generate answers strictly grounded in retrieved case law, statutes, or contract clauses. It is intended for production RAG systems where every claim must be traceable to a source, jurisdiction must be respected, and uncertainty must be surfaced explicitly. The ideal user is an engineering lead or AI architect integrating a legal research or contract analysis feature into a product used by legal professionals. The core job-to-be-done is transforming a set of retrieved legal documents and a user question into a verified, citation-backed answer that a lawyer can audit, not a summary that merely sounds plausible.

Use this prompt when your system reliably retrieves relevant legal documents and you need an answer that includes direct quotes, jurisdiction-aware citations, and explicit flags for missing or conflicting authority. It is appropriate for workflows like legal research memo drafting, contract obligation extraction, and compliance Q&A over regulatory text. The prompt assumes that the retrieval step has already occurred and that the provided context contains the universe of permissible evidence for the answer. It enforces a strict contract: the model must not introduce external legal knowledge, must cite to specific sections or page numbers, and must separate binding authority from persuasive commentary.

Do not use this prompt for general legal advice, consumer-facing chatbots without human review, or workflows where the retrieval step is unreliable. If your system cannot guarantee that the provided context contains the answer, this prompt's abstention and uncertainty mechanisms will trigger frequently, which may degrade user experience. This prompt is also unsuitable for e-discovery review, privilege log generation, or any workflow requiring subjective legal judgment. In high-stakes deployments, always pair this prompt with a human review step and automated eval checks for citation hallucination, misattributed holdings, and jurisdictional mismatch before any answer reaches an end user.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before deploying a legal RAG answer prompt.

01

Good Fit: Grounded Legal Q&A

Use when: Answering questions from a closed, curated corpus of case law, statutes, or contracts where every claim must be cited. Guardrail: The prompt excels at synthesizing answers with direct quotes and jurisdiction-aware citations, making it ideal for legal research assistants and contract review tools.

02

Bad Fit: Open-Domain Legal Advice

Avoid when: The system lacks a defined retrieval corpus or is asked for speculative legal strategy. Guardrail: Without source grounding, the model may hallucinate case names or holdings. Route these requests to a human review queue and log them for audit.

03

Required Inputs

What to watch: The prompt is useless without high-quality, chunked legal documents and metadata. Guardrail: Ensure your retrieval pipeline provides the full text of relevant clauses, case citations, and jurisdiction metadata. A missing input should trigger an abstention, not a guess.

04

Operational Risk: Citation Hallucination

What to watch: The model may generate plausible-looking but fictitious case citations (e.g., a fake volume and page number). Guardrail: Implement a post-generation validation step that cross-references every citation string against your source database before showing it to a user.

05

Operational Risk: Misattributed Holdings

What to watch: The model can correctly quote a case but incorrectly state its legal holding or apply it to the wrong jurisdiction. Guardrail: Add an eval rubric that checks if the generated summary of a holding matches the source document's headnotes or key paragraphs.

06

Variant: Contract-Specific Analysis

What to watch: The general legal prompt may not handle clause-level extraction from a single contract well. Guardrail: For contract review, use a variant that prioritizes clause text, obligation identification, and cross-references to governing law sections over broad case law synthesis.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable system prompt for generating jurisdiction-aware legal answers with verbatim citations, direct quotes, and explicit uncertainty flags from retrieved legal context.

This prompt template is designed for legal AI builders who need to generate answers strictly grounded in retrieved case law, statutes, regulations, or contract clauses. It enforces citation discipline by requiring every factual claim to be paired with a source reference, a direct quote, and a jurisdiction note. The template uses square-bracket placeholders that your application must populate before sending the request to the model. Replace each placeholder with your system's live data: the user's question, the retrieved context chunks, your desired output schema, any domain-specific constraints, and the risk level that controls how the model handles uncertainty.

text
You are a legal research assistant. Your answers must be grounded exclusively in the provided [CONTEXT] and must never rely on your own knowledge of law, cases, or statutes.

## INPUT
[INPUT]

## CONTEXT
[CONTEXT]

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "answer": "string (the synthesized answer)",
  "citations": [
    {
      "source_id": "string (from context metadata)",
      "source_name": "string (case name, statute title, contract section)",
      "jurisdiction": "string (court, state, federal circuit, or regulatory body)",
      "direct_quote": "string (verbatim text from the source)",
      "relevance": "string (one sentence explaining why this source supports the answer)"
    }
  ],
  "uncertainty_flags": [
    {
      "type": "string (one of: 'conflicting_authority', 'jurisdictional_variance', 'incomplete_context', 'ambiguous_holding', 'dicta_not_holding')",
      "description": "string (explanation of the uncertainty)"
    }
  ],
  "abstention": {
    "is_abstained": boolean,
    "reason": "string (if abstained, explain why the context is insufficient)"
  }
}

## CONSTRAINTS
[CONSTRAINTS]
- Every factual claim in the answer must be supported by at least one citation with a direct quote.
- Do not paraphrase holdings. Quote the exact language from the source.
- If sources conflict, surface the conflict in uncertainty_flags rather than choosing one.
- If the context does not contain enough information to answer, set abstention.is_abstained to true and explain what is missing.
- Do not cite sources that do not appear in the provided [CONTEXT].
- Distinguish between binding authority, persuasive authority, and dicta in your relevance explanations.
- If [RISK_LEVEL] is 'high', abstain unless the answer is unambiguously supported by binding authority in the user's jurisdiction.

## RISK_LEVEL
[RISK_LEVEL]

To adapt this template, start by mapping your retrieval pipeline's output into the [CONTEXT] placeholder. Each chunk should include a unique source_id, the full source name, jurisdiction metadata, and the raw text. The [CONSTRAINTS] placeholder lets you add domain-specific rules, such as 'prefer Supreme Court precedent over Circuit splits' or 'flag any source older than 10 years.' The [RISK_LEVEL] placeholder accepts values like 'low', 'medium', or 'high' and controls the abstention threshold. Before deploying, run this prompt through a citation hallucination eval: for each generated citation, verify that the direct_quote appears verbatim in the source chunk and that the source_id matches a real retrieved document. If your application operates in a regulated legal context, always route outputs through human review before they reach end users.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Legal RAG Answer with Citation Prompt Template. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to verify the input is well-formed before generation.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The legal question or request submitted by the user

What is the standard for summary judgment under FRCP 56?

Non-empty string check. Reject queries under 10 characters. Flag queries containing only case citations without a question for clarification.

[RETRIEVED_CHUNKS]

Array of text chunks retrieved from the legal knowledge base, each with source metadata

[{"chunk_id":"ch_001","text":"Rule 56(a) ...","source":"FRCP","jurisdiction":"federal","date":"2023-12-01"}]

Schema check: array of objects with required fields chunk_id, text, source. Reject if array is empty. Warn if fewer than 3 chunks. Validate jurisdiction field is present on each chunk.

[JURISDICTION]

The target jurisdiction for the answer, used to filter and prioritize retrieved authority

Federal - 9th Circuit

Must match a value from the allowed jurisdiction taxonomy. Reject if null or unrecognized. If user query implies a different jurisdiction than provided, flag for human review before generation.

[CITATION_STYLE]

The required legal citation format for output

Bluebook 21st edition

Must be one of: Bluebook, ALWD, state-specific, or custom. If custom, require a citation format specification string. Reject if null.

[MAX_QUOTE_LENGTH]

Maximum character length for any single direct quote from source material

300

Integer check. Must be between 100 and 800. Warn if over 500 for fair-use compliance. Default to 300 if not specified.

[CONFIDENCE_THRESHOLD]

Minimum confidence score required to generate an answer; below this threshold the system should abstain

0.75

Float check between 0.0 and 1.0. Reject if below 0.5 for legal use cases. If set above 0.9, warn that abstention rate may be high and require explicit approval.

[OUTPUT_SCHEMA]

The expected JSON schema for the structured answer output

{"answer":"string","citations":[{"source":"string","quote":"string","relevance":"string"}],"uncertainty_flags":["string"],"abstention":"boolean"}

Valid JSON Schema draft-07 check. Must include required fields: answer, citations, uncertainty_flags, abstention. Reject if citations array has no required source field. Warn if schema allows answer text when abstention is true.

[USER_ROLE]

The role of the end user, used to adjust answer depth and disclaimer language

Licensed attorney - litigation

Must be one of: licensed_attorney, paralegal, law_student, pro_se_litigant, or general_public. If general_public or pro_se_litigant, require additional disclaimer injection and flag for human review.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Legal RAG Answer with Citation prompt into a production application with validation, retries, and human review gates.

Integrating this prompt into a production legal RAG system requires more than a single API call. The harness must manage retrieval, prompt assembly, output validation, and a review workflow that reflects the high-stakes nature of legal content. Start by structuring the application as a pipeline: (1) user question intake with jurisdiction and date scoping, (2) retrieval from a vetted legal document store, (3) prompt assembly with the template below, (4) model inference, (5) structured output parsing, (6) automated validation, and (7) conditional human review before the answer reaches the end user. Each stage should log its inputs and outputs for auditability, and the system must never present an unvalidated answer as authoritative legal guidance.

Retrieval and context assembly. Before the prompt fires, retrieve passages from a curated corpus of case law, statutes, regulations, and contracts. Use a hybrid retrieval strategy—dense embeddings for semantic recall combined with keyword or boolean filters for jurisdiction, court level, and effective-date ranges. Deduplicate passages and rank them by a composite score that weights relevance, authority (e.g., binding precedent over persuasive), and recency. The top k passages become the [RETRIEVED_CONTEXT] placeholder. Include metadata per passage: source title, citation, court or jurisdiction, date, and a unique chunk identifier. This metadata is essential for the citation format the prompt demands and for downstream validation that checks whether every cited source actually appeared in the retrieved set.

Validation and retry logic. After the model returns an answer, parse it into a structured schema with fields for answer_text, citations (array of objects with source_id, quote, relevance), uncertainty_flags (array of strings), and abstention (boolean). Run automated evals before any human sees the output: (a) citation grounding—verify every source_id exists in the retrieved context and that quoted strings appear verbatim or with minimal, justifiable edits; (b) hallucination check—use a separate LLM judge prompt to flag claims not supported by the cited passages; (c) format compliance—confirm the output matches the expected schema and citation style. If validation fails, retry with the same prompt and an added [VALIDATION_ERRORS] block describing what went wrong. Cap retries at two attempts; after that, escalate to a human review queue with the full trace attached.

Human review and deployment considerations. For legal workflows, a human-in-the-loop gate is non-negotiable. Route answers that pass automated validation to a review interface that displays the question, the generated answer, the cited sources side-by-side with the model's quotes, and any uncertainty flags. The reviewer should confirm or override the answer, add disclaimers, and approve or reject before the answer is surfaced. Log the reviewer's identity, timestamp, and action for the audit trail. Model choice matters: use a model with strong instruction-following and long-context handling (e.g., GPT-4o, Claude 3.5 Sonnet). Set temperature low (0.0–0.2) to reduce variance in citation formatting. Monitor production for citation hallucination rate, abstention rate, and reviewer override frequency—these metrics will tell you when the prompt or retrieval pipeline needs tuning.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the structured output of the Legal RAG Answer with Citation prompt. Use this contract to build a post-processing validator.

Field or ElementType or FormatRequiredValidation Rule

answer_summary

string

Must be a non-empty string. Must not contain any direct quotes or citations inline.

detailed_answer

string

Must be a non-empty string. All factual claims must be immediately followed by a citation marker (e.g., [1]).

citations

array of objects

Array must not be empty if detailed_answer contains citation markers. Each object must pass the citation_object schema check.

citations[].id

integer

Must be a unique integer within the citations array, matching a marker used in detailed_answer.

citations[].source_document

string

Must exactly match a [DOCUMENT_ID] provided in the input context. No fabricated document names allowed.

citations[].quoted_text

string

Must be a verbatim substring found within the specified source_document in the input context. Fuzzy matching is not acceptable.

uncertainty_flags

array of strings

If present, each string must be from the allowed enum: ['binding_vs_persuasive', 'split_authority', 'dicta_vs_holding', 'jurisdictional_variance', 'statutory_ambiguity'].

abstention_note

string or null

If not null, must be a non-empty string explaining why a complete answer could not be provided. Required if the retrieved context is insufficient to ground the answer.

PRACTICAL GUARDRAILS

Common Failure Modes

Legal RAG answers fail in predictable ways. Here are the most common failure modes, why they happen, and how to guard against them before answers reach users.

01

Citation Hallucination

What to watch: The model invents case names, reporter citations, or statute numbers that look plausible but do not exist. This is the highest-risk failure in legal RAG because fabricated authority undermines the entire answer. Guardrail: Require every citation to match a retrieved document ID. Post-process answers to verify that each citation string appears in the source text. Add a citation-verification eval that flags any citation not present in the provided context.

02

Misattributed Holdings

What to watch: The model correctly cites a real case but attributes a holding, rule, or reasoning to it that belongs to a different case or does not exist. This is harder to detect than pure hallucination because the case name is real. Guardrail: Add an eval step that extracts each claimed holding and checks whether the cited source actually contains that proposition. Use a separate verification prompt that asks: 'Does the source text support this specific holding?'

03

Jurisdiction Confusion

What to watch: The model applies precedent from one jurisdiction as if it were binding in another, or fails to note that a cited case is persuasive rather than controlling authority. This is especially common when retrieval returns cases from multiple jurisdictions. Guardrail: Include jurisdiction metadata in each retrieved chunk and instruct the prompt to explicitly state the jurisdictional weight of each citation. Add an eval that checks whether the answer distinguishes binding from persuasive authority.

04

Overgeneralized Legal Rules

What to watch: The model states a legal rule as absolute when the source shows it is subject to exceptions, jurisdictional splits, or fact-specific balancing tests. Black-letter statements that omit nuance are a form of unfaithful synthesis. Guardrail: Instruct the prompt to preserve exception language, multi-factor tests, and split-of-authority notes from the source. Add an eval that flags answers containing unqualified 'always' or 'never' statements about legal rules.

05

Temporal Staleness

What to watch: The model answers using a statute or case that has been amended, overturned, or superseded, but the retrieved context does not include the subsequent treatment. The answer is faithful to the retrieved text but legally wrong. Guardrail: Include effective-date and subsequent-treatment metadata in retrieval. Add a temporal-check eval that flags citations older than a configurable threshold without a 'still good law' verification step. Consider a Shepardizing or citator API integration.

06

Confidence Overstatement

What to watch: The model presents uncertain or incomplete answers with high confidence, omitting caveats about missing evidence, factual disputes, or unsettled law. In legal contexts, overconfidence is itself a harm. Guardrail: Require the prompt to output an explicit confidence indicator and list of evidence gaps. Add an eval that checks whether answers with low source coverage or conflicting evidence include appropriate uncertainty language. Escalate answers below a confidence threshold for human review.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of legal RAG answers before shipping. Each criterion targets a known failure mode in legal citation and synthesis. Run these checks on a golden dataset of legal questions with known source documents.

CriterionPass StandardFailure SignalTest Method

Citation Hallucination

Every citation resolves to a passage present in [RETRIEVED_CONTEXT]

Answer contains a case name, statute, or citation string not found verbatim in the provided context

Parse all citation strings; run exact-match and fuzzy-match against [RETRIEVED_CONTEXT]; flag any citation with zero matches

Holding Misattribution

The legal principle attributed to a cited case matches the actual holding in [RETRIEVED_CONTEXT]

Answer states 'Case X held that Y' but the retrieved passage for Case X states a different holding or contradicts Y

For each case citation, extract the attributed holding; compare against the source passage using an NLI model; flag entailment score below 0.7

Jurisdictional Scope

Answer explicitly states the jurisdiction of cited authority and does not apply it outside its binding scope

Answer cites a 9th Circuit case to answer a question about 5th Circuit law without noting the split or limiting the scope

Check for jurisdiction tokens in the answer; verify that any binding-authority claim includes a jurisdiction qualifier; flag missing qualifiers

Direct Quote Accuracy

Every quoted string delimited by quotation marks appears verbatim in [RETRIEVED_CONTEXT]

A quoted passage contains altered words, omitted text without ellipsis, or fabricated language

Extract all quoted strings; run exact substring search against [RETRIEVED_CONTEXT]; flag any quote with edit distance > 0

Uncertainty Flagging

Answer includes explicit uncertainty language when evidence is incomplete, conflicting, or from non-binding authority

Answer states a legal conclusion with certainty but the source passages contain hedging, dissents, or 'may'/'could' qualifiers

Scan answer for certainty markers ('clearly', 'definitively', 'always'); cross-check against source passage modality; flag certainty without source support

Source Conflict Disclosure

Answer surfaces and explains conflicting authority when [RETRIEVED_CONTEXT] contains contradictory holdings or statutes

Answer presents one side of a circuit split or statutory conflict as settled law without acknowledging the conflict

Cluster retrieved passages by legal question; detect contradictory conclusions using contradiction NLI; verify answer mentions the conflict; flag suppression

Abstention Trigger

Answer abstains or provides only procedural guidance when [RETRIEVED_CONTEXT] lacks sufficient evidence to answer the legal question

Answer fabricates a legal conclusion or generalizes from tangentially related authority when no on-point authority exists

Measure semantic overlap between question and retrieved passages; if overlap score is below threshold, verify answer contains abstention language; flag confident answers with low-evidence overlap

Temporal Grounding

Answer notes the effective date, publication date, or temporal scope of cited authority and flags superseded or overturned law

Answer cites a statute or case as current authority when [RETRIEVED_CONTEXT] indicates it has been amended, overturned, or superseded

Extract dates from cited passages; check for subsequent history markers ('overruled by', 'amended by'); verify answer includes temporal caveat; flag missing temporal context

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt template and a small set of 5-10 legal documents. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with default temperature. Focus on getting the citation format right before adding validation layers.

Strip the prompt down to essential instructions:

  • [RETRIEVED_CONTEXT] with document IDs
  • [USER_QUESTION]
  • Citation format requirement
  • Uncertainty flag instruction

Watch for

  • Citations that look real but reference non-existent document sections
  • Model conflating holdings from different jurisdictions
  • Overly confident answers when evidence is thin
  • Missing [JURISDICTION] scoping in early versions
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.