Structured-Extraction Pipeline
A recipe over the shared block palette that takes a continuous stream of mixed business documents and
turns them into validated structured data, then into action — per-entity operational routing,
portfolio-level business insights, or both.
The shape: one spine, two heads
Spine (always): ingest → classify document type → extract type-specific fields → validate on confidence
(low-confidence → human review) → assemble into one record per entity.
Then pick the head(s) — independent, can coexist:
- Operational head — a per-entity decision (risk / action / derived amount) → triage lanes (auto /
review / reject). Acts on each entity now. (claims intake, KYC.)
- Analytical head — roll the validated records up into QoQ metrics, trends, anomalies, then an insights
& recommended-actions synthesis. Steers the portfolio over time. (AP/spend analytics.)
When to use
- A stage receives a mix of document types that must be classified and extracted by different schemas.
- Several documents belong to one record and must be reassembled (one row per claim / case / vendor invoice).
- You want to act on each entity (auto / review / reject) and/or turn the document stream into a reporting
dataset (metrics, trends, anomalies, recommended actions). Off-target documents must be gated out.
Do NOT use for: a single document type → ../invoice-processing/SKILL.md
or the base; thematic/semantic understanding (themes, clustering, RAG) →
../corpus-intelligence/SKILL.md; one-off extraction → a one-shot AI_EXTRACT.
Read first
The orchestration scaffold is shared — ../conventions.md. Load it, plus the palette router
../../blocks/README.md and contract ../../blocks/conventions.md.
This file supplies the recipe, defaults, the two-grain refresh note, and smoke checks.
Recipe — blocks to compose
Spine: ingest/ingestion → ingest/parse-text
(filter to text formats; derive <entity_key>) → extract/classify
(multi-class router) → one extract/fields (routed extractor, scored) per
text type + extract/vision-structured per image type →
records/entity (assemble per <entity_key>).
Operational head: records/reason (cross-document decision) →
records/triage (lanes).
Analytical head: analyze/metrics-trend →
analyze/synthesize (insights & actions). Derive a grouping dimension with
extract/classify (category-derive) if your raw dimension is near-unique.
Tail: serve/final-shape.
Intake topics (raise only what the prompt left open)
| Topic |
Default if unspecified |
Block |
| Document types & off-target gating |
classify into named types + other; other is gated out |
classify (router) |
| Image/visual types present |
none (text-only); if present, assess with a vision model |
vision-structured |
| One record per entity? |
yes if types share a key — assemble; else per-document output |
entity |
| Per-field confidence → review flag |
on — scores => TRUE; low MIN_KEY_CONF routes to review (cutoff ≈ 0.6, calibrate) |
fields + triage |
| Which head(s)? |
infer from the goal — per-record decision/route → operational; reporting/metrics → analytical |
(selects the head blocks) |
| Operational: decision + lanes |
3 lanes (auto / review / reject), conservative thresholds |
reason + triage |
| Analytical: metrics + insights |
off; needs a measure + dimension + (ideally) a date |
metrics-trend + synthesize |
| Final freshness (target lag) |
operational: 5 min; analytical insights: a slow lag |
base Step 7 |
Refresh expectation (two grains)
The spine and operational head are per-entity INCREMENTAL. The analytical head shifts grain: both the
metrics DT and the insights DT are FULL by necessity but cheap (they aggregate records, never re-read
documents). The metrics rollup must be a DT, not a bare view (the insights DT reads it; a DT can't read a
view that wraps a DT). In base Step 6, verify spine/operational DTs are INCREMENTAL and expect the metrics
and insights DTs to be FULL — those are not defects. Watch the router UNION ALL and the entity-assembly
multi-LEFT JOIN stay INCREMENTAL.
Smoke checks (after the base Step 8 test)
- Classification distribution is plausible and off-target files landed in
other.
- Assembly: entity count and
HAS_* flags match the expected mix; core identifying fields are populated.
- Operational head:
ROUTE distribution is sane; the auto-lane contains no obviously-bad records.
- Analytical head: the metrics view returns sane
period × dimension rows; the insights DT returns a
non-empty set, each with a recommended action.
Examples
examples/claims-intake.md — spine + operational head (router → per-type extractors + vision → assembly → decision → lanes).
examples/ap-spend.md — analytical head on a single type (extract → derive category → metrics rollup → insights).
1---2name: structured-extraction-pipeline3description: "Build a persistent, Snowflake-native pipeline that turns a stream of mixed business documents into validated structured data and then into action: classify each document type, extract type-specific fields, validate with confidence scores (low-confidence routes to human review), reassemble multiple documents into one record per entity, then either route each entity to action lanes (operational) and/or roll the records up into QoQ metrics, trends, anomalies and recommended actions (analytical). Use for POs, contracts, receipts, claims, applications, KYC/loan packets — anywhere documents of several types must be sorted, extracted, validated, and turned into decisions or business insights. Triggers: document intelligence pipeline, classify then extract, multi-type document pipeline, document routing/triage by type, claims intake, AP/spend analytics from documents, invoice/PO/contract analytics, QoQ metrics from documents, trends and anomalies, recommended actions from documents, per-claim/per-case assembly, structured extraction pipeline."4parent_skill: ai-functions-pipeline-builder5metadata:6 source: https://skillmd.com/skills/s-14-h/structured-extraction-pipeline7---89# Structured-Extraction Pipeline1011A **recipe** over the shared block palette that takes a continuous stream of **mixed business documents** and12turns them into **validated structured data**, then into **action** — per-entity operational routing,13portfolio-level business insights, or both.1415## The shape: one spine, two heads1617**Spine (always):** ingest → classify document type → extract type-specific fields → validate on confidence18(low-confidence → human review) → assemble into one record per **entity**.1920Then pick the head(s) — independent, can coexist:2122- **Operational head** — a per-entity **decision** (risk / action / derived amount) → **triage lanes** (auto /23 review / reject). Acts on each entity *now*. *(claims intake, KYC.)*24- **Analytical head** — roll the validated records up into **QoQ metrics, trends, anomalies**, then an **insights25 & recommended-actions** synthesis. Steers the *portfolio* over time. *(AP/spend analytics.)*2627## When to use2829- A stage receives a **mix of document types** that must be classified and extracted by different schemas.30- Several documents **belong to one record** and must be reassembled (one row per claim / case / vendor invoice).31- You want to **act on each entity** (auto / review / reject) and/or **turn the document stream into a reporting32 dataset** (metrics, trends, anomalies, recommended actions). Off-target documents must be gated out.3334**Do NOT use for:** a single document type → [`../invoice-processing/SKILL.md`](../invoice-processing/SKILL.md)35or the base; thematic/semantic understanding (themes, clustering, RAG) →36[`../corpus-intelligence/SKILL.md`](../corpus-intelligence/SKILL.md); one-off extraction → a one-shot `AI_EXTRACT`.3738## Read first3940The orchestration scaffold is shared — [`../conventions.md`](../conventions.md). Load it, plus the palette router41[`../../blocks/README.md`](../../blocks/README.md) and contract [`../../blocks/conventions.md`](../../blocks/conventions.md).42This file supplies the recipe, defaults, the two-grain refresh note, and smoke checks.4344## Recipe — blocks to compose4546**Spine:** [`ingest/ingestion`](../../blocks/ingest/ingestion.md) → [`ingest/parse-text`](../../blocks/ingest/parse-text.md)47(filter to text formats; derive `<entity_key>`) → [`extract/classify`](../../blocks/extract/classify.md)48(multi-class router) → one [`extract/fields`](../../blocks/extract/fields.md) (routed extractor, scored) **per49text type** + [`extract/vision-structured`](../../blocks/extract/vision-structured.md) per image type →50[`records/entity`](../../blocks/records/entity.md) (assemble per `<entity_key>`).5152**Operational head:** [`records/reason`](../../blocks/records/reason.md) (cross-document decision) →53[`records/triage`](../../blocks/records/triage.md) (lanes).5455**Analytical head:** [`analyze/metrics-trend`](../../blocks/analyze/metrics-trend.md) →56[`analyze/synthesize`](../../blocks/analyze/synthesize.md) (insights & actions). Derive a grouping dimension with57`extract/classify` (category-derive) if your raw dimension is near-unique.5859**Tail:** [`serve/final-shape`](../../blocks/serve/final-shape.md).6061## Intake topics (raise only what the prompt left open)6263| Topic | Default if unspecified | Block |64|-------|------------------------|-------|65| Document types & off-target gating | classify into named types + `other`; `other` is gated out | classify (router) |66| Image/visual types present | none (text-only); if present, assess with a vision model | vision-structured |67| One record per entity? | **yes** if types share a key — assemble; else per-document output | entity |68| Per-field confidence → review flag | **on** — `scores => TRUE`; low `MIN_KEY_CONF` routes to review (cutoff ≈ 0.6, calibrate) | fields + triage |69| **Which head(s)?** | infer from the goal — per-record decision/route → operational; reporting/metrics → analytical | (selects the head blocks) |70| Operational: decision + lanes | **3 lanes** (auto / review / reject), conservative thresholds | reason + triage |71| Analytical: metrics + insights | off; needs a **measure + dimension + (ideally) a date** | metrics-trend + synthesize |72| Final freshness (target lag) | operational: 5 min; analytical insights: a slow lag | base Step 7 |7374## Refresh expectation (two grains)7576The **spine and operational head are per-entity `INCREMENTAL`**. The **analytical head shifts grain**: both the77metrics DT and the insights DT are **`FULL` by necessity but cheap** (they aggregate records, never re-read78documents). The metrics rollup **must be a DT, not a bare view** (the insights DT reads it; a DT can't read a79view that wraps a DT). In base Step 6, verify spine/operational DTs are `INCREMENTAL` and **expect the metrics80and insights DTs to be `FULL`** — those are not defects. Watch the router `UNION ALL` and the entity-assembly81multi-`LEFT JOIN` stay `INCREMENTAL`.8283## Smoke checks (after the base Step 8 test)8485- **Classification** distribution is plausible and off-target files landed in `other`.86- **Assembly**: entity count and `HAS_*` flags match the expected mix; core identifying fields are populated.87- **Operational head**: `ROUTE` distribution is sane; the auto-lane contains no obviously-bad records.88- **Analytical head**: the metrics view returns sane `period × dimension` rows; the insights DT returns a89 non-empty set, each with a recommended action.9091## Examples9293- [`examples/claims-intake.md`](examples/claims-intake.md) — spine + **operational head** (router → per-type extractors + vision → assembly → decision → lanes).94- [`examples/ap-spend.md`](examples/ap-spend.md) — **analytical head** on a single type (extract → derive category → metrics rollup → insights).