This prompt is designed for legal operations teams and contract intelligence engineers who need to extract structured entity records from contract text. It targets parties, dates, jurisdictions, governing law, and defined terms while handling counterparty aliases, amendment chains, and entity roles such as licensor, lessee, or indemnitor.
Prompt
Entity Extraction Prompt for Legal Contracts

When to Use This Prompt
Understand the ideal use case, required inputs, and critical limitations of the entity extraction prompt for legal contracts.
Use this prompt when you need to ingest a corpus of agreements into a contract management system, populate a clause library, or feed a downstream risk analysis pipeline. The prompt assumes the input is clean, machine-readable contract text. It does not handle scanned PDFs or handwritten markups without an OCR preprocessing step.
This is not a contract review or redlining prompt. It does not flag risky clauses, suggest alternative language, or provide legal advice. Its job is extraction, not interpretation. For high-risk workflows, always route low-confidence extractions to a human review queue and maintain source attribution for every extracted entity.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the Entity Extraction Prompt for Legal Contracts is the right tool for your current task.
Good Fit: Structured Contract Review
Use when: You need to extract a predictable set of entities (parties, dates, jurisdictions) from a single, well-formatted contract to populate a contract management system. Guardrail: The prompt excels with defined schemas. Always provide an [OUTPUT_SCHEMA] with explicit fields and enum values to prevent type confusion.
Bad Fit: Legal Advice or Risk Interpretation
Avoid when: The task requires interpreting clause fairness, summarizing legal risk, or recommending a course of action. This prompt extracts entities, it does not provide legal judgment. Guardrail: Route risk analysis tasks to a separate, human-in-the-loop review workflow. Never present extracted entities as a risk assessment.
Required Input: Clean, Machine-Readable Text
What to watch: The prompt fails silently on scanned PDFs, low-contrast images, or heavily watermarked documents. OCR artifacts introduce phantom entities. Guardrail: Pre-process all documents with a layout-aware parser. Validate that the [INPUT] text contains the expected contract sections before calling the extraction prompt.
Operational Risk: Amendment Chains
What to watch: Extracting entities from a single amendment without the master agreement produces an incomplete, misleading record. The effective date or governing law may be overwritten. Guardrail: Always provide the full document chain in [CONTEXT]. Instruct the model to resolve conflicts by prioritizing the most recent amendment for changed terms while preserving original definitions.
Operational Risk: Counterparty Aliases
What to watch: A single legal entity may be referenced by a short name, a DBA, or an outdated legal name throughout the contract. The prompt may extract these as separate entities. Guardrail: Add a canonicalization step. Use a post-processing resolver or a second prompt pass with a provided alias map to merge extracted entities into a single canonical record.
Bad Fit: Unbounded Entity Discovery
Avoid when: You want the model to find every possible "interesting" entity without a predefined schema. This leads to inconsistent output and missed critical fields. Guardrail: Always define a strict [OUTPUT_SCHEMA]. For exploratory work, use a separate, non-schema prompt to suggest new entity types, then add them to the extraction schema after human review.
Copy-Ready Prompt Template
A production-ready prompt for extracting legal entities into a strict JSON schema with source attribution and confidence flags.
This prompt template is designed to be dropped into your AI system for extracting parties, dates, jurisdictions, governing law, and defined terms from contract text. It instructs the model to produce a predictable JSON structure that downstream systems can ingest without parsing surprises. The template uses square-bracket placeholders that you must replace with your specific contract text, entity definitions, and output requirements before sending to the model.
textYou are a legal entity extraction system. Your task is to extract structured entities from the provided contract text. You must follow the output schema exactly. Do not add fields, omit required fields, or change field types. If an entity type is not present in the text, return an empty array for that field. If an entity is present but ambiguous, include it with a confidence score below 0.8 and a flag for human review. ## INPUT [CONTRACT_TEXT] ## ENTITY DEFINITIONS Extract the following entity types: - parties: Legal persons or organizations entering into the contract. Include their role (e.g., licensor, lessee, indemnitor, counterparty). - effective_date: The date the contract becomes effective. Normalize to YYYY-MM-DD format. - termination_date: The date the contract terminates or expires. Normalize to YYYY-MM-DD format. If not specified, use null. - governing_law: The jurisdiction whose laws govern the contract. Include the specific state or country. - jurisdiction: The courts or venue where disputes will be resolved. - defined_terms: Terms explicitly defined in the contract. Include the term and its definition. - amendment_references: References to prior agreements, amendments, or related contracts. - monetary_amounts: All monetary figures with their currency, amount, and what they represent (e.g., license fee, damages cap, retainer). ## OUTPUT SCHEMA Return a single JSON object with this exact structure: { "contract_id": "string or null if not provided", "extraction_timestamp": "ISO 8601 timestamp of extraction", "entities": { "parties": [ { "name": "string", "role": "string", "aliases": ["string"], "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false } ], "effective_date": { "value": "YYYY-MM-DD or null", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false }, "termination_date": { "value": "YYYY-MM-DD or null", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false }, "governing_law": { "jurisdiction": "string or null", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false }, "jurisdiction": { "venue": "string or null", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false }, "defined_terms": [ { "term": "string", "definition": "string", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false } ], "amendment_references": [ { "reference": "string", "date": "YYYY-MM-DD or null", "relationship": "string (e.g., amends, supersedes, incorporates)", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false } ], "monetary_amounts": [ { "amount": 0.0, "currency": "string (ISO 4217 code)", "description": "string", "confidence": 0.0, "source_span": "exact text from contract", "needs_review": false } ] } } ## CONSTRAINTS - Every entity must include a source_span: the exact text from the contract that supports the extraction. - Confidence scores must be between 0.0 and 1.0. Use 0.0 only when the entity type is not present in the text. - Set needs_review to true when confidence is below 0.8, when the source text is ambiguous, or when multiple interpretations are possible. - For parties, resolve aliases and include them in the aliases array. Use the canonical legal name as the name field. - For dates, normalize to YYYY-MM-DD. If only a partial date is available (e.g., only the year), use the available portion and set needs_review to true. - If the contract references amendments or prior agreements, extract them as amendment_references even if the full text of those documents is not provided. - Do not hallucinate entities. If an entity type is not present, return an empty array or null as specified in the schema. ## EXAMPLES [EXAMPLES] ## RISK LEVEL [RISK_LEVEL]
To adapt this prompt, replace [CONTRACT_TEXT] with the full text of the contract you are processing. If you have few-shot examples that demonstrate correct extraction for your specific contract types, add them to the [EXAMPLES] section. Set [RISK_LEVEL] to 'high' if the extraction will be used for binding decisions without human review; this instructs the model to be more conservative with confidence scores and to flag more entities for review. For production deployments, always validate the output JSON against the schema before ingestion, and route any entity with needs_review set to true to a human review queue. This prompt works best with models that have strong instruction-following and JSON generation capabilities, such as GPT-4, Claude 3.5 Sonnet, or fine-tuned variants. Avoid using this prompt with models that have weak schema adherence, as missing or malformed fields will break downstream ingestion pipelines.
Prompt Variables
Required and optional inputs for the entity extraction prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to check that the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CONTRACT_TEXT] | Full text of the legal contract to extract entities from | "This Master Services Agreement (the 'Agreement') is entered into as of January 15, 2024 by and between Acme Corp, a Delaware corporation..." | Non-empty string. Minimum 50 characters. Check for PDF extraction artifacts, missing pages, or garbled OCR output before passing to prompt. |
[ENTITY_TYPES] | List of entity categories to extract from the contract | ["parties", "effective_date", "governing_law", "jurisdiction", "defined_terms", "obligation_triggers"] | Must be a valid JSON array of strings. Each string must match a supported entity type in the extraction schema. Reject unknown types before prompt assembly. |
[OUTPUT_SCHEMA] | JSON Schema describing the expected output structure for extracted entities | {"type": "object", "properties": {"parties": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}, "role": {"type": "string"}, "aliases": {"type": "array"}}}}}} | Must be valid JSON Schema draft-07 or later. Validate with a schema validator before injection. Required fields must be marked. Nullable fields must be explicit. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score (0.0 to 1.0) for including an extracted entity in the output | 0.75 | Must be a float between 0.0 and 1.0. Values below 0.5 produce noisy output. Values above 0.95 may suppress valid but ambiguous entities. Default to 0.7 if not specified. |
[NORMALIZATION_RULES] | Rules for canonicalizing extracted values to standard forms | {"dates": "ISO 8601", "party_names": "full_legal_name_only", "amounts": "numeric_usd"} | Must be a valid JSON object. Each key must map to a supported normalization strategy. Unsupported rules should cause prompt assembly to fail with a clear error. |
[AMENDMENT_CHAIN_CONTEXT] | Prior contract versions or amendments for resolving entity evolution across document versions | "Amendment No. 1 to the MSA dated March 3, 2024 between Acme Corp and Beta LLC..." | Optional. If provided, must be a non-empty string. If null, the prompt should include an explicit instruction that amendment history is unavailable and entities reflect only the current document. |
[JURISDICTION_HINTS] | Default jurisdiction assumptions when the contract text is ambiguous or silent | {"default_country": "US", "default_state": "California"} | Optional. Must be a valid JSON object with at least one key. Used only when [CONTRACT_TEXT] lacks explicit jurisdiction language. If null, the model should mark jurisdiction as 'not_specified' rather than guessing. |
Implementation Harness Notes
How to wire the entity extraction prompt into a production legal contract pipeline with validation, retries, and human review.
This prompt is designed to be called as a single step within a larger contract ingestion pipeline, not as a standalone chat interface. The application layer is responsible for document chunking, prompt assembly, output validation, and downstream routing. Because legal contracts carry high operational and regulatory risk, the harness must enforce strict schema compliance, log every extraction attempt, and escalate ambiguous outputs to a human review queue before extracted entities reach a contract management system or obligation tracker.
Pre-processing: Split the contract into sections (parties, recitals, definitions, operative clauses, signatures) using a layout-aware parser or section-heading heuristic. Each section becomes a separate prompt call with shared context about the document type and governing jurisdiction. Pass the full contract text as a single [DOCUMENT] block only for short agreements under ~8,000 tokens; for longer contracts, extract the parties clause, definitions section, and signature block as targeted chunks and merge results in the application layer. Model choice: Use a model with strong structured output support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and enable JSON mode or structured outputs with the schema defined in the prompt. Do not use a smaller, faster model for this workflow unless you have a validated fine-tuned variant and a high-recall validation layer. Validation: After each extraction call, validate the JSON output against the expected schema. Check that: (1) all required entity categories are present, even if empty arrays; (2) every entity has a non-empty mention_text and canonical_form; (3) confidence values are numbers between 0 and 1; (4) source_span references exist in the input text; (5) dates parse to valid ISO 8601 strings. Reject and retry any output that fails schema validation, up to two retries with the validation errors appended to the prompt as [PREVIOUS_ERRORS].
Retry and escalation logic: If the model fails to produce valid JSON after two retries, or if any extracted entity has a confidence score below your defined threshold (start at 0.7 for high-risk fields like party names and governing law, 0.5 for defined terms), flag the entire contract section for human review. Do not silently drop low-confidence entities—route them to a review queue with the source text, the model's partial output, and the validation failure details. Logging: Log every extraction call with: prompt version, model identifier, input token count, output token count, latency, validation pass/fail, retry count, and the final output or escalation reason. This audit trail is essential for legal operations teams who must demonstrate extraction quality to compliance reviewers. Downstream ingestion: Only after validation passes should extracted entities be written to the contract management system. Map the canonical entity forms to your master data records using the entity resolution prompts in this pillar. Store the raw extraction output alongside the mapped records so that auditors can trace every system field back to its source span in the original contract.
What to avoid: Do not use this prompt in a streaming or real-time chat context where partial outputs might be consumed before validation. Do not skip the source-span validation step—legal teams need to click from an extracted party name directly to the contract text that produced it. Do not assume the model will correctly handle amendment chains or counterparty aliases without explicit instructions; those cases are covered in the prompt template's [CONSTRAINTS] section and should be tested with your own contract corpus before production deployment. Start with a golden dataset of 20–50 annotated contracts covering your most common agreement types, run the full pipeline, and measure precision and recall per entity category before expanding to live documents.
Expected Output Contract
Define the exact shape of the JSON object the model must return for each extracted entity. Use this contract to build a server-side validator before ingesting model output into downstream systems.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
entities | Array of objects | Must be a JSON array. If no entities are found, return an empty array, not null or a missing key. | |
entities[].mention_text | String | Exact substring from [DOCUMENT_TEXT]. Must pass a substring existence check against the source text. Non-empty. | |
entities[].entity_type | Enum: PARTY | DATE | JURISDICTION | GOVERNING_LAW | DEFINED_TERM | AMENDMENT_REF | Must match one of the defined enum values. Reject any output with an unrecognized type. | |
entities[].canonical_form | String or null | Normalized representation. For PARTY, use full legal name. For DATE, use ISO 8601 (YYYY-MM-DD). If normalization is not possible, set to null. | |
entities[].role | Enum: LICENSOR | LICENSEE | LESSOR | LESSEE | INDEMNITOR | INDEMNITEE | null | Required only when entity_type is PARTY. Must be a valid role from the contract context. Set to null for non-PARTY types or when the role is ambiguous. | |
entities[].source_spans | Array of objects: [{start: int, end: int}] | Character offsets locating mention_text in [DOCUMENT_TEXT]. Each span must pass a boundary check: source_text[start:end] must equal mention_text. | |
entities[].confidence | Number between 0.0 and 1.0 | Model's self-assessed confidence. Values below 0.7 should be routed for human review. Must be a float, not a string. | |
entities[].aliases | Array of strings or null | Other names or abbreviations used for this entity in the document. Set to null if no aliases are detected. If present, each alias must be a substring of [DOCUMENT_TEXT]. |
Common Failure Modes
Entity extraction from legal contracts fails in predictable ways. These cards cover the most common production failure modes and how to guard against them before they reach downstream systems.
Counterparty Alias Drift
What to watch: The same legal entity appears under multiple names across the contract—full legal name, shortened alias, 'Party A' defined-term reference, and signature-block variant. The prompt extracts each as a separate entity instead of resolving them to one canonical party. Guardrail: Include a defined-terms mapping step before extraction. Instruct the model to resolve all aliases and defined-term references to the canonical legal name from the preamble or definitions section. Validate that the output party count matches the contract's stated number of counterparties.
Governing Law vs. Venue Confusion
What to watch: The model conflates governing law (which state's law applies) with venue (where disputes are litigated) or jurisdiction (which courts have authority). These are distinct legal concepts that often appear in separate clauses but get merged into a single incorrect extraction. Guardrail: Use separate output fields for governing_law, venue, and jurisdiction_forum. Add a validation rule that flags records where all three fields contain identical values, as this often indicates conflation. Include few-shot examples showing correct separation from real contract language.
Amendment Chain Entity Collapse
What to watch: When processing an amendment or addendum, the model extracts only the entities named in the amendment text and omits the original contracting parties. The amendment may reference 'the Parties' without restating their full legal names, causing entity loss. Guardrail: Require the prompt to identify whether the document is an original agreement, amendment, or restatement. For amendments, instruct extraction of both the original parties (from recitals or reference clauses) and any new or substituted parties. Flag outputs where the extracted party count is fewer than two for bilateral contracts.
Defined-Term Scope Leakage
What to watch: The model extracts a defined term from a nested definition that applies only within a specific section or schedule, then applies it globally. For example, 'Services' may have a narrow definition in an exhibit that differs from the main agreement's definition. Guardrail: Include a scope-awareness instruction that ties each defined term to its definition location (section, schedule, or exhibit). When a term is redefined in a sub-document, extract both definitions with their scope boundaries. Add a post-extraction check for duplicate defined terms with conflicting definitions.
Entity Role Misassignment
What to watch: The model extracts party names correctly but assigns wrong roles—labeling the licensor as licensee, lessor as lessee, or indemnitor as indemnitee. This is especially common in mutual or reciprocal clauses where both parties take on both roles in different sections. Guardrail: Anchor role extraction to the specific clause context, not the document-level party list. Use clause-level extraction with role labels tied to the action verb in each sentence. Validate that no party is assigned mutually exclusive roles within the same clause without explicit reciprocal language.
Signature-Block Entity Extraction Failure
What to watch: The model extracts parties from the preamble and body text but misses entities that appear only in signature blocks, notary blocks, or execution pages. Subsidiaries, guarantors, and authorized signatories often appear exclusively in these sections. Guardrail: Explicitly instruct the model to scan signature blocks, execution pages, schedules, and exhibits for additional entity mentions. Add a completeness check that compares preamble parties against signature-block signatories and flags discrepancies for human review.
Evaluation Rubric
Criteria for testing the quality of extracted legal entities before integrating the prompt into a production contract review pipeline.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Party Entity Completeness | All signatory and referenced parties are extracted with their defined roles (e.g., Licensor, Indemnitor). | A named party in the preamble or signature block is missing from the output. | Diff extracted entities against a manually labeled golden set of 20 contracts. |
Counterparty Alias Resolution | All aliases, DBAs, and shorthand names for a party are mapped to a single canonical [PARTY_NAME]. | Two separate entity objects exist for 'Acme Corp' and 'Acme Corporation' without a resolution link. | Check for duplicate [PARTY_CANONICAL_ID] values in the output; verify alias mapping in the [ALIASES] field. |
Date Normalization Accuracy | All dates are extracted and normalized to ISO 8601 format in the [NORMALIZED_DATE] field. | A date is output in its raw text form (e.g., 'the 5th day of March, 2024') or is off by one day. | Parse the [NORMALIZED_DATE] field with a strict date parser and compare against a source-of-truth timeline. |
Governing Law Extraction | The governing law jurisdiction is correctly identified and populated in the [GOVERNING_LAW] field. | The [GOVERNING_LAW] field is null when a governing law clause exists, or it contains the state of incorporation instead. | Assert that [GOVERNING_LAW] is not null for contracts containing a 'Governing Law' section header. |
Defined Term Identification | All terms defined in a definitions section or via quoted inline definitions are extracted with their [DEFINED_TERM] and [TERM_DEFINITION]. | A defined term is extracted but its definition is truncated or missing the substantive clause. | Validate that for every [DEFINED_TERM], the corresponding [TERM_DEFINITION] string length is greater than 10 characters. |
Amendment Chain Handling | The prompt correctly identifies the [ROOT_CONTRACT_ID] and lists all amendments in the [AMENDMENT_CHAIN] array. | An amendment is incorrectly identified as the root contract, or a prior amendment is missing from the chain. | Check that the [CONTRACT_TYPE] field is 'amendment' and that the [AMENDMENT_CHAIN] array contains at least one prior [CONTRACT_ID]. |
Confidence Score Calibration | A [CONFIDENCE] score of 0.9 or above correlates with human-verified correct extraction. | A high-confidence extraction (>=0.95) is factually wrong, indicating overconfidence. | Run a calibration plot on 100 extractions; the Brier score for high-confidence buckets should be less than 0.05. |
Null vs. Missing Handling | The [EXTRACTION_STATUS] field is 'extracted' for found entities, 'not_present' for absent entities, and 'not_applicable' for irrelevant categories. | A missing entity type returns a null object instead of an object with [EXTRACTION_STATUS]: 'not_present'. | Assert that the output JSON contains a key for every entity category defined in the [OUTPUT_SCHEMA] with a valid [EXTRACTION_STATUS]. |
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 simplified JSON schema. Remove strict enum constraints for [ENTITY_TYPE] and [ROLE]. Accept a single pass without retry logic. Focus on extracting the most common entities: parties, dates, governing law, and defined terms.
Prompt modification
- Replace strict
enumlists with descriptive guidance: "Classify the entity type as best you can (e.g., PERSON, ORG, DATE, LOCATION, TERM)." - Drop the
confidencefield requirement or make it optional. - Remove source span offsets (
start_char,end_char) and use onlymention_text.
Watch for
- Entity type confusion between party names and defined terms
- Missing amendment-chain entities when contracts reference prior agreements
- Overly broad extraction that treats every noun phrase as an entity

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