Skip to main content

Introduction

While schemas define what to extract, prompts guide how to extract it. A well-crafted prompt can significantly improve extraction accuracy, especially for edge cases and ambiguous documents.

Prompt Basics

Default Behavior

If you don’t provide a prompt, Documind uses a generic extraction instruction:

Custom Prompts

Add specific instructions to improve accuracy:

Prompt Structure

Effective Prompt Template

Example:

Best Practices

1. Be Specific About Formats

2. Handle Ambiguity

Documents often have multiple similar values. Guide the extraction:

3. Define Edge Cases

Tell the AI how to handle missing or unusual data:

4. Specify Units and Currency

5. Handle Multiple Values

Domain-Specific Prompts

Invoices

Receipts

Forms

Contracts

Prompt Patterns

Pattern 1: Clarify Location

Help the AI know where to look:

Pattern 2: Provide Examples

Show expected values:

Pattern 3: Define Fallbacks

Handle missing data gracefully:

Pattern 4: Normalize Data

Ensure consistent output:

Pattern 5: Handle Calculations

Guide computed fields:

Advanced Techniques

Multi-Document Types

If processing various document types:

Language-Specific Instructions

For multi-language documents:

Quality Checks

Add validation hints:

Contextual Hints

Provide business context:

Combining Prompts with Schemas

Schemas and prompts work together:

Testing Prompts

A/B Testing

Compare different prompts on the same document:

Prompt Iteration

  1. Start generic: Use a simple prompt
  2. Review errors: Note common mistakes
  3. Add specifics: Address errors in prompt
  4. Test again: Verify improvements
  5. Refine: Continue until satisfied

Common Mistakes

❌ Too Verbose

Problem: Too much information confuses the model.
Solution: Be concise and direct.

❌ Contradicting Schema

Problem: Confusion leads to inconsistent results.
Solution: Ensure prompt and schema align.

❌ No Guidance for Edge Cases

Problem: No guidance for missing fields, multiple values, or ambiguous data.
Solution: Add edge case handling.

❌ Assuming Document Structure

Problem: Not all invoices follow this layout.
Solution: Provide multiple possible locations or labels.

Prompt Templates

General-Purpose Template

Strict Validation Template

Flexible Template

Next Steps

Schema Design

Design schemas that work with your prompts

Invoice Tutorial

See prompts in action for invoice processing

Core Concepts

Understand how prompts fit into the extraction workflow

API Reference

See the extraction API with prompt parameter