Inferensys

Prompt

Document Set Gap Analysis Prompt

A practical prompt playbook for using the Document Set Gap Analysis Prompt in production AI workflows to identify missing provisions, classify risk, and recommend remediation.
Risk analyst performing AI risk assessment on laptop, risk matrices visible, casual office risk session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, the user, and the boundaries for the Document Set Gap Analysis Prompt.

This prompt is designed for compliance engineers and legal operations teams who need to systematically identify missing provisions across a portfolio of documents. The core job-to-be-done is not just reading what's present, but proving what's absent. The ideal user is an AI engineer or technical operator building a compliance review pipeline who needs a structured, machine-readable gap report that can be fed into a governance, risk, and compliance (GRC) system. The required context includes a target document set, a defined inventory of expected provisions (a checklist, policy, or master agreement), and clear rules for what constitutes a 'gap' versus an intentional omission.

Use this prompt when you have a known standard or requirement against which you are auditing a document set, such as checking a vendor contract portfolio against an updated corporate data protection addendum (DPA) template, or verifying that all loan agreements in a package contain the latest regulatory boilerplate. The prompt is designed to produce a structured output with explicit 'absence evidence'—citing the sections that were searched and found to be missing—rather than a simple negative claim. This is critical for audit trails. Do not use this prompt for comparing two documents for textual differences; that is a redline comparison task. Do not use it to reconcile conflicting clauses; that is a reconciliation task. This prompt is specifically for the 'expected-but-not-found' pattern.

Before implementing, you must define your expected provisions inventory with enough precision that absence is a meaningful finding. A vague instruction like 'check for data protection clauses' will produce noisy, low-confidence results. Instead, provide a structured list of specific provisions, such as 'Data Processing Purpose Limitation clause,' 'Cross-Border Data Transfer Mechanism (e.g., SCCs),' and 'Subprocessor Notification Obligation.' The prompt's value scales with the specificity of this input. If your expected provisions are ambiguous, you will get false-positive gaps that waste reviewer time and erode trust in the system. Pair this prompt with a human review step for any gap classified as 'High' risk before it is reported to a business stakeholder.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Document Set Gap Analysis Prompt works and where it introduces unacceptable risk. Use this to decide whether to deploy, adapt, or choose a different approach.

01

Good Fit: Known Provision Inventories

Use when: you have a defined checklist of expected provisions, clauses, or regulatory requirements to check against a document portfolio. Why it works: the prompt compares a known target list against discovered content, producing a structured gap report with absence evidence. Guardrail: maintain the expected-provision inventory as versioned configuration, not ad-hoc user input.

02

Bad Fit: Open-Ended Completeness Review

Avoid when: the task is 'find everything missing' without a predefined checklist. Risk: the model cannot reliably enumerate all possible provisions that should be present; it will hallucinate expected clauses or miss domain-specific requirements. Guardrail: require a closed, curated provision inventory before invoking gap analysis. If the inventory is unknown, use a classification or extraction prompt first.

03

Required Inputs: Provision Inventory and Document Set

Required: a structured list of expected provisions with identifiers, a set of documents to scan, and an output schema for gap records. Risk without these: missing provision definitions cause false negatives; ambiguous document scope causes incomplete scans. Guardrail: validate that the provision inventory is non-empty and each entry has a unique identifier before running the prompt.

04

Operational Risk: False-Positive Gap Flags

What to watch: the model flags a provision as missing when it is present under different wording, in an implied form, or in a referenced external document. Impact: compliance teams waste time investigating phantom gaps, eroding trust in the system. Guardrail: require the prompt to cite the specific text that would satisfy each provision and flag low-confidence matches for human review.

05

Operational Risk: False-Negative Missed Gaps

What to watch: a genuinely missing provision is not flagged because the model misinterprets a related clause as covering the requirement. Impact: compliance gaps go undetected, creating regulatory or contractual exposure. Guardrail: test against a known gap inventory with seeded missing provisions; measure recall and require human review for high-severity provision categories.

06

Domain Constraint: Regulatory and Legal Workflows

What to watch: gap analysis in legal, compliance, or regulatory contexts carries material consequences for incorrect output. Risk: the model may apply the wrong regulatory standard, misinterpret jurisdiction-specific requirements, or miss nuanced interpretive gaps. Guardrail: never treat model output as a final compliance determination. Route all gap reports through qualified human review and document the review decision.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt with square-bracket placeholders for generating a structured gap analysis report from a set of compliance documents.

This prompt template is designed to be dropped into your application's prompt assembly layer. It instructs the model to act as a compliance analyst, comparing a provided document set against a known inventory of required provisions. The output is a structured gap report, not a conversational summary. Every finding must be tied to a specific expected provision and supported by evidence of absence from the source documents. The template uses square-bracket placeholders for all dynamic inputs, making it safe to populate programmatically before each inference call.

text
You are a compliance gap analyst. Your task is to compare a set of provided documents against a list of required provisions and identify what is missing.

## REQUIRED PROVISIONS
[REQUIRED_PROVISIONS]

## DOCUMENT SET
[DOCUMENTS]

## INSTRUCTIONS
1. For each provision in the REQUIRED_PROVISIONS list, determine if it is present in the DOCUMENT SET.
2. If a provision is present, cite the document name, section, and paragraph where it appears.
3. If a provision is absent, classify the gap severity as CRITICAL, HIGH, MEDIUM, or LOW based on [RISK_CLASSIFICATION_RULES].
4. For each gap, provide a remediation recommendation.
5. If a provision is partially addressed, explain what is covered and what is missing.
6. Do not invent provisions that are not in the REQUIRED_PROVISIONS list.
7. If a document is illegible, ambiguous, or contains conflicting information, flag it with an UNCERTAINTY note instead of guessing.

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "analysis_metadata": {
    "documents_reviewed": ["string"],
    "provisions_evaluated": number,
    "gaps_found": number,
    "uncertainty_flags": number
  },
  "findings": [
    {
      "provision_id": "string",
      "provision_description": "string",
      "status": "PRESENT" | "ABSENT" | "PARTIAL",
      "source_citation": {
        "document": "string | null",
        "section": "string | null",
        "paragraph": "string | null",
        "excerpt": "string | null"
      },
      "gap_severity": "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | null,
      "gap_rationale": "string | null",
      "remediation": "string | null",
      "uncertainty_note": "string | null"
    }
  ]
}

## CONSTRAINTS
- Only use provisions from the REQUIRED_PROVISIONS list.
- Do not hallucinate document sections or paragraph numbers.
- If you cannot determine presence or absence with high confidence, set status to "PARTIAL" and include an uncertainty_note.
- For ABSENT provisions, source_citation fields must be null.
- Gap severity must follow [RISK_CLASSIFICATION_RULES].

To adapt this template, replace each placeholder with application-supplied data. [REQUIRED_PROVISIONS] should be a structured list of provision objects, each with an ID and description. [DOCUMENTS] should contain the full text of each document, prefixed with a document identifier and section markers if available. [RISK_CLASSIFICATION_RULES] should define your organization's severity taxonomy—for example, classifying the absence of a regulatory-mandated clause as CRITICAL and a best-practice recommendation as LOW. Before deploying, run this prompt against a known gap inventory to measure false-positive and false-negative rates, and implement a post-processing validator that checks every finding's provision_id against the input list to catch hallucinations.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Document Set Gap Analysis Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to programmatically verify that the input is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[DOCUMENT_SET]

The full text or structured representation of all documents in the portfolio being analyzed. Each document must be delimited with a unique identifier and section markers.

DOC_ID: master-service-agreement-2024 ---SECTION: 12.1--- Text of section 12.1... ---END_SECTION---

Check that each DOC_ID is unique and non-empty. Verify that section delimiters are balanced. Reject if total token count exceeds model context window minus prompt overhead.

[EXPECTED_PROVISIONS]

A structured list of provisions, clauses, or terms that should be present in the document set. Each entry includes a provision name, description, and optional regulatory or policy reference.

PROVISION_ID: data-retention-policy DESCRIPTION: Specifies retention period for customer PII REFERENCE: GDPR Art. 5(1)(e)

Validate that PROVISION_ID values are unique and non-empty. Check that each entry has a non-empty DESCRIPTION. Warn if REFERENCE is missing for provisions tagged as regulatory.

[RISK_CLASSIFICATION_SCHEMA]

The taxonomy of risk levels to assign to each gap. Defines the labels, criteria, and escalation rules for the organization.

CRITICAL: Regulatory violation, immediate remediation required HIGH: Material business risk, 30-day remediation MEDIUM: Best-practice gap, 90-day review LOW: Informational, no action required

Verify that at least one risk level is defined. Check that each level has a non-empty label and criteria. Reject if labels contain only whitespace or duplicate names.

[OUTPUT_SCHEMA]

The exact JSON schema or structured format the gap report must conform to. Defines required fields, types, and constraints for each gap entry.

{ "gaps": [{ "provision_id": "string", "absence_evidence": "string", "risk_level": "CRITICAL|HIGH|MEDIUM|LOW", "remediation": "string" }] }

Parse as valid JSON. Confirm that required fields are present. Validate that risk_level enum values match [RISK_CLASSIFICATION_SCHEMA] labels. Reject if schema is not parseable.

[ABSENCE_EVIDENCE_RULES]

Instructions for what constitutes valid evidence that a provision is absent. Prevents the model from flagging gaps based on inference rather than explicit document content.

A gap is confirmed only when: (1) the provision is not found in any document section, (2) no semantically equivalent clause exists, (3) no cross-reference to the provision exists. Cite the closest related clause if found.

Check that rules are non-empty. Verify that rules include at least one positive criterion (what counts as absence) and one negative criterion (what does not count). Warn if rules are fewer than 50 characters.

[REMEDIATION_TEMPLATE]

The structure for remediation recommendations. Defines what each recommendation must include: action, priority, owner role, and suggested language.

ACTION: Insert new clause in Section [X] PRIORITY: Aligned with risk_level OWNER_ROLE: Legal Counsel SUGGESTED_LANGUAGE: [Draft clause text]

Verify that template fields are non-empty. Check that OWNER_ROLE maps to a valid role in the organization's RACI model if provided. Warn if SUGGESTED_LANGUAGE placeholder is present but no drafting guidance is supplied.

[FALSE_POSITIVE_CONSTRAINTS]

Explicit rules for what should NOT be flagged as a gap. Prevents the model from reporting provisions that are intentionally excluded, covered by external documents, or not applicable.

Do not flag: (1) provisions explicitly waived in a waiver document, (2) provisions covered by a referenced parent agreement, (3) provisions marked as NOT APPLICABLE in the scope section.

Check that constraints are non-empty. Verify that each constraint references a specific condition or document type. Reject if constraints contain only generic language like 'be careful'.

[CONFIDENCE_THRESHOLD]

The minimum confidence score required to include a gap in the final report. Gaps below this threshold are either suppressed or routed to human review.

0.85

Parse as a float between 0.0 and 1.0. Reject if value is below 0.5 or above 1.0. Warn if threshold is below 0.7 for regulated domains. Default to 0.8 if not provided.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the gap analysis prompt into a production document review pipeline with validation, retries, and human escalation.

The gap analysis prompt is designed to operate as a batch inference step within a document processing pipeline, not as a standalone chat interaction. Each invocation should receive a single document's text content, a structured list of expected provisions, and any domain-specific constraints. The prompt returns a structured gap report that downstream systems can parse, store, and route for review. Because gap analysis carries compliance risk, the implementation must include schema validation, confidence scoring, and a human review queue for any gap flagged above a configurable severity threshold.

Wire the prompt into your application using a three-stage harness: (1) Pre-processing extracts document text and normalizes the expected provisions list into the [EXPECTED_PROVISIONS] placeholder format. (2) Inference calls the model with the populated prompt template, requesting the [OUTPUT_SCHEMA] as a JSON array of gap objects. Set temperature=0 and response_format to JSON mode if your provider supports it. (3) Post-processing validates each gap object against the schema—checking that provision_name matches an entry in the expected list, absence_evidence contains a non-empty string with a document citation, and risk_classification is one of the allowed enum values. Any gap that fails validation should trigger a single retry with the validation error injected into the [CONSTRAINTS] field. If the retry also fails, route the document to a human review queue with the raw model output and validation errors attached.

For evaluation and monitoring, maintain a golden dataset of documents with known gap inventories. Run the prompt against this dataset on every prompt change and log precision, recall, and false-positive rate for gap detection. Pay special attention to false-positive gaps—where the model flags a provision as missing when it is actually present under different wording. These are the most common failure mode and erode reviewer trust. Log every gap flag to your observability platform with the document ID, provision name, risk classification, and whether the gap was confirmed or dismissed on human review. Use this feedback to calibrate the [RISK_LEVEL] threshold that determines which gaps auto-escalate. Avoid running this prompt on documents exceeding the model's context window without first chunking by section and aggregating results, as mid-document truncation produces silent false negatives.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact fields, types, and validation rules for the gap analysis report. Use this contract to build a post-processing validator that rejects malformed or hallucinated outputs before they reach a compliance reviewer.

Field or ElementType or FormatRequiredValidation Rule

gap_id

string (kebab-case)

Must match pattern GAP-\d{3}. Must be unique within the output array.

expected_provision

string

Must be a complete sentence describing the missing clause. Length must be between 20 and 500 characters.

absence_evidence

object

Must contain source_document (string) and citation (string referencing a section or page). citation must not be an empty string.

risk_classification

enum

Must be one of: critical, high, medium, low. No other values are allowed.

remediation_recommendation

string

Must be a non-empty string between 10 and 300 characters. Must not be a verbatim copy of expected_provision.

false_positive_risk

boolean

Must be true or false. If true, a risk_rationale field must also be present in the object.

risk_rationale

string

Required only if false_positive_risk is true. Must explain why the gap might be a false positive in 10-200 characters.

remediation_priority

integer

Must be an integer between 1 and 100. A lower number indicates higher priority. Must be consistent with risk_classification (e.g., critical must have a priority less than 25).

PRACTICAL GUARDRAILS

Common Failure Modes

Document set gap analysis fails in predictable ways. These are the most common production failure modes and the specific guardrails that prevent them.

01

False-Positive Gap Flags

What to watch: The model flags a provision as missing when it actually exists under a different name, in an incorporated-by-reference document, or in an implied form. This erodes trust and creates unnecessary remediation work. Guardrail: Require the model to cite the specific section where it expected to find the provision and explain why it was not found. Pair with a second-pass verification prompt that re-checks flagged gaps against the full document text before finalizing the report.

02

Missed Gaps from Synonym Blindness

What to watch: The expected provision uses terminology that differs from the document's actual language (e.g., 'indemnification' vs. 'hold harmless'). The model fails to recognize semantic equivalence and reports a gap where none exists, or worse, misses a real gap because it searched for the wrong surface form. Guardrail: Include a terminology mapping in the prompt that lists known synonyms and alternative phrasings for each expected provision. Run a pre-processing step that extracts all defined terms from the document set and injects them into the gap analysis context.

03

Scope Creep in Gap Classification

What to watch: The model classifies a provision as missing because it falls outside the document's intended scope, not because of an actual drafting omission. For example, flagging missing data-processing terms in a simple NDA. This inflates the gap report with irrelevant findings. Guardrail: Define explicit scope boundaries per document type in the prompt. Include a pre-classification step that determines the document's governing purpose and filters the expected-provision checklist to only those applicable to that document category before running gap detection.

04

Hallucinated Provision Text in Remediation Recommendations

What to watch: When generating remediation recommendations, the model invents clause language that sounds plausible but introduces legal risk or contradicts other document provisions. This is especially dangerous when the output is passed directly to drafting workflows. Guardrail: Restrict remediation output to structured guidance (provision type, risk level, reference examples) rather than generated clause text. If clause suggestions are required, ground them in existing clauses from the same document set and flag them as draft-only requiring human review.

05

Cross-Document Context Collapse

What to watch: When analyzing gaps across a portfolio of documents, the model loses track of which document contains which provision, conflating evidence from multiple sources or attributing a found provision to the wrong document. This produces a gap report with incorrect source citations. Guardrail: Structure the prompt to process each document independently first, extracting a provision inventory with document-level citations. Then run the gap analysis against the aggregated inventory, preserving document-source pointers at every step. Validate citation accuracy with a separate verification pass.

06

Risk Severity Inflation

What to watch: The model assigns high-risk classifications to minor or cosmetic gaps, reducing the report's usefulness for prioritization. Every missing provision becomes 'critical,' overwhelming reviewers. Guardrail: Provide a calibrated risk rubric with concrete examples for each severity level. Require the model to justify each risk classification with specific consequences of the gap. Run a calibration check against a known gap inventory with pre-assigned severity labels and flag deviations for human adjustment.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Document Set Gap Analysis Prompt against a known gap inventory before shipping. Each criterion targets a specific failure mode observed in document portfolio analysis.

CriterionPass StandardFailure SignalTest Method

Gap Recall

All known gaps from the test inventory are identified with correct provision names

Known gap is absent from the output or mislabeled as a different provision type

Compare output gap list against a golden gap inventory of 10-15 known missing provisions across the test document set

False-Positive Rate

Zero false-positive gaps flagged where the provision actually exists in the document set

Output flags a provision as missing but the provision text is present in a cited or uncited document

For each flagged gap, manually verify the provision is absent from all documents in the set; count false positives

Source Citation Accuracy

Every gap flag includes a document identifier and section reference that correctly points to where the provision should be but is not

Citation points to a document that does not exist in the set, a section that contains the provision, or a hallucinated section number

Cross-reference each citation against the actual document structure; flag any citation that resolves to a provision that exists

Risk Classification Consistency

Risk severity assignments (Critical, High, Medium, Low) match the predefined risk rubric for the domain

A gap with regulatory exposure is classified as Low, or a cosmetic gap is classified as Critical without justification

Run 5 known gaps with pre-assigned risk levels through the prompt and measure exact-match accuracy against expected classifications

Remediation Recommendation Actionability

Each remediation recommendation includes a specific action, responsible party type, and suggested timeline

Recommendation is generic (e.g., 'add the clause') without specifying what clause, who should add it, or by when

Review all remediation fields for presence of action verb, role label, and time-bound element; flag any with fewer than 2 of 3

Absence Evidence Quality

Each gap includes a statement explaining why the provision is considered absent, referencing document sections searched

Evidence field is empty, contains only 'not found', or references a document that was not provided in the input set

Check that every gap row has a non-empty evidence field containing at least one document reference and a search rationale

Output Schema Compliance

Output is valid JSON matching the expected schema with all required fields present and correctly typed

Output is missing required fields, contains extra untyped fields, or fails JSON parse

Validate output against the JSON Schema definition; reject if validation errors exist or required fields are null without explicit null justification

Cross-Document Coverage

The analysis references all documents in the input set when searching for each expected provision

Output only searches one document and declares a gap without checking other documents in the set

For each gap, verify the evidence field mentions searching across all provided documents; flag gaps where only a subset of documents was checked

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single document set and a short expected-provisions list. Remove strict schema enforcement and accept paragraph-style output. Start with 5–10 known provisions to validate gap detection logic before scaling.

Replace [OUTPUT_SCHEMA] with: Return a markdown list of missing provisions with a one-sentence risk note for each.

Watch for

  • False-positive gaps when a provision exists under a different name or section heading
  • Overly broad gap claims without citing where the provision should appear
  • Missing severity differentiation when everything is flagged as high-risk
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.