agentleFS
aws-solutions-library-samplesaws-solutions-library-samples/accelerated-intelligent-document-processing-on-aws/.claude/skills/extraction-pipeline/SKILL.md

extraction-pipeline

Skill329 starsChanged 7 days agoMIT-0View on GitHub

Use when changing the document processing pipeline, its configuration, or agentic extraction and table parsing.

The file

Files
SKILL.md

Extraction Pipeline — Core Domain Logic — GenAI IDP Accelerator

Processing Flow

Documents → S3 Input Bucket → EventBridge → Queue Sender Lambda
→ SQS → Queue Processor Lambda → Step Functions
→ [OCR → Classification → Extraction → Assessment → Rule Validation → Summarization]
→ S3 Output Bucket

Two Processing Modes

Controlled by use_bda flag in configuration:

Pipeline Mode (use_bda: false) — Default

  1. OCR: Amazon Textract (or Bedrock OCR backend)
  2. Classification: Bedrock LLM — classification.strategy is combined (one call returns boundaries and classes) or split_then_classify (boundaries first, then one classification call per section); the granularity, page or packet, is classification.combined.granularity under combined and classification.split_then_classify.splitting.llm.granularity under split_then_classify; modality.text / modality.images decide what each call is sent
  3. Extraction: Bedrock LLM — traditional or agentic mode
  4. Assessment: LLM-powered confidence assessment with multimodal analysis
  5. Rule Validation: Custom business rules (criteria validation)
  6. Summarization: Document summarization

BDA Mode (use_bda: true)

  • End-to-end processing with Bedrock Data Automation (BDA)
  • Handles packet or media documents
  • Integrated OCR, classification, and extraction
  • Then → Rule Validation → Summarization

Agentic Extraction with Table Parsing

For documents with large tables (100+ rows), bank statements, transaction logs:

extraction:
  mode: advanced                   # selects the agentic path; agentic.enabled is derived from it
  model: "us.anthropic.claude-sonnet-5"
  agentic:
    table_parsing:
      enabled: true
      max_empty_line_gap: 3          # Standard quality (0-10)
      auto_merge_adjacent_tables: true
      min_confidence_threshold: 95.0
      min_parse_success_rate: 0.90
  • extraction.mode is authoritative and overwrites agentic.enabled whenever it is set, so agentic.enabled: true alone stays on the traditional path once the config is merged with a mode
  • Strands agent framework for tool-based structured output
  • Deterministic Markdown table parser for robust tabular data
  • Intelligent lookahead recovery for OCR artifacts
  • Auto-merge table fragments split by page breaks
  • See lib/idp_common_pkg/idp_common/extraction/README.md for details

Configuration System

Hierarchy

  1. System defaults (idp_common/config/system_defaults/*.yaml)
  2. Configuration presets (config_library/unified/<preset>/config.yaml)
  3. Custom overrides (via CustomConfigPath parameter or CLI)
  4. Stored in DynamoDB Configuration Table (gzip-compressed for large configs)

Config Structure (YAML)

use_bda: false
notes: "Description of this configuration"

classes:
  - $schema: https://json-schema.org/draft/2020-12/schema
    $id: DocumentType
    type: object
    x-aws-idp-document-type: DocumentType     # Custom extension
    description: >-
      Description of the document class
    properties:
      FieldName:
        type: string
        description: "Field description"
        x-aws-idp-evaluation-method: EXACT    # see the method list below

Custom JSON Schema Extensions

  • x-aws-idp-document-type — Document class identifier
  • x-aws-idp-evaluation-method — Evaluation metric type
  • x-aws-idp-evaluation-method-config — Per-comparator options (e.g. DateComparator's dayfirst, NUMERIC_EXACT's tolerance)
  • x-aws-idp-examples — Few-shot example references. ⚠️ This is the declared spelling (X_AWS_IDP_EXAMPLES in idp_common/config/schema_constants.py). A misspelled x-aws-idp-* extension is accepted, stored, never read and never reported, so a typo here fails silently — no gate catches it.

Evaluation methods

The settable values of x-aws-idp-evaluation-method, from METHOD_TO_COMPARATOR in idp_common/evaluation/stickler_backend/mapper.py (the authority — re-read it rather than trusting this list):

MethodComparator
EXACTExactComparator
NUMERIC_EXACTNumericComparator
FUZZYFuzzyComparator
LEVENSHTEINLevenshteinComparator
SEMANTICSemanticComparator
DATEDateComparator
LLMIDPLLMComparator (Bedrock-backed)
HUNGARIANnone — built in for arrays

Configuration presets

Located in config_library/unified/, one directory per preset, the directory name being the Configuration Preset stack parameter value. lending-package-sample is the default. Enumerate the rest with ls config_library/unified/ — they are added and renamed often enough that a list here goes stale.

Presets are not keyed by processing mode: use_bda resolves to false for every one of them, and each preset's notes says to set use_bda: true for BDA mode.

Key Models and Types (idp_common.models)

from idp_common.models import Document, Page, Section, Status

class Status(str, Enum):
    QUEUED = "QUEUED"
    IN_PROGRESS = "IN_PROGRESS"
    COMPLETE = "COMPLETE"
    FAILED = "FAILED"
    ...

class Document(BaseModel):
    id: str
    input_bucket: str
    input_key: str
    status: Status
    pages: list[Page]
    sections: list[Section]
    ...

Concurrency Management

  • DynamoDB atomic counter for workflow concurrency
  • MaxConcurrent parameter limits Step Functions executions
  • Queue Processor manages back-pressure via SQS visibility timeout

Human-in-the-Loop (HITL)

Built-in review system for human validation:

  • Documents flagged by assessment module
  • Review UI in the web interface
  • Status transitions: IN_PROGRESS → REVIEW → APPROVED/REJECTED

Evaluation Framework

  • Baseline data in S3 Evaluation Baseline bucket
  • stickler-eval library for accuracy metrics
  • Per-field evaluation methods: EXACT, NUMERIC_EXACT, FUZZY
  • Configuration versioning for A/B testing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.