Lesson 353·M28 AI System Design
AI Document Processing System
OpenLearning Objectives
By the end of this lesson you should be able to:
- Explain the clarify: the document's requirements (L353)
- Explain the pipeline: the parse, the classify, the extract (L353)
- Explain the extraction: the structured output (L143)
- Explain the verification: the rules and the human (L353)
- Explain the AI shape: the document's scale (L353)
One-Line Definition
The AI document processing system is the protocol run on a document product (L353) — the clarify (the users L162, the documents L177, the volume L353, the accuracy L353, L353), the pipeline (the parse L177, the classify L353, the extract L143, the verify L353, L353), the extraction (the structured output L143: the JSON schema L143, the fields L353, L353), and the verification (the rules L353 and the human L208: the low-confidence L139 reviewed, L353) — the documents (L177), processed at the scale (L353).
The one-sentence interview answer: "The document processing system is the protocol, run (L353). The clarify (L353): the users (L162), the documents (L177) — the types (L353): the invoices, the contracts, the forms (L353); the volume (L353); and the accuracy (L353) — the error's cost (L353). The pipeline (L353): the parse (L177) — the PDF (L177) → the text (L353); the classify (L353) — the document's (L353) type (L353); the extract (L143) — the structured output (L143): the JSON (L143) with the fields (L353) — the invoice's (L353) amounts (L353) and dates (L353); and the verify (L353) — the rules (L353): the totals (L353) and the cross-checks (L353). The queue (L270): the batch (L282) processing (L353) — the workers (L266) at the scale (L353). The verification (L353): the rules (L353) first (L353); the low-confidence (L139) — the human (L208) review (L353) — the L208 workflow (L208). The AI shape (L173): the documents (L177) — the pipeline (L353): the parse (L177), the classify (L353), the extract (L143), and the verify (L353) — the batch (L282) at the scale (L353)."
Mental Model
Think of the document system as the mailroom's processing line. The line (the pipeline, L353) processes the mail (the documents, L177): the opening (the parse, L177) — the envelope (the PDF, L177) → the letter (the text, L353); the sorting (the classify, L353) — the invoice (L353), the contract (L353), the form (L353); the transcribing (the extract, L143) — the letter's (L353) fields (L353) into the ledger (the JSON, L143); and the checking (the verify, L353) — the totals (L353) and the cross-checks (L353). The conveyor (the queue, L270) carries the batches (L353); the supervisor (the human, L208) reviews the unclear (L139) ones (L353). The mailroom works because the line is staged, the conveyor is fast, and the supervisor checks the unclear (L353).
the mailroom line (the document system, L353)
┌────────────────────────────────────────────────────────┐
│ the opening (the parse, L177) · the sorting (the │
│ classify, L353) · the transcribing (the extract, L143) │
│ the checking (the verify, L353) · the conveyor (the │
│ queue, L270) · the supervisor (the human, L208) │
└────────────────────────────────────────────────────────┘
The mental model is the mailroom line: the stages and the supervisor (L353).
Visual Flow — One Document's Path
the document (L177)
│ the S3 (L265) event (L276)
▼
┌────────────────────── THE PIPELINE (L353) ─────────────────────────┐
│ 1 · the parse (L177): the PDF → the text (L353) │
│ 2 · the classify (L353): the invoice, the contract (L353) │
│ 3 · the extract (L143): the JSON fields (L353) │
│ 4 · the verify (L353): the rules (L353) — the totals (L353) │
└──────────────────────────┬───────────────────────────────────────┘
▼
┌────────────────────── THE VERIFICATION (L353) ─────────────────────┐
│ the rules pass (L353) → the result (L353) │
│ the low-confidence (L139) → the human (L208) review (L353) │
└──────────────────────────────────────────────────────────────────┘
The flow is the document: parse → classify → extract → verify (L353).
How It Works — The Design, Part by Part
- The clarify (L353). The users (L162), the documents (L177), the volume (L353), the accuracy (L353).
- The pipeline (L353). The parse (L177), the classify (L353), the extract (L143), the verify (L353) — the queue (L270) and the workers (L266).
- The extraction (L143). The structured output (L143): the JSON schema (L143) with the fields (L353).
- The verification (L353). The rules (L353) and the human (L208): the low-confidence (L139) reviewed (L353).
Note
The verify is the accuracy's gate (L353). The senior answer separates the verify (L353): the rules (L353) — the deterministic checks (L353): the totals (L353), the cross-fields (L353), the formats (L353) — cheap and instant (L353); and the human (L208) — the low-confidence (L139) and the rule-failing (L353) documents (L353) — the L208 workflow (L208) with the full context (L353). The verify (L353) is the accuracy's (L353) gate (L353).
Real Project Usage
- A document SaaS (L357). The pipeline (L353) — the parse (L177), the extract (L143), the verify (L353).
- An invoice processor (L353). The fields (L353) — the amounts (L353) and the dates (L353) — the rules (L353) verifying (L353).
- A contract review (L353). The classify (L353) — the clauses (L353) — the extract (L143).
- A forms processor (L353). The batch (L282) — the queue (L270) at the scale (L353).
- Anything documents (L177). The pipeline (L353) — the stages (L353) and the verify (L353).
The through-line: the pipeline is the document's — the parse, the extract, and the verify (L353).
Interview Explanation
Say it in four moves:
- The clarify. "The documents, the volume, the accuracy (L353)."
- The pipeline. "The parse (L177), the classify (L353), the extract (L143)."
- The extraction. "The JSON schema (L143) with the fields (L353)."
- The verify. "The rules (L353) and the human (L208)."
Senior-Level Insights
- The stages are the pipeline's (L353). The parse (L177), the classify (L353), the extract (L143), and the verify (L353) — each a stage (L353) in the queue (L270).
- The schema is the extract's contract (L143). The JSON schema (L143) — the fields (L353) — the structured output (L143) validated (L353).
- The rules are the cheap verify (L353). The totals (L353) and the cross-checks (L353) — the deterministic (L353) — before the human (L208).
- The human is the accuracy's (L208). The low-confidence (L139) — the L208 review (L208) — the error's cost (L353) bounded (L353).
- The eval is the pipeline's quality (L341). The extraction's accuracy (L353) — the golden documents (L342) — the L341 suite (L341) (L353).
Common Mistakes
- The OCR-only (L353). The parse (L177) as the whole (L353) — the classify (L353) and the extract (L143) are the value (L353).
- The free-text extraction (L143). The unstructured output (L143) — the JSON schema (L143) is the contract (L353).
- The un-verified results (L353). The extraction (L143) without the verify (L353) — the errors (L353) ship (L353).
- The everything-to-the-human (L208). The full review (L208) — the cost (L334) — the rules (L353) first (L353).
- The eval-less pipeline (L341). The accuracy (L353) un-measured (L341) — the golden documents (L342) (L353).
Best Practices
- Stage the pipeline (L353) — the parse (L177), the classify (L353), the extract (L143), the verify (L353).
- Schema the extraction (L143) — the JSON (L143) with the fields (L353).
- Rule the verify (L353) — the totals (L353) and the cross-checks (L353).
- Human the low-confidence (L208) — the L208 review (L208).
- Eval the accuracy (L341) — the golden documents (L342).
Interview Questions
Q: Walk me through the document processing system.
A: The protocol, run (L353). The clarify — the documents, the volume, the accuracy (L353). The pipeline — the parse (L177), the classify (L353), the extract (L143). The extraction — the JSON schema (L143) with the fields (L353). And the verify — the rules (L353) and the human (L208).
Q: How do you design the extraction?
A: The structured output (L143): the JSON schema (L143) — the document's (L353) fields (L353): the invoice's (L353) amounts (L353), the dates (L353), the vendor (L353) — the model (L278) generates the JSON (L143), validated (L143) against the schema (L353).
Q: How do you verify the accuracy?
A: Two layers (L353): the rules (L353) — the deterministic checks (L353): the totals (L353) match, the cross-fields (L353) agree, the formats (L353) validate (L353) — cheap and instant (L353); and the human (L208) — the low-confidence (L139) and the rule-failing (L353) documents (L353) reviewed (L353) — the L208 workflow (L208).
Q: How does it scale?
A: The batch (L282): the documents (L177) land in the S3 (L265) — the events (L276) enqueue (L270) — the workers (L266) process (L353) the pipeline (L353) — the parse (L177), the extract (L143), the verify (L353) — the queue (L270) absorbing the spikes (L353).
Follow-Up Questions
- What's the clarify (L353)?
- How do you design the extraction (L143)?
- How do you verify the accuracy (L353)?
- How does it scale (L282)?
- What's the eval (L341)?
Comparison Table — The Pipeline's Stages
| Stage (L353) | The work (L353) | The output (L353) |
|---|---|---|
| The parse (L177) | the PDF → the text (L353) | the text (L353) |
| The classify (L353) | the type (L353) | the label (L353) |
| The extract (L143) | the fields (L353) | the JSON (L143) |
| The verify (L353) | the rules, the human (L208) | the validated (L353) |
The senior read: each stage is a step in the queue (L353).
Code Example — The Pipeline, Applied
// The document pipeline (L353) — the staged processing (L353).
// 1 · THE STAGES (L353) — the queue-fed steps (L353).
async function processDocument(doc) {
// 1 · THE PARSE (L177): the PDF → the text (L353).
const text = await parsePdf(doc.bytes); // L177
// 2 · THE CLASSIFY (L353): the type (L353).
const type = await classify(text); // L353
// 3 · THE EXTRACT (L143): the JSON schema (L143).
const schema = INVOICE_SCHEMA; // the fields (L353)
const extracted = await model.generate({ // L278
schema, // the structured output (L143)
text,
});
const validated = validateSchema(extracted, schema); // L143
// 4 · THE VERIFY (L353): the rules first (L353).
const rules = checkRules(extracted); // the totals (L353)
// 5 · THE HUMAN (L208): the low-confidence (L139).
if (!rules.pass || validated.confidence < 0.8) {
return humanReview(doc, extracted); // the L208 review (L208)
}
return { type, extracted, status: 'verified' }; // L353
}
// 2 · THE QUEUE (L270): the S3 (L265) event (L276) → the worker (L266).
What the reader must SEE — the pipeline, applied:
parsePdf → text → the parse (L177)
classify(text) → the type (L353)
model.generate + schema → the extraction (L143)
checkRules + confidence → the verify (L353)
humanReview on the low → the human (L208, L139)
The staged pipeline, the rule verify, the human review (L353).
Tip
The pair that defines the design: the JSON schema (the extraction's contract, L143) and the rule-based verify (the accuracy's gate, L353). Stage the pipeline, schema the output, rule the verify, human the low — the document's scale (L353).
Performance Notes
- The queue is the scale (L270). The workers (L266) — the batch (L282) throughput (L353).
- The schema is the latency's cost (L143). The structured generation (L143) — the tokens (L332) per document (L353).
- The rules are the zero-cost verify (L353). The deterministic checks (L353) — the instant (L353) before the model (L278) or the human (L208).
- The human is the accuracy's cost (L208). The review (L208) — the L208 workflow (L208) — the error's cost (L353) bounded (L353).
Debugging Scenarios
| Symptom | First check (L353) | The lever |
|---|---|---|
| The fields are wrong | The extraction (L143) | The schema (L143), the model (L148) |
| The errors ship | The verify (L353) | The rules (L353), the human (L208) |
| The batch lags | The queue (L270) | The workers (L266) |
| The human reviews too much | The confidence (L139) | The rules (L353), the model (L148) |
| The accuracy drifts | The evals (L341) | The golden documents (L342) |
Quick Revision Notes
- The document processing system = the document's design (L353): the clarify, the pipeline, the extraction, the verification.
- The clarify: the documents (L177), the volume (L353), the accuracy (L353).
- The pipeline: the parse (L177), the classify (L353), the extract (L143), the verify (L353).
- The extraction: the JSON schema (L143) with the fields (L353).
- The verification: the rules (L353) and the human (L208).
Cheat Sheet
AI DOCUMENT PROCESSING = the parse, the classify, the extract, the verify
THE CLARIFY (L353)
the users (L162) · the documents (L177) — the invoices,
the contracts, the forms (L353)
the volume (L353) · the accuracy (L353) — the error's cost (L353)
THE PIPELINE (L353)
1 the parse (L177) — the PDF → the text (L353)
2 the classify (L353) — the document's type (L353)
3 the extract (L143) — the JSON schema (L143), the fields (L353)
4 the verify (L353) — the rules (L353), the human (L208)
the queue (L270) · the workers (L266) · the batch (L282)
THE EXTRACTION (L143)
the structured output (L143) — the JSON (L143)
the fields (L353): the amounts, the dates, the vendor (L353)
THE VERIFICATION (L353)
the rules (L353) — the totals, the cross-checks (L353)
the human (L208) — the low-confidence (L139) reviewed (L353)
INTERVIEW, 4 MOVES
1 clarify "the documents, the volume, the accuracy (L353)"
2 pipeline "the parse, the classify, the extract, the verify (L353)"
3 extract "the JSON schema with the fields (L143)"
4 verify "the rules and the human (L353)"Key Takeaways
Recap
- The AI document processing system is the protocol run on a document product (L353): the clarify (L353), the pipeline (L353), the extraction (L143), and the verification (L353)
- The clarify (L353): the users (L162), the documents (L177), the volume (L353), and the accuracy (L353)
- The pipeline (L353): the parse (L177), the classify (L353), the extract (L143), and the verify (L353) — the queue (L270) and the workers (L266)
- The extraction (L143): the structured output (L143) — the JSON schema (L143) with the fields (L353)
- The verification (L353): the rules (L353) — the deterministic checks (L353) — and the human (L208) — the low-confidence (L139) reviewed (L353)
- The AI shape (L353): the documents (L177) — the pipeline (L353) — the parse (L177), the classify (L353), the extract (L143), and the verify (L353) — the batch (L282) at the scale (L353)
Check your understanding
Answer each one out loud. Then rate yourself honestly.
0/8What's the clarify (L353)?
How do you design the extraction (L143)?
How do you verify the accuracy (L353)?
How does it scale (L282)?
What's the eval (L341)?
What's the classify (L353)?
What's the schema (L143)?
What is the document's pipeline (L353)?
A Closing Note — The Line, Staged
You now hold the design: the parse, the classify, the extract, and the verify — with the conveyor fast and the supervisor checking. The mailroom line is staged — and the unclear letters reach the supervisor (L353).
Next: the hardest latency budget — AI Coding Assistant (L354).