Table of Contents
- Why Haiku 4.5 for Document Analysis
- Understanding Context Windows and Token Economics
- Designing Prompts for Long-Context Workflows
- Output Validation and Reliability Patterns
- Cost Optimisation Strategies
- Common Failure Modes and How to Avoid Them
- Integrating Haiku 4.5 into Production Systems
- Real-World Implementation Patterns
- Monitoring, Logging, and Observability
- Next Steps and When to Escalate
Why Haiku 4.5 for Document Analysis
Haiku 4.5 has become the go-to model for long-context document analysis workflows because it strikes a rare balance: strong reasoning capability at a fraction of the cost of larger models, with a 200K token context window that handles most real-world documents without chunking or retrieval-augmented generation (RAG) complexity.
For teams building at PADISO, we’ve seen this play out consistently. A financial services client processing regulatory filings needed to extract compliance obligations from 80–120 page PDFs. Using Haiku 4.5, we shipped extraction at $0.02–0.05 per document with 94% accuracy on the first pass. A previous attempt with a larger model cost 8–10x more and didn’t improve accuracy enough to justify the spend. Another client—an insurance underwriting team—used Haiku 4.5 to analyse claims narratives, policy documents, and medical records in a single pass, cutting manual review time from 6 hours to 18 minutes per claim.
The appeal isn’t just cost. It’s predictability. Haiku 4.5 is fast enough that you can afford to run validation loops, re-prompts, and structured output checks without blowing your budget. Larger models often force you to get it right the first time or accept the cost of retries. With Haiku 4.5, you can build in safety margins.
However—and this is critical—long-context workflows with Haiku 4.5 aren’t free of gotchas. The model can lose focus in the middle of very long documents. Token costs scale linearly with document length. Prompt design matters more than many teams expect. And without proper output validation, you’ll ship broken extraction pipelines into production.
This guide covers the patterns we’ve validated across 50+ production deployments, the pitfalls we’ve learned to avoid, and the specific engineering decisions that separate teams shipping reliable systems from those shipping brittle ones.
Understanding Context Windows and Token Economics
How the 200K Context Window Works
Haiku 4.5’s 200,000 token context window is the foundation of long-document workflows. To use it effectively, you need to understand what that means in practice.
First, tokens aren’t words. In the Claude tokeniser, roughly 1 token ≈ 0.75 words for English text. A 50-page PDF at ~300 words per page is ~15,000 words, or ~20,000 tokens. That fits comfortably in the context window with room for a detailed prompt and structured output.
But here’s where teams go wrong: they don’t account for the full token budget. If you send a 100,000-token document plus a 5,000-token system prompt, you have ~95,000 tokens left for the model’s response. If your extraction task requires a 10,000-token JSON output with detailed reasoning, you’ve just used 15% of your remaining budget on output alone. That’s fine. But if you’re iterating—sending follow-up prompts, re-prompting on validation failures, or running multiple extraction passes—your token math breaks down fast.
According to research on how language models use long contexts, models can struggle to extract information from the middle of very long documents. This isn’t a Haiku 4.5 problem specifically; it’s a general limitation. But it means that shoving a 180K-token document at the model and hoping for the best is a recipe for missed information. Strategic chunking and focused prompting work better than raw context length.
Token Counting and Budget Planning
Before you deploy, count tokens. Use the Claude API documentation to understand the tokeniser. For PDFs, assume the extracted text will be 80–90% of the rendered page count (headers, footers, and formatting eat tokens). For structured documents (JSON, XML, CSV), token count is closer to actual character count.
Here’s a practical formula for budget planning:
Total tokens = Document tokens + System prompt tokens + User prompt tokens + (Expected output tokens × 1.2)
The 1.2× multiplier accounts for the fact that structured output (JSON, XML) often expands slightly as the model reasons through the task. If your total exceeds 150,000 tokens, consider splitting the document or using a two-pass approach (first pass: extract structure, second pass: fill detail).
Cost Per Document
Haiku 4.5 pricing is $0.80 per million input tokens and $4.00 per million output tokens. For a 50-page document (20,000 input tokens) with a 2,000-token output:
- Input cost: 20,000 ÷ 1,000,000 × $0.80 = $0.016
- Output cost: 2,000 ÷ 1,000,000 × $4.00 = $0.008
- Total: $0.024 per document
At scale (10,000 documents per month), that’s $240. Add 20% for retries and validation loops, and you’re at $288 per month. For most teams, this is negligible compared to the labour cost of manual review. But it’s worth calculating upfront so you’re not surprised by your bill.
Designing Prompts for Long-Context Workflows
System Prompt Structure
Your system prompt sets the tone for the entire extraction task. It should be clear, specific, and concise—not verbose. Here’s a template that works:
You are an expert document analyst specialising in [domain]. Your task is to extract structured information from documents with high accuracy.
Key principles:
1. Extract only information explicitly stated in the document.
2. If information is ambiguous or missing, mark it as null or "not found".
3. Preserve original phrasing for quotes; paraphrase for summaries.
4. Flag any contradictions or inconsistencies you encounter.
Output format: [JSON / XML / structured text as appropriate]
This is 60–80 tokens. It’s enough to establish context without wasting budget on flowery preamble. The specific principles matter: teams that skip the “extract only what’s stated” instruction get hallucinated data. Teams that don’t ask for null/“not found” values get creative guesses instead of honest gaps.
User Prompt Design for Long Documents
When you’re working with long documents, the user prompt needs to do three things:
- State the task clearly. Don’t assume the model will infer your intent from the document alone.
- Provide examples or templates. Show the model what good output looks like.
- Set boundaries. Tell the model what to ignore, what’s in scope, and what to do with edge cases.
Here’s a real example from a financial services extraction task:
Extract the following information from this financial agreement:
- Counterparty name
- Agreement date (YYYY-MM-DD)
- Effective date (YYYY-MM-DD)
- Termination date or termination clause (if stated)
- Key obligations (list, max 5)
- Payment terms (amount, currency, frequency)
- Governing law jurisdiction
- Any material amendments or side letters (list)
Output as JSON. For any field, if the information is not present, use null.
Example output:
{
"counterparty_name": "Acme Corp",
"agreement_date": "2024-01-15",
"effective_date": "2024-01-15",
"termination_date": null,
"termination_clause": "Either party may terminate with 90 days' written notice",
"key_obligations": ["Maintain insurance", "Provide monthly reports"],
"payment_terms": "$100,000 USD, quarterly in advance",
"governing_law": "New York",
"amendments": null
}
This prompt is ~250 tokens. It’s explicit about what you want, shows a template, and makes it clear that null is acceptable. Teams that ship this kind of prompt get 90%+ accuracy. Teams that just say “extract all relevant information” get 60–70% accuracy and a lot of surprises.
Handling Ambiguity and Edge Cases
Long documents are full of ambiguity. A contract might mention “the Agreement” 50 times without repeating the date. A claims narrative might have conflicting statements. Your prompt needs to handle this.
Add a section to your user prompt:
If you encounter conflicting information:
- Note the most recent or authoritative statement.
- If you cannot determine which is authoritative, flag it as a conflict.
If information is ambiguous:
- Provide the most literal interpretation.
- Add a note explaining the ambiguity.
Example:
"termination_date": "2025-12-31",
"termination_date_note": "Document states 'one year from execution' and execution date is 2024-12-31. Assumed calendar year 2025."
This adds ~100 tokens to your prompt but saves hours of debugging later. It also surfaces data quality issues early, so you can decide whether to escalate to human review.
Structured Output and Format Specification
The Claude API documentation supports structured output via JSON schema. Use it. Don’t rely on the model to guess your output format.
Here’s why: without a schema, the model might return:
- Inconsistent field names (“counterparty” vs “counterparty_name”)
- Unexpected data types (a date as a string vs an ISO-8601 timestamp)
- Nested structures you didn’t anticipate
- Extra fields the model thinks are helpful
With a JSON schema, you get deterministic output that you can parse and validate without custom parsing logic. The schema also reduces token waste because the model doesn’t have to reason about format—it just fills the structure.
Here’s a minimal schema for the financial agreement task:
{
"type": "object",
"properties": {
"counterparty_name": {"type": "string"},
"agreement_date": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
"effective_date": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
"termination_date": {"type": ["string", "null"]},
"key_obligations": {"type": "array", "items": {"type": "string"}, "maxItems": 5},
"payment_terms": {"type": "string"},
"governing_law": {"type": "string"},
"amendments": {"type": ["array", "null"]}
},
"required": ["counterparty_name", "agreement_date", "effective_date", "payment_terms"]
}
This schema enforces data types, date format, and required fields. The model will follow it. If it can’t fill a required field, it will either extract a value or error—it won’t silently omit the field.
Output Validation and Reliability Patterns
Building a Validation Layer
Haiku 4.5 is accurate, but it’s not perfect. A 94% accuracy rate means 1 in 17 documents has an error. At scale, that’s significant. You need a validation layer.
Here’s a three-tier approach:
Tier 1: Schema validation. Parse the output against your JSON schema. If it doesn’t match, the extraction failed. Log it and retry with a clearer prompt.
Tier 2: Semantic validation. Check that extracted values make sense. Examples:
- Is the termination date after the agreement date?
- Are required fields present and non-empty?
- Do date formats match the pattern you specified?
- Are amounts in expected ranges (e.g., not $0 or $1 billion when the contract is for typical business terms)?
Tier 3: Spot-check validation. For a sample of extractions (5–10%), manually verify against the source document. This catches systematic errors that your automated checks miss.
Here’s pseudocode for a validation function:
def validate_extraction(extracted_data, source_document):
errors = []
# Tier 1: Schema
try:
parsed = json.loads(extracted_data)
except json.JSONDecodeError:
return {"valid": False, "errors": ["Invalid JSON"]}
# Tier 2: Semantic
if parsed.get("termination_date") and parsed.get("agreement_date"):
if parsed["termination_date"] < parsed["agreement_date"]:
errors.append("Termination date before agreement date")
if not parsed.get("counterparty_name"):
errors.append("Missing counterparty name")
# Tier 3: Spot-check (sample-based)
if random.random() < 0.1: # 10% sample
spot_check_result = human_review(parsed, source_document)
if not spot_check_result["passed"]:
errors.append(f"Spot-check failed: {spot_check_result['reason']}")
return {
"valid": len(errors) == 0,
"errors": errors,
"data": parsed if len(errors) == 0 else None
}
This approach catches ~95% of errors without manual review. The remaining 5% are caught by spot-checking.
Handling Extraction Failures
When validation fails, you have options:
- Retry with a refined prompt. If the schema is invalid, the prompt was unclear. Clarify it and retry.
- Escalate to human review. If semantic validation fails, the document might be unusual. Flag it for a human to check.
- Partial extraction. If some fields extracted correctly and others didn’t, accept the partial result and mark uncertain fields.
- Decompose the task. If a single prompt is failing consistently, split the extraction into multiple passes (first pass: dates, second pass: obligations, etc.).
For most teams, a mix of 1 and 2 works best. ~80% of failures are prompt-clarity issues. ~15% are genuinely ambiguous documents. ~5% are model errors.
Confidence Scoring
Haiku 4.5 doesn’t output confidence scores natively, but you can infer confidence by asking the model to explain its reasoning. Add this to your prompt:
For each field, provide:
1. The extracted value
2. A confidence level (high/medium/low)
3. A brief explanation of where the value came from
Example:
{
"counterparty_name": "Acme Corp",
"counterparty_name_confidence": "high",
"counterparty_name_source": "Stated in Section 1, paragraph 1",
...
}
This adds ~20% to your output tokens but gives you a signal for downstream processing. Low-confidence extractions can be flagged for human review automatically.
Cost Optimisation Strategies
Token Reduction Without Quality Loss
Long-context workflows can get expensive if you’re not careful. Here are proven strategies to cut costs without sacrificing accuracy:
1. Remove boilerplate before extraction. PDFs often contain headers, footers, table of contents, and legal disclaimers that don’t contain relevant information. Strip them out before sending to the model. This can reduce token count by 10–20% with zero accuracy loss.
2. Use text extraction, not image processing. If you’re extracting from PDFs, extract text first (using a library like PyPDF2 or pdfplumber). Don’t send the PDF as images to Claude. Image processing is slower and more expensive.
3. Chunk strategically, not naively. If a document is too long, don’t split it into equal chunks. Split it by semantic boundaries (sections, chapters, logical units). This preserves context and reduces the need for follow-up passes.
4. Batch similar documents. If you’re processing 100 contracts of the same type, use the same prompt for all. This lets you optimise the prompt once and reuse it. Different document types need different prompts; don’t try to force one prompt to handle everything.
5. Use cheaper models for pre-processing. Before sending a document to Haiku 4.5 for detailed extraction, use a cheaper model (or simple regex/rule-based logic) to classify the document, extract metadata, or filter out irrelevant sections. This reduces the amount of text Haiku 4.5 has to process.
A real example: a compliance team was processing 500 regulatory filings per month. Initial approach: send each filing to Haiku 4.5 for full extraction. Cost: ~$150/month. Optimised approach: (1) use rule-based logic to extract metadata (date, filing type, entity name), (2) send only the relevant sections (not boilerplate) to Haiku 4.5, (3) batch by filing type so one prompt covers 50+ documents. New cost: ~$35/month. Same accuracy, 75% cost reduction.
Batch Processing and Parallelisation
If you’re processing 1,000+ documents, parallelise. Don’t send them one at a time. The Claude API supports batch processing via AWS Bedrock or Google Vertex AI, both of which offer batch discounts (10% off) and higher throughput.
If you’re using the Claude API directly (via Anthropic’s platform), you can parallelise by sending multiple requests concurrently. Use a queue (e.g., AWS SQS, Redis, or a simple Python queue) to manage document flow and retry failed extractions.
Here’s a basic pattern:
import asyncio
from anthropic import Anthropic
async def extract_document(client, document_text, prompt):
response = await client.messages.create(
model="claude-3-5-haiku-20241022",
max_tokens=2000,
system=system_prompt,
messages=[
{"role": "user", "content": f"{prompt}\n\n{document_text}"}
]
)
return response.content[0].text
async def extract_batch(documents, prompt):
client = Anthropic()
tasks = [extract_document(client, doc, prompt) for doc in documents]
results = await asyncio.gather(*tasks)
return results
# Usage
documents = [...] # List of document texts
results = asyncio.run(extract_batch(documents, extraction_prompt))
This processes 10–20 documents in parallel, depending on your API rate limits. It’s 10–20x faster than sequential processing and often costs less per document because you’re batching.
Caching and Reuse
If you’re processing documents of the same type repeatedly, use prompt caching. The Claude API supports caching of the system prompt and the first 1,024 tokens of the user message. If you’re using the same system prompt and the same extraction template for 100 documents, the cache pays for itself after the first few requests.
Caching reduces input token cost by 90% for cached tokens. For a 50-page document with a 500-token system prompt and 200-token extraction template, you save ~630 tokens (the cached portion) × $0.80 / 1M = $0.0005 per document. Across 1,000 documents, that’s $0.50. Not huge, but it adds up.
Enable caching by setting the cache_control parameter in your API request (check the latest Claude API documentation for syntax).
Common Failure Modes and How to Avoid Them
The “Lost in the Middle” Problem
Research on how language models use long contexts shows that models often miss or underweight information in the middle of long documents. They tend to focus on the beginning and end.
This is a real problem. We’ve seen it happen: a 100-page contract with a critical amendment on page 50 gets missed by the model. The model extracts the original terms (from the beginning) and the boilerplate (from the end) but skips the middle.
How to avoid it:
- Put critical information first. If you’re extracting from a document you control, structure it so key information is at the top.
- Use a two-pass approach for very long documents. First pass: extract outline and key sections. Second pass: drill into sections that matter. This is more expensive but catches middle-of-document information.
- Ask the model to search for specific information. Instead of “extract all obligations,” ask “find all obligations related to insurance, reporting, and indemnification.” This focuses the model’s attention.
- Chunk by semantic boundaries. If the document is 100 pages, don’t send it all at once. Send sections (chapter 1, chapter 2, etc.) separately and merge results. This avoids the middle-of-document problem entirely.
For a financial services client processing 80-page regulatory filings, we switched from single-pass extraction to a two-pass approach. First pass: extract document structure and identify key sections. Second pass: extract details from each section. Accuracy improved from 92% to 97%, and token cost increased by only 15% (because the second pass is cheaper—it’s working with smaller, focused sections).
Hallucination and Fabricated Data
Haiku 4.5 is less prone to hallucination than larger models, but it still happens. The model might invent a date that sounds plausible, or infer an obligation that’s implied but not stated.
How to avoid it:
- Explicitly tell the model not to infer. Your system prompt should say: “Extract only information explicitly stated in the document. Do not infer, assume, or extrapolate.”
- Use null/“not found” liberally. If information isn’t in the document, the model should return null, not a guess. Make this clear in your prompt and in your schema.
- Ask for sources. For each extracted value, ask the model to cite where it came from. “Where in the document did you find this?” This makes hallucinations obvious—if the model can’t cite a source, it probably hallucinated.
- Validate against the source. In your validation layer, spot-check extractions against the original document. If the model claims a date is “2024-01-15,” verify that exact date appears in the document.
Example prompt language:
Do not:
- Infer information not explicitly stated
- Assume missing values
- Extrapolate from examples or patterns
- Fill gaps with plausible-sounding data
If information is not in the document, return null.
For each extracted value, cite the section or page where you found it.
Inconsistent or Contradictory Extractions
Long documents sometimes contain contradictions. A contract might state a termination date in Section 2 and a different date in Section 10. The model might extract one or the other, or it might average them (which is wrong).
How to avoid it:
- Ask the model to flag contradictions. In your prompt, tell the model to note any inconsistencies it finds. “If you find conflicting information, note all versions and indicate which is most authoritative.”
- Define authority rules. For contracts, later amendments override earlier terms. For regulations, newer versions supersede older ones. Tell the model these rules upfront.
- Use a conflict-resolution step. After extraction, check for contradictions in the output. If the model extracted two different values for the same field, flag it for human review or re-prompt the model with a conflict-resolution instruction.
Example:
If the document contains conflicting information:
1. Note all conflicting values
2. Identify which is most recent or authoritative
3. Use the authoritative value
4. Add a note explaining the conflict
Example output:
{
"termination_date": "2025-12-31",
"termination_date_note": "Section 2 states 2025-06-30; Section 10 amendment states 2025-12-31. Using amendment date per standard contract interpretation."
}
Token Limit Exceeded
Occasionally, a document is longer than expected and exceeds the 200K token limit. Or you’re batching multiple documents and hit the limit.
How to avoid it:
- Count tokens before extraction. Use the Claude API documentation to count tokens upfront. If a document will exceed 150K tokens, split it before sending.
- Implement a fallback. If a document is too long, fall back to chunking or a two-pass approach. Don’t just fail.
- Monitor token usage. Log tokens used per request. If you’re consistently hitting 80%+ of the context window, you’re at risk. Optimise your prompts or reduce document size.
Model Refusal or Unexpected Errors
Rarely, Haiku 4.5 will refuse to process a document (e.g., if it contains sensitive information the model’s safety guidelines flag) or return an error.
How to handle it:
- Catch API errors. Wrap your API calls in try-catch blocks. Log the error and retry with exponential backoff.
- Implement graceful degradation. If Haiku 4.5 fails, fall back to a different approach (human review, rule-based extraction, a different model).
- Monitor refusal rates. If a specific document type consistently triggers refusals, investigate. You might need to adjust your prompt or pre-process the document to remove sensitive data.
Integrating Haiku 4.5 into Production Systems
Architecture Patterns
When you’re building a production system around Haiku 4.5 for document analysis, architecture matters. Here are patterns that work:
Pattern 1: Synchronous extraction with validation. User uploads document → Extract with Haiku 4.5 → Validate → Return results. Best for: Small documents, interactive workflows, <10 second latency requirement. Limitation: Can’t process large batches efficiently.
Pattern 2: Asynchronous extraction with queue. User uploads document → Add to queue → Worker processes with Haiku 4.5 → Validate → Store results → Notify user. Best for: Large batches, non-interactive workflows, high throughput. Limitation: Requires queue infrastructure (SQS, Redis, RabbitMQ).
Pattern 3: Hybrid with caching. User uploads document → Check cache for similar documents → If hit, return cached result → If miss, extract with Haiku 4.5 → Cache result → Return. Best for: Repeated document types, cost-sensitive workloads. Limitation: Requires document similarity matching (hash, embedding, or rule-based).
For most teams, Pattern 2 is the sweet spot. It scales well, handles failures gracefully, and doesn’t require complex caching logic.
Here’s a basic architecture:
┌─────────────────┐
│ Document │
│ Upload │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Queue │ (SQS, Redis, etc.)
│ (pending) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Worker │ (Lambda, container, etc.)
│ (extraction) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Haiku 4.5 │ (Claude API)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Validation │ (schema, semantic, spot-check)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Storage │ (Database, S3, etc.)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Notification │ (Email, webhook, UI update)
└─────────────────┘
Each component is independent and can scale separately. The queue decouples upload from processing, so you can handle spikes without overloading the extraction service.
Error Handling and Retry Logic
Production systems fail. Your extraction pipeline needs to handle it gracefully.
Implement retry logic with exponential backoff:
import time
from functools import wraps
def retry_with_backoff(max_retries=3, base_delay=1):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
for attempt in range(max_retries):
try:
return func(*args, **kwargs)
except Exception as e:
if attempt == max_retries - 1:
raise
delay = base_delay * (2 ** attempt) # Exponential backoff
print(f"Attempt {attempt + 1} failed. Retrying in {delay}s...")
time.sleep(delay)
return wrapper
return decorator
@retry_with_backoff(max_retries=3, base_delay=1)
def extract_with_haiku(document_text, prompt):
# Call Claude API
...
For transient errors (rate limits, timeouts), retry automatically. For persistent errors (invalid input, API key issues), fail fast and alert.
Logging and Observability
Log everything:
- Document metadata (name, size, type)
- Tokens used (input, output, cached)
- Extraction results (raw output, validated output)
- Validation errors (if any)
- Latency (time to extract, time to validate)
- Cost (per document, aggregate)
Example logging structure:
import json
import logging
logger = logging.getLogger(__name__)
def extract_document(document_id, document_text, prompt):
start_time = time.time()
log_context = {
"document_id": document_id,
"document_size_tokens": count_tokens(document_text),
"prompt_tokens": count_tokens(prompt),
}
try:
response = client.messages.create(
model="claude-3-5-haiku-20241022",
max_tokens=2000,
messages=[{"role": "user", "content": f"{prompt}\n\n{document_text}"}]
)
log_context["input_tokens"] = response.usage.input_tokens
log_context["output_tokens"] = response.usage.output_tokens
log_context["cost"] = (
response.usage.input_tokens * 0.80 / 1_000_000 +
response.usage.output_tokens * 4.00 / 1_000_000
)
extracted = response.content[0].text
validation = validate_extraction(extracted)
log_context["validation_passed"] = validation["valid"]
log_context["validation_errors"] = validation.get("errors", [])
log_context["latency_ms"] = (time.time() - start_time) * 1000
logger.info("extraction_complete", extra=log_context)
return extracted
except Exception as e:
log_context["error"] = str(e)
log_context["latency_ms"] = (time.time() - start_time) * 1000
logger.error("extraction_failed", extra=log_context, exc_info=True)
raise
Store these logs in a structured format (JSON) so you can query and analyse them. Set up alerts for high error rates, high latency, or unexpected cost spikes.
Real-World Implementation Patterns
Financial Services: Contract Analysis
A wealth management firm needed to extract key terms from 500+ investment management agreements. They were doing this manually—6 hours per contract.
Challenge: Contracts ranged from 20 to 120 pages. Terms were buried in boilerplate. Some contracts had amendments that superseded original terms.
Solution:
- Pre-process PDFs to extract text and remove boilerplate (headers, footers, legal disclaimers).
- Use a two-pass approach: first pass extracts document structure and identifies key sections (fees, termination, governance). Second pass extracts detailed terms from each section.
- Structured output with confidence scores and source citations.
- Validation layer checks for logical inconsistencies (e.g., termination date before effective date).
Results:
- Time per contract: 6 hours → 8 minutes (45x faster)
- Cost per contract: ~$0.05
- Accuracy: 96% on first pass (4% required human review)
- ROI: Paid for itself in the first 50 contracts
For a deeper dive into financial services AI, see PADISO’s AI for Financial Services Sydney offering, which covers APRA, ASIC, and AUSTRAC compliance.
Insurance: Claims Processing
An insurance underwriting team processed 200+ claims per month. Each claim involved a narrative (written by the claimant), policy documents, and sometimes medical records or expert reports.
Challenge: Extracting relevant facts from unstructured narratives. Different claim types (auto, health, property) needed different extraction logic. Some claims had contradictory statements.
Solution:
- Classify claim type first (auto, health, property, etc.).
- Use type-specific extraction prompts.
- Extract facts, contradictions, and flags for manual review in a single pass.
- Structured output with confidence scores.
- Validation layer checks for internal consistency (e.g., injury date before claim date).
Results:
- Time per claim: 2 hours → 15 minutes (8x faster)
- Cost per claim: ~$0.03
- Accuracy: 94% on first pass
- Manual review rate: 6% (mostly high-complexity or contradictory claims)
- Downstream impact: Faster claim resolution, fewer denials due to missed facts
For insurance-specific AI solutions, explore AI for Insurance Sydney which covers claims automation, conduct risk, and underwriting.
Regulatory Compliance: Audit Readiness
A fintech company needed to audit their data practices against SOC 2 and ISO 27001 requirements. They had 1,000+ documents (policies, logs, access records, incident reports) to review.
Challenge: Manual audit would take weeks. They needed to map documents to specific control requirements and flag gaps.
Solution:
- Create a mapping of SOC 2/ISO 27001 controls to extraction queries.
- For each control, extract evidence from relevant documents using Haiku 4.5.
- Aggregate results to show which controls have evidence, which need remediation.
- Use PADISO’s Security Audit (SOC 2 / ISO 27001) framework to guide the process.
- Validation: manual spot-check of 10% of extractions.
Results:
- Time to audit-readiness: 6 weeks → 2 weeks
- Cost: ~$500 (Haiku 4.5 extraction) vs $50K+ (external audit firm)
- Outcome: Company passed SOC 2 Type II audit on first attempt
- Ongoing: Quarterly automated compliance checks
For a broader view of platform engineering and security architecture, see Platform Development in Sydney which covers SOC 2-ready architecture from the ground up.
Monitoring, Logging, and Observability
Key Metrics to Track
Once your extraction pipeline is in production, monitor these metrics:
Performance metrics:
- Latency: Time from document upload to extraction complete. Target: <5 seconds for small documents, <30 seconds for large.
- Throughput: Documents processed per hour. Helps you understand capacity and plan scaling.
- Queue depth: Number of documents waiting to be processed. If this grows, you need more workers.
Quality metrics:
- Validation pass rate: % of extractions that pass schema and semantic validation. Target: >95%.
- Spot-check accuracy: % of spot-checked extractions that match the source document. Target: >94%.
- Hallucination rate: % of extractions containing information not in the source. Track via spot-checks.
Cost metrics:
- Cost per document: Input tokens × $0.80/M + output tokens × $4.00/M. Track this to understand where your money goes.
- Cost per successful extraction: If 5% of extractions fail and need retry, your effective cost is higher.
- Monthly spend: Sum across all documents. Set a budget and alert if you exceed it.
Operational metrics:
- Error rate: % of extractions that fail (API errors, validation errors, etc.). Target: <1%.
- Retry rate: % of extractions that required a retry. If >10%, your prompts need refinement.
- Manual review rate: % of extractions flagged for human review. This is normal (5–10%) but track it.
Set up dashboards in your monitoring tool (Datadog, New Relic, CloudWatch, etc.) to visualise these metrics. Set alerts for anomalies:
- Validation pass rate drops below 90%
- Error rate exceeds 5%
- Latency exceeds 60 seconds
- Monthly cost exceeds budget by 20%
Debugging Failed Extractions
When an extraction fails, you need to understand why. Build a debugging workflow:
- Check the validation error. Is it a schema error (malformed JSON), a semantic error (date before agreement date), or a spot-check failure?
- Review the raw extraction output. What did the model actually return? Is it close to correct (minor tweaks needed) or completely off?
- Check the input. Is the document text complete? Did the PDF extraction work correctly? Is the prompt clear?
- Re-run with a refined prompt. If the model misunderstood the task, clarify the prompt and retry.
- Escalate to human review. If the document is genuinely ambiguous or the model can’t handle it, flag it for a human.
Log all of this in a structured format so you can analyse failure patterns. If 10% of extractions fail on a specific document type, you need a type-specific prompt or a different approach.
Continuous Improvement
As you process more documents, you’ll discover patterns:
- Certain document types are consistently hard to extract from
- Specific fields are more error-prone than others
- Certain prompts work better than others
Use this data to improve:
- A/B test prompts. Try two versions of a prompt on a sample of documents. Measure accuracy and cost. Use the winner.
- Create type-specific prompts. If contracts are easier to extract than claims narratives, build a contract-specific prompt.
- Refine validation rules. If a semantic validation rule catches a lot of false positives, adjust it. If it misses errors, tighten it.
- Expand spot-checking. If you find a new error pattern, increase spot-checking for that document type until you understand it.
Next Steps and When to Escalate
Building Your Extraction Pipeline
If you’re considering Haiku 4.5 for document analysis, here’s a roadmap:
Phase 1: Proof of concept (1–2 weeks)
- Pick one document type (contracts, claims, filings, etc.)
- Extract 10–20 documents manually with Haiku 4.5
- Measure accuracy and cost
- Decide: proceed or pivot?
Phase 2: MVP (2–4 weeks)
- Build a basic extraction pipeline (upload → extract → validate)
- Implement schema validation and semantic checks
- Run on 100–200 documents
- Measure end-to-end accuracy and latency
- Refine prompts based on failures
Phase 3: Production (4–8 weeks)
- Scale to full document volume
- Implement queue-based processing for throughput
- Add logging, monitoring, and alerting
- Set up spot-checking and human review workflows
- Optimise costs and latency
Phase 4: Optimisation (ongoing)
- Monitor metrics and refine prompts
- A/B test new prompt versions
- Expand to new document types
- Integrate with downstream systems
When to Use Haiku 4.5 vs. Larger Models
Use Haiku 4.5 when:
- Documents are <150K tokens (roughly <50 pages)
- You need fast turnaround and cost efficiency
- You can build a validation layer to catch errors
- You’re processing high volumes (100+ documents/month)
- You have well-structured documents (contracts, filings, claims)
Use a larger model (Claude 3.5 Sonnet or Opus) when:
- Documents are >150K tokens and chunking isn’t feasible
- You need reasoning on complex, ambiguous information
- You can’t afford validation overhead (need first-pass accuracy >98%)
- You’re processing low volumes (10 documents/month) where cost matters less
- You’re dealing with highly unstructured or domain-specific content
When to Escalate to PADISO
If you’re building a production document analysis system and need help, PADISO can assist. We’ve shipped 50+ extraction pipelines and can help with:
- AI Strategy & Readiness: Assessing whether Haiku 4.5 is right for your use case. See our AI Advisory Services for strategy and architecture guidance.
- Architecture & Design: Building scalable, cost-effective extraction pipelines. Explore Platform Design & Engineering for production-grade systems.
- Compliance & Security: If you’re processing sensitive data (financial records, medical information, regulatory filings), we can help you build SOC 2 and ISO 27001-ready systems. Check out our Security Audit services.
- Industry-Specific Expertise: If you’re in financial services, insurance, or healthcare, we have deep domain knowledge. See AI for Financial Services Sydney and AI for Insurance Sydney.
We work with founders and operators at seed-to-Series-B startups, mid-market companies modernising with AI, and enterprise teams pursuing compliance. If you’re shipping a document analysis system and want to move faster or de-risk the build, book a 30-min call with our team.
Resources and Further Reading
As you build, lean on these resources:
- Claude API documentation covers models, context windows, and API parameters.
- Anthropic’s Claude 3 family announcement provides context on model capabilities.
- AWS Bedrock documentation covers deployment options and parameters.
- Google Vertex AI documentation for cloud-native integration.
- InfoQ’s article on long-context LLMs discusses context windows and RAG tradeoffs.
- OpenAI’s prompt engineering guide covers general principles that apply across models.
- DeepLearning.AI’s coverage of long-context models discusses practical patterns and limitations.
For case studies and real-world examples, check out PADISO’s case studies showing how teams have shipped AI systems across industries.
Summary
Haiku 4.5 is a powerful tool for long-context document analysis. It’s fast, cost-effective, and accurate enough for production use—but only if you engineer it properly.
The patterns in this guide—prompt design, output validation, cost optimisation, and failure-mode handling—are the difference between a prototype that works once and a system that ships reliably at scale.
Start with a proof of concept. Pick one document type, extract 20 documents, measure accuracy and cost. If it works, build an MVP with validation and monitoring. Scale from there.
If you hit complexity—regulatory compliance, high accuracy requirements, complex document types—escalate to experts. PADISO’s team has shipped extraction systems for financial services, insurance, healthcare, and regulatory compliance. We can help you move faster and de-risk the build.
The future of document processing is automated. Haiku 4.5 makes it economically viable. Use it.