Inferensys

Prompt

Exhibit Identification and Extraction Prompt Template

A practical prompt playbook for identifying, extracting, and linking exhibits in contracts and legal filings within 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

Define the job, reader, and constraints for exhibit identification and extraction in legal and contractual documents.

This prompt is designed for legal engineering teams building document processing pipelines that must reliably identify, extract, and link exhibits within contracts, regulatory filings, and other structured legal documents. The primary job-to-be-done is automated exhibit boundary detection: finding where each exhibit starts and ends, extracting its label and title, and connecting it back to the referencing clause in the parent document. This is not a general-purpose PDF extraction prompt—it assumes the input is a legal document with conventional exhibit structures such as 'Exhibit A,' 'Schedule 1,' or 'Annex B' and that the output will feed into a downstream system for chunking, indexing, or contract review.

Use this prompt when your document pipeline needs to separate exhibits from the main body of a contract for independent processing, when you need to verify that all referenced exhibits are actually present in the document set, or when you need to build a navigable exhibit index for a document Q&A system. The ideal user is a developer or legal engineer who has already extracted text from PDFs or digital documents and needs structured exhibit metadata. Required context includes the full document text, any known exhibit naming conventions used by the organization or document type, and optionally a list of exhibit references extracted from the main body clauses. Do not use this prompt for documents without formal exhibit structures, for general-purpose table of contents extraction, or for documents where exhibits are inline sections rather than separate labeled attachments.

Before deploying this prompt in production, ensure you have a clear definition of what constitutes an exhibit boundary in your document corpus. Some documents use page breaks, others use centered labels, and still others use section numbering conventions. The prompt includes placeholders for [EXHIBIT_NAMING_CONVENTIONS] and [DOCUMENT_TYPE] to adapt to your specific domain. Always pair this prompt with validation checks that verify every extracted exhibit has a non-empty label, that exhibit boundaries don't overlap, and that exhibits referenced in the main body are accounted for in the extraction output. For high-stakes legal workflows, include a human review step for any exhibits flagged as ambiguous or where the extraction confidence falls below your threshold.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Exhibit Identification and Extraction prompt template delivers reliable results and where it introduces unacceptable risk. Use these cards to decide whether this prompt fits your document pipeline before integrating it into production.

01

Good Fit: Structured Legal Filings

Use when: documents follow predictable exhibit labeling conventions such as 'Exhibit A', 'Schedule 1', or 'Appendix B' with clear start and end markers. Guardrail: validate extracted exhibit boundaries against the table of contents when available to catch missed or merged exhibits.

02

Bad Fit: Inline Reference Ambiguity

Avoid when: the document contains frequent inline references like 'see Exhibit A' without the actual exhibit attached. Risk: the model may hallucinate exhibit content or misidentify a reference as the exhibit boundary. Guardrail: require explicit start-marker detection before extracting content and flag references without matching exhibits.

03

Required Inputs

Must provide: the full document text with page markers, a list of expected exhibit labels or a naming pattern, and the referencing clause text that triggered the extraction request. Guardrail: if page markers are missing, limit extraction confidence scores and flag outputs for human review before downstream ingestion.

04

Operational Risk: Multi-Page Drift

Risk: exhibits spanning multiple pages may be truncated if the model relies on a single end marker that appears before the exhibit actually ends. Guardrail: implement a post-extraction length check against expected exhibit size and retry with expanded boundary windows when truncation is detected.

05

Operational Risk: Missing Exhibit Detection

Risk: the referencing clause points to an exhibit that is not present in the document, but the model fabricates content to satisfy the extraction request. Guardrail: add an explicit instruction to return a 'NOT_PRESENT' status with the missing exhibit label rather than generating placeholder text. Validate this status in eval tests.

06

Variant: Exhibit-to-Clause Linking

Use when: you need bidirectional traceability between referencing clauses and extracted exhibits. Guardrail: produce a structured mapping object with clause IDs, exhibit labels, and confidence scores. Test for orphaned exhibits with no referencing clause and clauses that reference non-existent exhibits.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for identifying exhibit boundaries, extracting labels and titles, and linking exhibits to their referencing clauses in legal documents.

The prompt template below is designed to be copied directly into your prompt management system, IDE, or orchestration layer. It uses square-bracket placeholders for all variable inputs, constraints, and output format requirements. Before using it in production, replace each placeholder with the actual values for your document processing pipeline. The template assumes you have already extracted the full text of the contract or filing and can provide it as [DOCUMENT_TEXT]. If your pipeline processes documents page by page, you will need to assemble the full text before invoking this prompt, as exhibit boundaries often span multiple pages and cannot be reliably detected from isolated page chunks.

text
You are a legal document structure analyst. Your task is to identify all exhibits, schedules, annexes, and attachments in the provided document text. For each exhibit found, you must determine its start and end boundaries, extract its label and title, and identify which clauses in the main document reference it.

## INPUT
[DOCUMENT_TEXT]

## CONSTRAINTS
- Only identify exhibits that are actually present in the document text. Do not invent exhibits that are referenced but not included.
- An exhibit begins at its title or label line (e.g., 'Exhibit A', 'Schedule 1', 'Annex B') and ends immediately before the next exhibit begins or at the end of the document.
- Distinguish between inline references to exhibits (e.g., 'as set forth in Exhibit A') and the actual start of an exhibit section. Only mark the latter as an exhibit boundary.
- If an exhibit is referenced in the document but its content is not present, list it under 'referenced_but_missing' with the referencing clause locations.
- Multi-page exhibits must be captured as a single continuous span from start to end.
- If exhibit boundaries are ambiguous due to poor formatting or missing labels, flag the exhibit with confidence='low' and explain the ambiguity.

## OUTPUT_SCHEMA
Return a valid JSON object with this exact structure:
{
  "exhibits": [
    {
      "label": "string (e.g., 'Exhibit A', 'Schedule 2.1')",
      "title": "string or null (the descriptive title if present)",
      "start_char": integer (character offset where exhibit content begins),
      "end_char": integer (character offset where exhibit content ends),
      "referencing_clauses": [
        {
          "clause_text": "string (the sentence or clause that references this exhibit)",
          "location": "string (section number or paragraph reference where the clause appears)",
          "start_char": integer
        }
      ],
      "confidence": "high|medium|low",
      "notes": "string or null (explain any boundary ambiguity or extraction issues)"
    }
  ],
  "referenced_but_missing": [
    {
      "label": "string",
      "referencing_clauses": [
        {
          "clause_text": "string",
          "location": "string",
          "start_char": integer
        }
      ]
    }
  ]
}

## EXAMPLES
[EXAMPLES]

## RISK_LEVEL
[RISK_LEVEL]

## INSTRUCTIONS
1. Scan the full document text for exhibit labels and section headers.
2. For each exhibit found, locate its start boundary (the label line) and end boundary (next exhibit start or document end).
3. Search the main document body for clauses that reference each exhibit by label.
4. If [RISK_LEVEL] is 'high', flag any exhibit with confidence below 'high' for human review.
5. Output only the JSON object. Do not include any explanatory text outside the JSON.

To adapt this template for your pipeline, start by replacing [DOCUMENT_TEXT] with the full extracted text from your PDF or document parser. The [EXAMPLES] placeholder should be populated with one or two few-shot demonstrations showing correct exhibit extraction from documents similar to yours—this is especially important if your documents use non-standard labeling conventions like Roman numerals or descriptive titles without explicit 'Exhibit' prefixes. The [RISK_LEVEL] placeholder accepts 'low', 'medium', or 'high' and controls whether the prompt requests human review flags. For production legal workflows, set this to 'high' and ensure your application layer routes low-confidence extractions to a review queue. The output schema uses character offsets rather than page numbers because character offsets are more reliable across different text extraction methods; your application should map these back to page and line numbers using your document's text position metadata. Before deploying, validate that your model reliably produces the exact JSON schema specified—schema drift is the most common failure mode for structured extraction prompts.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Exhibit Identification and Extraction prompt. Validate each placeholder before calling the model to prevent silent failures and ambiguous boundary detection.

PlaceholderPurposeExampleValidation Notes

[DOCUMENT_TEXT]

Full text of the contract or filing to scan for exhibits

Exhibit A: Master Services Agreement

  1. Scope of Services...

Required. Must be non-empty string. Strip control characters. If OCR output, run layout-aware extraction first to preserve reading order.

[EXHIBIT_REFERENCE_PATTERNS]

Regex or keyword patterns that signal an exhibit reference in the body text

Exhibit [A-Z]|Schedule [0-9]+|Annex [IVX]+|Attachment [0-9]+

Required. Provide as array of pattern strings. Validate each pattern compiles without error. Empty array causes false negatives on exhibit detection.

[DOCUMENT_TYPE]

Type of document to disambiguate exhibit conventions

contract|filing|agreement|amendment|prospectus

Required. Enum check against allowed values. Different document types use different exhibit labeling conventions. Mismatch causes boundary detection errors.

[PAGE_BREAK_MARKER]

Token or string that indicates a page break in the source text

---PAGE BREAK---|\f|{page:###}

Required if multi-page. Must be consistent throughout [DOCUMENT_TEXT]. Missing or inconsistent markers cause multi-page exhibit boundaries to be truncated.

[REFERENCED_ONLY_FLAG]

Whether to include exhibits referenced in body text but not present in the document

true|false

Optional. Default false. When true, output must include a separate 'referenced_but_missing' array. When false, silently skip missing exhibits.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for exhibit boundary detection before flagging for human review

0.7|0.85|0.9

Optional. Float between 0.0 and 1.0. Default 0.7. Boundaries below threshold should be returned with low_confidence flag set to true and routed for review.

[OUTPUT_SCHEMA]

Expected JSON schema for the extracted exhibit list

{"exhibits": [{"label": "string", "title": "string|null", "start_marker": "string", "end_marker": "string", "page_range": "string", "referencing_clause": "string", "confidence": "float", "present": "boolean"}]}

Required. Validate schema is parseable JSON before prompt assembly. Schema mismatch between prompt and downstream parser causes post-processing failures.

[MAX_EXHIBIT_COUNT]

Upper bound on expected exhibits to catch extraction loops

50|100|200

Optional. Integer. Default 100. If extracted count exceeds this, trigger retry or escalation. Prevents runaway extraction on malformed documents.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the exhibit identification prompt into a production document processing pipeline with validation, retries, and human review gates.

The exhibit extraction prompt is rarely a standalone call. It sits inside a document processing pipeline that has already identified the main contract body and needs to isolate exhibits for separate downstream processing, indexing, or summarization. The harness must handle multi-page documents, exhibits that span page breaks, exhibits referenced but not physically present, and inline exhibits that lack clear boundary markers. Before calling the prompt, the application layer should split the document into manageable chunks that preserve page boundary metadata, because the model needs page references to report exhibit locations accurately.

Wire the prompt as a structured output call with a strict JSON schema. Require the model to return an array of exhibit objects, each containing exhibit_label (string), exhibit_title (string or null), start_page (integer), end_page (integer), referencing_clause (string or null), and present_in_document (boolean). Validate the output immediately: check that start_page is less than or equal to end_page, that page ranges don't overlap for exhibits marked as present, and that every present_in_document: false exhibit has a non-null referencing_clause. If validation fails, retry once with the validation errors appended to the prompt as [CONSTRAINTS]. If the retry also fails, route the document to a human review queue with the partial output and error details attached. Log every extraction attempt with the document ID, model version, prompt version, validation result, and retry count for observability.

For documents exceeding the model's context window, implement a two-pass architecture. First, run a lightweight classification pass over each page or chunk to detect exhibit start candidates using a simpler prompt or heuristic (e.g., regex for 'Exhibit', 'Schedule', 'Annex' followed by a label). Second, assemble the candidate pages plus surrounding context into a focused extraction window and run the full exhibit identification prompt only on that subset. This avoids sending entire 200-page filings through the prompt while still giving the model enough context to determine exhibit boundaries and titles. Store the extracted exhibit metadata in your document index so downstream retrieval and Q&A systems can scope searches to specific exhibits when users ask about them.

Model choice matters here. Use a model with strong instruction-following and structured output support for the primary extraction call. Claude 3.5 Sonnet or GPT-4o are good defaults for this task because exhibit boundary detection requires reasoning about document structure, cross-references, and legal formatting conventions. Avoid smaller or older models that struggle with multi-page spatial reasoning. If cost is a concern, use a smaller model for the candidate detection pass and reserve the larger model only for the focused extraction window. Always set temperature=0 or very low to get consistent boundary detection across repeated runs on the same document.

Build eval assertions into your test suite before shipping. At minimum, test: (1) a document with sequentially labeled exhibits all present, (2) a document where an exhibit is referenced but not attached, (3) a document with an inline exhibit that starts mid-page without a page break, (4) a multi-page exhibit spanning three or more pages, and (5) a document with no exhibits at all. For each test case, assert the exact exhibit count, correct label extraction, and accurate page ranges. Run these evals on every prompt change and on every model version upgrade. When an eval fails, inspect whether the prompt needs adjustment or whether the new model has different behavior around boundary detection.

PRACTICAL GUARDRAILS

Common Failure Modes

Exhibit extraction fails silently in ways that corrupt downstream contract analysis. These are the most common failure modes and the specific guardrails that catch them before they reach production.

01

Inline Exhibit Misidentification

What to watch: The model treats an inline reference like 'see Exhibit A attached hereto' as the exhibit itself, extracting the reference sentence as the full exhibit content. This produces empty or one-sentence exhibit outputs that downstream systems treat as valid. Guardrail: Add a minimum content length validator. If extracted exhibit text is under 200 characters, flag for human review and re-prompt with explicit boundary instructions.

02

Exhibit Boundary Bleed

What to watch: The model includes text from the preceding section or following exhibit in the extracted exhibit, usually because the exhibit lacks a clear end marker. This contaminates exhibit content with unrelated clauses. Guardrail: Validate that the extracted text starts with an exhibit label pattern and ends at the next exhibit label, signature block, or document end. Use a post-extraction boundary trimmer that searches for the next structural marker.

03

Referenced-But-Missing Exhibits

What to watch: The main contract references an exhibit that is not actually attached to the document. The model may hallucinate exhibit content rather than reporting it as missing. Guardrail: Before extraction, run a separate detection pass that lists all referenced exhibits and checks for their presence. If an exhibit is referenced but no matching label is found in the document body, output an explicit 'EXHIBIT_NOT_PRESENT' flag instead of attempting extraction.

04

Multi-Page Exhibit Truncation

What to watch: The model extracts only the first page of a multi-page exhibit, often because it treats a page break as an exhibit boundary. This silently drops schedules, tables, or signature pages that continue across pages. Guardrail: After extraction, check whether the exhibit ends with a complete clause, signature block, or next exhibit marker. If it ends mid-sentence or mid-table, extend the extraction window and re-run. Log truncation events for pipeline monitoring.

05

Exhibit Label Ambiguity

What to watch: Documents with inconsistent labeling like 'Exhibit 1', 'Exhibit A', and 'Schedule 1' used interchangeably cause the model to miss exhibits or double-count them. This breaks the mapping between referencing clauses and extracted exhibits. Guardrail: Normalize exhibit labels before extraction using a canonical label schema. Map all variants to a consistent format and validate that each extracted exhibit has exactly one canonical label. Flag documents with unresolvable label conflicts for manual review.

06

Nested Exhibit Confusion

What to watch: An exhibit contains a reference to another exhibit or sub-exhibit, and the model treats the nested reference as a new top-level exhibit boundary. This fragments the parent exhibit and creates phantom exhibits. Guardrail: Track exhibit depth during extraction. When a new exhibit label is detected inside an already-open exhibit, classify it as a sub-exhibit and maintain the parent-child relationship. Validate that no exhibit appears as both a top-level and nested entity in the output.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the Exhibit Identification and Extraction prompt before production deployment. Each row defines a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Exhibit Boundary Precision

Start and end markers match the exact page and paragraph where the exhibit begins and ends in the source document.

Boundary is off by more than one paragraph or includes content from the preceding/following section.

Compare extracted [EXHIBIT_START] and [EXHIBIT_END] spans against a manually annotated golden set of 20 documents.

Exhibit Label Extraction

Exhibit label matches the document's own label exactly, including punctuation and spacing (e.g., 'Exhibit A', 'Schedule 2.1').

Label is missing, truncated, or normalizes away significant characters like periods or parentheses.

Run extraction on a test set with known labels. Require exact string match. Flag any edit distance > 0.

Exhibit Title Extraction

Extracted title is the full, verbatim title as it appears in the document.

Title is paraphrased, truncated mid-phrase, or pulled from a cross-reference instead of the exhibit header.

Spot-check 50 random exhibits. Require human review if Levenshtein similarity to source title < 0.95.

Reference Clause Linking

Every in-document reference to an exhibit (e.g., 'see Exhibit B') is linked to the correct extracted exhibit entry.

A reference is linked to the wrong exhibit, left unlinked, or a false link is created from general text.

Parse all [REFERENCE_CLAUSE] outputs. Verify each linked [EXHIBIT_ID] exists in the output and the clause text contains the exhibit label.

Multi-Page Exhibit Handling

A single exhibit spanning multiple pages is extracted as one contiguous unit, not split into separate entries.

Multi-page exhibit is fragmented into multiple exhibit entries or truncated at a page break.

Count extracted exhibits per document. Flag any document where exhibit count exceeds the known count from a golden manifest by > 0.

Inline Exhibit Detection

Exhibits embedded within the main document body (not at the end) are correctly identified and bounded.

Inline exhibit is missed entirely or its boundaries bleed into surrounding clauses.

Include 10 documents with inline exhibits in the test set. Require 100% recall on these exhibits.

Referenced-But-Missing Flag

Output includes a [MISSING_EXHIBIT] flag with the referenced label when a document references an exhibit not present in the provided file.

Missing exhibit is silently omitted, or a false [MISSING_EXHIBIT] flag is raised for an exhibit that is actually present.

Provide documents with known missing exhibits. Check that [MISSING_EXHIBIT] list matches the expected set exactly.

Exhibit Order Preservation

Extracted exhibits are listed in the order they appear in the document, not alphabetically or by reference order.

Exhibit order is alphabetical, sorted by label, or follows the order of first reference rather than document position.

Compare the sequence of extracted [EXHIBIT_ID] values against the page-ordered sequence in the golden test set. Require sequence match.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small set of known documents (5-10 contracts). Remove strict schema enforcement initially—accept markdown or plain-text output to test extraction quality before locking down JSON structure. Use a single model call per document without chunking.

Prompt modification

  • Replace [OUTPUT_SCHEMA] with: Return a bulleted list with exhibit label, title, start indicator, and end indicator.
  • Set [CONFIDENCE_THRESHOLD] to 0.5 or remove it entirely.
  • Add: If unsure about a boundary, mark it with [UNCERTAIN] and continue.

Watch for

  • Missed inline exhibits (e.g., "Exhibit A follows this paragraph")
  • Multi-page exhibit boundaries that drift by a paragraph
  • Exhibits referenced in text but not actually present in the document—model may hallucinate content
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.