Skip to main content
When accuracy is critical, running extraction multiple times and comparing results can catch errors that a single pass might miss. This guide covers consensus voting strategies for high-stakes document processing.

Prerequisites

  • Node.js 18+
  • API keys for multiple providers (or OpenRouter for unified access)
  • A document to process

When to Use Consensus

Consensus voting is valuable when:
  • Processing high-value documents (financial, legal, medical)
  • Extraction errors have significant business impact
  • You need confidence scores for extracted values
  • Auditing requirements demand verification
Trade-off: Consensus increases cost and latency proportionally to the number of runs.

Basic Consensus Configuration

Enable consensus on the extract node:

Voting Strategies

Majority (Default)

Each field is voted on independently. The value with the most votes wins:
Example with 3 runs:
  • Run 1: { total: 1250.00 }
  • Run 2: { total: 1250.00 }
  • Run 3: { total: 1250.50 }
Result: { total: 1250.00 } (2/3 agreement)

Unanimous

All runs must agree for a value to be accepted:
If any run disagrees, that field is marked as uncertain or null.

Weighted

Assign different weights to different providers or runs:
Useful when you have a primary provider and backup providers.

Multi-Provider Consensus

Run extraction across different AI providers for diverse perspectives:

Agreement Thresholds

Set minimum agreement levels:
Fields that don’t meet the threshold can be:
  • Set to null
  • Flagged for human review
  • Returned with a confidence score

Accessing Consensus Results

The output includes agreement information:

Observability Hooks

Monitor consensus execution:

Complete Example: Financial Document Validation

Extract and validate financial data with high confidence:

Cost Optimization Strategies

Consensus increases costs. Here are strategies to manage this:

Tiered Consensus

Use single extraction for low-value documents, consensus for high-value:

Selective Field Consensus

Run consensus only on critical fields:

Conditional Re-extraction

Only run consensus when initial extraction has low confidence:

Handling Disagreement

When providers disagree, you have options:

Return Null for Uncertain Fields

Flag for Human Review

Return All Candidate Values

Using Doclo Cloud with Consensus

Configure consensus for cloud-based flows:

Next Steps

Consensus Voting

Consensus configuration reference

Providers

Configure different providers

Extract Invoice

Basic extraction guide

Error Recovery

Handle provider failures