Skip to main content

How to write effective prompts for AI Extractions

Write description-field prompts and schema rules that guide AI Extractions to the right fields, tables, and footnotes across any document layout.

AI Extractions automatically extracts fields, tables, and footnotes at scale across a wide range of document layouts, and every extracted value is traceable back to its source document. Well-structured prompts in the description field are the key to accurate, consistent results. This article explains how to write them and how to refine them when a field is not extracting cleanly.

Prerequisites

  • DataSnipper v26.1 or later

  • DataSnipper Accelerate or Elevate package

Principles of prompting the description field

Use the description field to guide AI Extractions to the exact data you need. These principles help you get consistent results:

  • Be specific about structure: include column names, table layout, or document sections.

  • Add positional information: use phrases like "next to", "under", "in the second column", or "at the bottom".

  • Specify format: include date formats, number formats, character lengths, or data types.

  • Handle variations: describe the different ways the information might appear.

  • Add exclusions: tell the AI what to ignore.

  • Iterate and refine: test your descriptions and verify the results. Some trial and error is part of the process.

How to refine the description field

1. When field names appear multiple times

Scenario: extracting "401K" values from a document where the term appears multiple times in different contexts.

Key: "401K"

Instead of: an empty description, or just "401K value"

Use: "The version that is next to or under community depreciation"

2. Handling complex fields that need extensive prompting

Scenario: extracting footnotes from K1 tax forms that can appear in different formats.

Key: "Footnotes"

Instead of: "Get the footnotes"

Use: "Capture all elements that start with LINE, ITEM, or BOX. They can be in a table. They can be in two types [specify the types]. Ignore pages that just have listings and dumps of codes and how-to-use instructions."

3. Adding format specifications

Scenario: extracting province codes that should be two characters.

Key: "Province of employment"

Instead of: an empty description

Use: "Two character province code"

4. Provide visual location cues

Scenario: extracting tax amounts from invoices where the tax may be labeled differently.

Key: "Tax amount"

Instead of: "Extract the tax amount"

Use: "Extract the tax amount (usually appears as a line item above the total, may be labeled as GST, VAT, Sales Tax, or Tax)"

5. Give examples of variations

Scenario: extracting dates from invoices where the date field may have different labels.

Key: "Invoice date"

Instead of: "Extract the date"

Use: "Extract the invoice date (may appear as 'Invoice Date', 'Date', 'Issued', or 'Bill Date', typically in MM/DD/YYYY or DD/MM/YYYY format)"

6. Clarify ambiguous fields

Scenario: extracting the final invoice total when multiple monetary amounts appear on the document.

Key: "Invoice total"

Instead of: "Extract the total"

Use: "Extract the invoice total (the final amount due after all taxes and discounts, not the subtotal or pre-tax amount). This is typically the largest number on the invoice and may be labeled 'Total', 'Amount Due', or 'Balance Due'"

Example use case: payroll reports

The example below shows how a clear description field guides AI Extractions to the right values on a payroll report.

AI Extractions description field example for extracting values from a payroll report

Schema description: set rules for better extraction

The schema description gives a concise overview of the extraction purpose and the type of content being processed. AI Extractions uses it during property extraction, so clear and precise descriptions improve accuracy.

Guidelines:

  • State the extraction objective clearly and avoid vague or ambiguous instructions.

  • Keep the description concise while including all relevant context.

  • Make sure the description guides how the AI model interprets the content.

Tips for success

Results are extracted from the wrong location: add specific location descriptors to your field description. Example fix: "Extract 401K deduction (located under the accumulation date field, NOT the year-to-date 401K total shown in the summary section)."

Values are missing as non-duplicate entries: indicate in the prompt that all elements, including duplicates, should be extracted. Example fix: "Extract all names, including duplicates, under the personnel column."

Some values are missing: add a new key to target the missed elements, then merge keys and prompts. Example fix: "Extract all dates in YYYY/MM/DD with numerals. Extract all dates in Japanese."

Extraction is slow: extraction time depends on document complexity and may take 5 to 20 seconds per page, with a current limit of 300 pages per document. If it is too slow, run the template on a smaller set first, then split the set into smaller parts if needed.

Did this answer your question?