This prompt is built for legal engineering teams who need to extract specific, named clauses from contract documents with precise citation boundaries. The primary job-to-be-done is producing isolated clause text alongside section, page, and paragraph references plus confidence scores, so that downstream systems—obligation trackers, review queues, audit logs—can operate on traceable, verifiable outputs. The ideal user is a developer or legal operations engineer integrating this prompt into a document processing pipeline where every extracted clause must be attributable to a source location. Use this when your application requires structured clause objects that can survive a compliance review or feed into a contract lifecycle management system without manual re-verification of provenance.
Prompt
Contract Clause Extraction with Citation Prompt Template

When to Use This Prompt
Identify the ideal scenarios, required inputs, and hard boundaries for deploying the Contract Clause Extraction with Citation Prompt Template in a production legal engineering system.
This prompt assumes the input document has been pre-processed with page and paragraph markers. If your ingestion pipeline does not yet inject markers like [Page 4] or [Para 12] before the text reaches the model, the citation fields will be unreliable. The prompt works best on clean, machine-readable contract text—not heavily degraded OCR output, handwritten amendments, or image-only scans without a text layer. It expects a single document per request; multi-document comparison or cross-contract dependency resolution is out of scope and belongs in a separate workflow. The output schema includes a confidence field, which you should treat as a routing signal: high-confidence extractions can proceed automatically, while low-confidence results should be queued for human review before any downstream action is taken.
Do not use this prompt as a substitute for legal advice, and do not bypass human review for high-stakes decisions such as obligation enforcement, litigation hold triggers, or financial commitment tracking. The prompt is designed to reduce hallucination risk through citation discipline, but it cannot guarantee zero hallucination—especially when clause language is ambiguous, split across multiple sections, or referenced indirectly. Before deploying, run a targeted evaluation set that includes edge cases like clauses spanning page breaks, clauses embedded in schedules or exhibits, and documents where the target clause is absent. If your use case involves regulated filings, cross-border jurisdictional analysis, or real-time negotiation support, pair this extraction prompt with a human-in-the-loop approval step and log every extraction with its model version, input hash, and confidence score for auditability.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the Contract Clause Extraction with Citation Prompt Template fits your workflow before you integrate it.
Good Fit: Structured Legal Review Pipelines
Use when: you are building a contract review system that needs to isolate specific clauses (indemnification, termination, governing law) with precise section, page, and paragraph citations. Why: the prompt is designed for high-stakes legal engineering workflows where citation boundary accuracy and hallucination reduction matter more than speed.
Bad Fit: Unstructured Chat or Ad-Hoc Q&A
Avoid when: users are asking free-form questions about a contract in a chat interface without a defined extraction schema. Why: this prompt expects a target clause type and a structured output contract. Ad-hoc Q&A without schema constraints leads to inconsistent citation formats and missed extraction boundaries.
Required Inputs: Clause Type, Document Text, and Citation Schema
What you must provide: a specific clause type to extract (e.g., 'Limitation of Liability'), the full document text with page and paragraph markers, and a defined output schema for citation fields. Guardrail: if your document lacks reliable page or paragraph markers, pre-process it with a layout-aware extraction step before calling this prompt.
Operational Risk: Silent Citation Drift
What to watch: the model may return a clause that exists in the document but cite the wrong section, page, or paragraph number. Guardrail: implement a post-extraction validator that checks whether the cited location actually contains the extracted text. Flag mismatches for human review before the output enters a downstream system of record.
Operational Risk: Partial Clause Extraction
What to watch: the model may extract only the first paragraph of a multi-paragraph clause, missing carve-outs, exceptions, or cross-referenced subsections. Guardrail: add a completeness check that verifies the extracted text ends with a complete sentence and does not cut off mid-provision. For critical clauses, require human confirmation of extraction boundaries.
Not a Replacement for Legal Judgment
What to watch: teams may treat the extracted clause and confidence score as a final determination rather than a starting point for review. Guardrail: always route extractions with confidence scores below your threshold to a human reviewer. Never use this prompt to make binding legal decisions without attorney review of the source document.
Copy-Ready Prompt Template
A reusable prompt for extracting contract clauses with precise section, page, and paragraph citations plus confidence scores.
This prompt template is designed for legal engineering teams building contract review systems. It instructs the model to isolate a specific clause type from a contract, return the exact clause text, and provide a precise citation to the source location. The template uses square-bracket placeholders that you replace with your document content, target clause type, and extraction parameters before sending to the model. The output schema enforces structured JSON with citation boundaries, confidence scores, and explicit null handling for missing clauses.
textYou are a legal document extraction assistant. Your task is to extract a specific clause from a contract and provide a precise citation to its location in the source document. ## INPUT [CONTRACT_TEXT] ## TARGET CLAUSE [CLAUSE_TYPE] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "clause_type": "string (the type of clause extracted)", "clause_text": "string (the exact text of the clause, verbatim from the source)", "citation": { "section_number": "string or null", "section_title": "string or null", "page_number": "integer or null", "paragraph_number": "integer or null", "line_range": "string or null (e.g., 'lines 12-18')" }, "confidence": "number between 0.0 and 1.0", "is_present": "boolean", "absence_reason": "string or null (required if is_present is false)", "surrounding_context": "string (one sentence before and after the clause for verification)" } ## CONSTRAINTS [CONSTRAINTS] ## EXAMPLES [EXAMPLES] ## INSTRUCTIONS 1. Extract the clause text exactly as written. Do not paraphrase, summarize, or modify. 2. If the clause is not present, set is_present to false and provide a specific absence_reason. 3. If the clause is present but the citation is ambiguous, set confidence below 0.7 and note the ambiguity. 4. For multi-page documents, estimate page numbers based on the provided text if explicit page markers are absent, and note this in confidence. 5. If multiple clauses match the target type, extract the most specific or primary instance and note additional instances in a remarks field. 6. Do not invent clause text. If you are uncertain, reduce confidence and flag the uncertainty.
To adapt this template, replace [CONTRACT_TEXT] with the full text of the contract or the relevant section. Set [CLAUSE_TYPE] to the specific clause you need, such as "Indemnification," "Limitation of Liability," or "Governing Law." The [CONSTRAINTS] placeholder should contain any additional rules, such as jurisdiction-specific requirements, maximum clause length, or handling of amendments and addenda. The [EXAMPLES] placeholder should include one or two few-shot examples showing the expected output format for both present and absent clauses. For production use, always validate the output against the source document and implement a human review step for low-confidence extractions below 0.8.
Before deploying this prompt into a contract review pipeline, run it against a golden dataset of contracts with known clause locations. Measure citation boundary accuracy by checking whether the extracted text matches the exact source span. Track hallucination rate by flagging any clause text that does not appear verbatim in the source. For high-stakes workflows, combine this extraction prompt with a separate verification prompt that re-reads the cited location and confirms the extracted text matches.
Prompt Variables
Inputs the prompt needs to work reliably. Validate each before sending to prevent silent extraction failures and hallucinated citations.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FULL_DOCUMENT_TEXT] | Raw text of the contract to extract clauses from | MASTER SERVICES AGREEMENT
| Required. Must be non-empty string. Check minimum length > 50 chars. Reject if only whitespace or OCR garbage detected. |
[TARGET_CLAUSE_TYPE] | Type of clause to isolate and extract | Termination for Cause | Required. Must match known clause taxonomy entry. Validate against allowed clause type list before sending. Reject unknown types. |
[CITATION_GRANULARITY] | Level of citation detail to return | section, page, paragraph | Required. Must be one of: section, page, paragraph, line, or comma-separated combination. Default to section, paragraph if not specified. |
[OUTPUT_SCHEMA] | JSON schema describing expected output shape | {"clause_text": "string", "citation": {"section": "string", "page": "int", "paragraph": "int"}, "confidence": "float"} | Required. Must be valid JSON schema. Validate parseable before prompt assembly. Reject if schema contains unsupported types or circular references. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for returning a result | 0.85 | Optional. Must be float between 0.0 and 1.0. Default to 0.80 if not provided. Results below threshold should trigger [MISSING_CLAUSE_HANDLING]. |
[MISSING_CLAUSE_HANDLING] | Instruction for when clause is absent or below confidence | return null with explicit missing_reason field | Required. Must be one of: return_null, flag_for_review, skip, or generate_empty_stub. Controls production behavior for absent clauses. |
[MAX_EXTRACTION_LENGTH] | Character limit for extracted clause text | 5000 | Optional. Must be positive integer. Truncation strategy should be defined in prompt instructions. Default to no limit if not specified. |
[DOCUMENT_SECTION_BOUNDARIES] | Pre-parsed section markers to constrain extraction scope | {"sections": [{"title": "Termination", "start_page": 12, "end_page": 14}]} | Optional. If provided, must be valid JSON with section array. Each section requires title and at least one boundary marker. Improves citation accuracy when available. |
Implementation Harness Notes
How to wire the Contract Clause Extraction with Citation prompt into a reliable application pipeline with validation, retries, and human review gates.
The Contract Clause Extraction with Citation prompt is designed to be embedded in a multi-stage document processing pipeline, not called in isolation. The typical harness receives a pre-parsed document (with page, paragraph, and section metadata), identifies the target clause type from a user query or configuration, invokes the prompt with the relevant document chunk and extraction schema, validates the structured output, and routes low-confidence or failed extractions for human review. Because legal documents vary widely in structure and clause placement, the harness must handle cases where the clause is absent, split across pages, or embedded in a larger section with ambiguous boundaries.
Input preparation is the first critical step. Before calling the prompt, the harness must: (1) chunk the document into sections with preserved page and paragraph metadata; (2) identify candidate sections likely to contain the target clause type using keyword search, heading matching, or a lightweight classifier; (3) assemble the prompt context with the candidate text plus surrounding sections for boundary disambiguation. The [INPUT] placeholder should receive the pre-identified document text with inline citation markers (e.g., [Page 4, §2.1]). The [CLAUSE_TYPE] placeholder maps to a controlled taxonomy (e.g., indemnification, limitation_of_liability, governing_law). The [OUTPUT_SCHEMA] should be a JSON schema specifying fields like clause_text, citation_start, citation_end, confidence_score, and missing_fields. Never pass raw, unchunked PDF text directly to the prompt—layout misordering will corrupt citation boundaries.
Validation and retry logic must run after every prompt call. Parse the JSON output and validate: (1) citation boundaries exist within the provided input text (no hallucinated page numbers); (2) the extracted clause text matches the cited range (perform a substring check); (3) confidence scores are present and above a configurable threshold (typically 0.7 for auto-accept, 0.4–0.7 for review queue, below 0.4 for rejection); (4) required fields are populated or explicitly marked as null with a missing_reason. On validation failure, retry once with an error-specific instruction appended to the prompt (e.g., "The previous extraction cited page 7, but the input only contains pages 3–5. Re-extract using only the provided text."). After two failures, escalate to a human review queue with the original document, the failed extractions, and the validation errors logged. For high-risk clause types (indemnification, liability caps, termination rights), consider requiring human approval even on high-confidence extractions by default.
Model choice and tool integration affect reliability. Use a model with strong instruction-following and JSON mode support (GPT-4o, Claude 3.5 Sonnet, or equivalent). Enable structured output mode if available to reduce parsing failures. For RAG-augmented pipelines, the retrieval step should supply the [INPUT] context, and the prompt's citation requirement acts as a grounding check—if the model cannot cite a source, it must not invent one. Log every extraction with: prompt version, model, input hash, output, validation result, retry count, and final disposition (accepted/reviewed/rejected). This audit trail is essential for legal engineering workflows where extraction decisions may be challenged. Avoid using this prompt with models under ~7B parameters without fine-tuning; smaller models frequently hallucinate citation boundaries and clause content.
Production hardening should include: a clause type router that selects the appropriate extraction schema before calling the prompt; a citation boundary overlap detector that flags when two extractions claim the same text for different clause types; and a missing clause classifier that distinguishes between "clause genuinely absent" and "clause present but extraction failed" using a secondary prompt or heuristic. The harness should never silently return an empty extraction—always surface the reason (absent, low confidence, parse failure, validation failure) to the calling system. When integrating with contract lifecycle management or compliance systems, map the extracted structured output to your system's canonical clause taxonomy and store the raw prompt response alongside the normalized record for future audit.
Expected Output Contract
Defines the exact fields, types, and validation rules for the model response when extracting contract clauses with citations. Use this contract to build downstream parsers and evaluation checks.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
clause_text | string | Must be a verbatim substring of [DOCUMENT_TEXT]. Fail if any character differs from the source. | |
clause_type | string (enum) | Must match one of the values in [CLAUSE_TYPE_TAXONOMY]. Reject unknown types. | |
citation_section | string | Must match a section heading present in [DOCUMENT_STRUCTURE]. Null allowed only if document has no sections. | |
citation_page | integer | Must be a positive integer within the page range of [DOCUMENT_PAGE_COUNT]. Null if page is unknown. | |
citation_paragraph | integer | Must be a positive integer. Null if paragraph numbering is not available in the source. | |
confidence_score | number (0.0-1.0) | Must be a float between 0.0 and 1.0. Scores below [CONFIDENCE_THRESHOLD] should trigger human review. | |
party_attribution | string | Must match a party name from [PARTY_LIST] or be null. Reject fabricated party names. | |
extraction_notes | string | Must be null if confidence_score >= [HIGH_CONFIDENCE_CUTOFF]. Required if confidence_score < [LOW_CONFIDENCE_CUTOFF] to explain uncertainty. |
Common Failure Modes
What breaks first in contract clause extraction and how to guard against it before the output reaches a downstream system or reviewer.
Citation Boundary Drift
What to watch: The model cites the correct section but includes text from an adjacent clause, or the citation span bleeds into a different subsection. This silently corrupts extracted obligations. Guardrail: Add a post-extraction boundary validator that checks the extracted text against the cited section using substring matching. If the extracted text does not appear within the cited section, flag for human review.
Hallucinated Clause Content
What to watch: The model generates plausible-sounding clause language that does not exist in the source document, especially for common boilerplate terms like governing law or indemnification. Guardrail: Require exact string matching between extracted text and the source document. Implement a confidence score threshold below which extractions are routed to a human-in-the-loop queue rather than accepted automatically.
Section Misidentification
What to watch: The model extracts text from the wrong section because section numbering is ambiguous, headers are misread, or the document uses non-standard labeling like schedules and exhibits. Guardrail: Pre-process documents to build a verified table of contents and section hierarchy. Pass this structure map into the prompt as grounding context so the model anchors its search to known section boundaries.
Missing Clause Silent Failure
What to watch: The requested clause type does not exist in the document, but the model returns a confident null without flagging the absence, or worse, fabricates a generic version. Guardrail: Require an explicit clause_present boolean field in the output schema. When false, the model must cite the search scope it examined. Downstream systems should treat absent clauses differently from extraction failures.
Multi-Page Clause Fragmentation
What to watch: A clause that spans a page break is extracted as two disconnected fragments, or the model stops at the page boundary and misses the continuation. Guardrail: Instruct the model to continue extraction across page breaks until it reaches the next section heading. Validate that extracted clause text ends with a complete sentence or section delimiter, not mid-sentence at a page boundary.
Confidence Score Inflation
What to watch: The model reports high confidence for extractions that are actually ambiguous, especially when the clause language is unusual or the document structure is non-standard. Guardrail: Calibrate confidence scores against a golden dataset of known extractions. Add a secondary verification prompt that re-examines low-agreement extractions. Route any extraction where the primary and secondary prompts disagree to human review.
Evaluation Rubric
Run these checks against a golden dataset of 20-50 contracts with known clause locations. Each criterion targets a specific failure mode observed in clause extraction with citation prompts.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Citation Boundary Accuracy | Extracted text start and end match golden boundaries within ±1 sentence tolerance | Output includes text from adjacent clauses or truncates clause content | Compare extracted span offsets against golden span offsets using character-level overlap ratio |
Clause Completeness | All sentences from the golden clause appear in the extracted output | Missing sentences or partial clause extraction with no uncertainty flag | Sentence-level recall against golden clause sentences; flag if recall < 0.95 |
Hallucinated Content Detection | Zero sentences in extracted output that do not appear in the source document | Output contains fabricated clause language, invented section numbers, or synthesized legal terms | Diff extracted text against source document text; flag any n-gram not present in source |
Citation Format Compliance | Every citation includes section number, page number, and paragraph reference in the specified schema | Missing page number, section reference, or malformed citation string | Schema validation against [CITATION_SCHEMA]; reject outputs with missing required fields |
Confidence Score Calibration | Confidence scores correlate with extraction difficulty: low confidence for ambiguous, redacted, or OCR-degraded regions | High confidence assigned to clearly incomplete or uncertain extractions | Compare confidence scores against human-labeled difficulty ratings; flag if confidence > 0.8 on known-hard cases |
Null Handling for Missing Clauses | Returns explicit null or absent flag when target clause type does not exist in the document | Hallucinates a clause or returns unrelated text when the clause is absent | Include 5+ documents without the target clause type in golden set; verify null output |
Multi-Section Clause Aggregation | Correctly aggregates clause text when the clause spans multiple sections or pages | Returns only the first section or breaks the clause into disconnected fragments | Check that all golden-annotated sections appear in the output with correct ordering |
Redacted or Illegible Content Flagging | Output includes explicit redaction or illegibility flag with location citation when content is obscured | Silently omits redacted content or attempts to guess redacted text | Include documents with known redactions in golden set; verify flag presence and absence of guessed content |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and a single-page contract snippet. Remove strict schema enforcement; accept JSON-like output with manual review. Start with a single clause type (e.g., governing law) before expanding to multi-clause extraction.
codeExtract the [CLAUSE_TYPE] clause from the following contract text. Return the clause text and the section/paragraph where it appears. [CONTRACT_TEXT]
Watch for
- Citation boundaries that include adjacent unrelated clauses
- Missing confidence scores when text is ambiguous
- Model inventing clause content for sections not present in the input
- No validation of whether the extracted text actually matches the clause type requested

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us