Document Processing Pipeline, Stage by Stage
Mixed document packs are hard to trust until you learn exactly what happened to every single page that they hold. The DaletParse document processing pipeline answers that question with six fixed steps that run in order from intake to delivery. It validates the file, splits it, types each part, reads the fields, checks them and delivers the result to you. Every step writes down what it decided, so a reviewer can follow the path of any document through the run. Each step has a clear job: some call a model, and the checks run as plain Python.
Key takeaway
One analysis function runs six stages for every upload, from the workspace, the API or the command line. Models read pages, Python checks the values, and each document ends accepted, accepted with flags or rejected.
Why mixed packs need a pipeline with fixed stages and rules
Many extraction tools take one page and return text. Mixed document packs rarely arrive that tidy, so they need a plan. That works for a single invoice. However, it breaks on a loan file, where a bank statement, a tax return and a passport share one PDF.
Also, a document processing pipeline for mixed document packs must solve three problems.
- Unknown boundaries mean that nobody knows where the second document starts, so fields from two documents land in one record.
- One reader for everything means that a generic prompt treats a lease and a paystub alike.
- Silent failures mean that a failed page vanishes, and the reviewer never learns that a document was lost.
A fixed document processing pipeline removes these gaps. First, splitting comes before typing. Next, typing comes before reading, and reading comes before checking.
In addition, these document processing stages never swap places. Therefore, a failed document still produces a result with a reason.
How six fixed stages turn each upload into a clear result
DaletParse treats a pack as many documents. Indeed, each one needs different handling. The document processing pipeline runs in a class named MultiDocPipeline. The stage order never changes.
First, intake prepares the pages, and splitting finds the documents. Notably, then classification assigns a registry type, and extraction runs the route for that type. Next, validation sets an outcome, and delivery writes the files.
The six document processing stages share one fixed order. Also, each one hands a smaller and surer object to the next. In fact, the raw file becomes pages.
The pages become documents, and the documents become typed records. In addition, the classification and splitting page covers the middle of the chain in depth.
What each pipeline stage does with a file, step by step
Each stage has one job and one output. Importantly, the notes below follow the real order of a run.
How intake checks a file and turns it into pages
The first stage checks the file. Overall, it accepts PDF, JPG, JPEG, PNG, TIFF, TIF and WEBP files up to 50 MiB. Page images use 72 DPI for native text.
Scans use 210 DPI, and photos use 300 DPI. Indeed, each page is checked as a native page or a scanned page. The document processing pipeline needs that label first.
A page is a native page when pdfplumber finds at least 20 words in its text layer. Otherwise it is a scanned page and goes through OCR. Intake is where the document processing pipeline decides how to read each page.
A quality check may find shadows or a watermark. Also, the page is then treated as a photo and cleaned first.
Splitting and page order come before any typing. Duplicate-page removal compares the first 300 characters of OCR text on consecutive non-native pages. A similarity of 0.95 or higher removes the repeat, which targets double scans. Good splitting keeps the document processing pipeline from mixing records.
Page order detection runs only for scanned PDFs. Besides, a vision pass reads printed page numbers, and Python reassembles the sequence. Boundary scoring then reads printed pagination, such as "Page 2 of 6". Finally, each page is scored against a threshold of 50.
Classification takes two clear passes. A vision pass describes up to five pages. Then a text pass picks one registry type, or "unclassified", from that description.
Annex pages, such as tax schedules and addenda, merge into the previous document. Notably, they skip extraction on their own. Typing is where the document processing pipeline picks a reader.
In addition, the reader choice drives every later step. Each typed record carries its type forward.
Extraction picks a route that fits each type. The simple route handles 72 types with a describe, extract and recheck sequence. The complex route is reserved for bank statements and has nine phases.
An annex route attaches a page to its parent. At this point the document processing pipeline hands each type to its own reader.
The registry holds 80 keys. Of these, 73 have a specialist extractor with its own validator. Specifically, use the specialist extractor page for the families. Use the statement page for the balance logic.
Validation sets the outcome for every document. It is pure Python, and it resolves each finding against a shared registry. Therefore, the message text comes from code and not from a model.
Validation is where the document processing pipeline becomes deterministic. In fact, any rejection gives rejected. Any flag without a rejection gives accepted with flags. Anything else is simply accepted.
The flags and outcomes page lists the severities and the check levels. Also, treat the outcome as a routing signal for review, not as a verdict. The document processing pipeline reports; people decide.
Delivery is the last of the document processing stages. It ends the whole run. Early information appears before the tables and validation finish.
Early information lets reviewers see the pack. It shows the document type, bank, holder, period and accounts.
Reviewers see the shape of the pack while later work continues. Mixed document packs therefore show their structure early, even for mixed document packs of many pages.
Delivery then writes one folder per document. Indeed, it holds a JSON envelope, a CSV mirror and the original PDF part. Bank statements add transaction CSVs per account. Everything is zipped, and a multi-document run adds a combined ZIP.
How the six stages of the pipeline flow as one line
The diagram shows the six stages as one line. In addition, intake opens a bounded job and starts a progress stream to the workspace. Splitting produces page ranges, and classification attaches a registry type.
Extraction then uses a specialist route or a generic workflow. Importantly, these document processing stages hand over a typed record each time. Validation applies rules and flags, and delivery writes the envelope and files. Overall, read as a whole, the document processing pipeline is a chain, not a single call.
The web workspace, the API and the command line all call a single analysis function. Therefore, a document passes through identical stages, whichever door it used. Together, these document processing stages form one line. Reviewers can read the document processing stages in order.
How a failed file still gets a clear result for a person
Each job streams its progress as events. Indeed, the progress stream lasts five minutes. A polling route exists for longer runs.
A cancel route also stops a job on request. Besides, a failed run in the document processing pipeline never ends silently.
A failed document, or one with no handler, becomes a rejection with the code REJ-UNSUPPORTED-001. Its category is processing failure. That rejection still gets a JSON envelope, a CSV mirror and a ZIP.
Therefore, the result list has one entry for every document that the splitter found. Notably, a reviewer never has to wonder whether a page was lost. This is how a document processing pipeline stays honest about failure.
Where models read and where Python decides the final result
The pipeline mixes two kinds of work. Models handle what needs perception. Python handles what needs arithmetic or a fixed rule.
Model calls cover four jobs.
- The vision pass that describes pages for classification.
- The describe, extract and recheck steps on the simple route.
- Proposed flag codes from the AI flag step.
- A vision fallback when boundary text is not confident enough.
Python covers the rest of the document processing pipeline, including boundary scoring, duplicate comparison, balance arithmetic and every validator. In fact, the model supplies only a flag code and a field path. Python looks up the message.
This keeps the document processing pipeline predictable. That limits what a creative model can write into your outcome.
What the pipeline needs from you before it can run well
DaletParse is a Python 3.12 container. In fact, it starts through Docker Compose. It combines a Flask web app, a REST API and a command line.
Notably, the document processing pipeline lives in that one container. OCR uses Tesseract, with an optional PaddleOCR service.
The document processing pipeline runs inside that container. Vision and text models are served by a separate GPU wrapper. You must run or reach that service before extraction works.
Importantly, the repository does not promise that documents stay inside your network. In fact, the wrapper decides where inference runs.
The web workspace also runs one job at a time. Page images wait in a queue. Overall, a watchdog fails a job after 900 seconds without activity. Plan queue time into any rollout that uploads many large packs.
One analysis function behind all three of the entry points
One function serves the command line, API and workspace. Specifically, this single analysis function sits behind every door. The single analysis function is the heart of the design. The single analysis function keeps results aligned.
Besides, a script runs the analyze command on a file. Also, a service posts the file to the analyze route and waits for the answer.
Because the single analysis function is shared, workspace results match caller results. Specifically, the review workspace and the API and command line pages describe each door. Engineers can script batches while reviewers use the screens.
Both see the same outcome. That single analysis function is also why a run through one door predicts the others.
What the envelope holds for each document in a run
Every document leaves the document processing pipeline as an envelope. Also, it names the document type, its label, the schema and the time of processing. An outcome block holds the status, the rejections and the flags.
The extracted data sits beside the outcome.
Document requests and a processing log follow. In addition, the log records extraction confidence and duration. However, the source file hash key stays empty in the code today. Therefore, do not plan an audit trail around it.
Limits to plan for before you rely on the pipeline
The pipeline has limits that a buyer should know. A canonical test suite of 259 cases, all passing, guards every stage of the pipeline. That number is a constant, not a calibrated score. Importantly, it says nothing about whether a document is genuine.
An unrecognized type is labeled unclassified, not forced into a guess. Indeed, the code then sends it down the default route, which re-runs classification. Do not assume that every unknown page is rejected. Mixed document packs may hold pages that no type fits.
Administrators set retention for web-workspace runs. Debug folders can hold full model transcripts. Notably, the security controls page lists the retention rules. For the wider discipline, read the intelligent document processing guide.
What one fixed pipeline gives your team in daily work
In fact, each property holds on every pack, whoever uploads it.
- The document processing pipeline gives every document in a pack a type and a recorded outcome.
- A failed document still produces a rejection envelope with a reason.
- Checks run in Python, so the same values give the same validator result on mixed document packs.
- Early information shows document type, holder and balances before validation ends.
- One single analysis function means the workspace, API and command line agree.
- Results arrive as JSON, CSV and ZIP files that your own systems can read.
Teams that load many files at once should also read about batch document processing. It explains how queued runs behave. Mixed document packs pass through the same document processing stages in a batch. One single analysis function serves the whole queue.
Run the pipeline on one workflow that you know very well
Judge the pipeline on your own pack. Choose one workflow, such as a credit file or a merchant onboarding set. Importantly, compare the splits, the types and the outcomes of the document processing stages with what your reviewers expect.
Check the page order in the output against the original pack. Then, open a native page and a scanned page side by side to see how each was read.
The document processing pipeline keeps the page images next to each typed record, so every stage can be checked against the page it read. In addition, the progress stream shows each document moving from stage to stage while the run is live.
Ask for a meeting, and bring a few files that are hard for your current process.
Questions and answers on this topic from the product team
Which file types can enter the pipeline?
The pipeline accepts PDF, JPG, JPEG, PNG, TIFF, TIF and WEBP files. The HTTP upload limit is 50 MiB per file. A larger file receives a 413 error instead of starting a job.
Do all six stages use a language model?
Not all of the six stages use one. Boundary scoring, duplicate-page removal, balance arithmetic and the final validation step run as Python code. Models describe pages, pick a type, turn descriptions into fields and propose some flags.
Why does a bank statement take a different route?
A bank statement has tables, running balances and several accounts. So it uses a nine-phase route instead of the short extraction route. The phases read tables with word positions, map headers, link balances to accounts.
What do I receive when a document fails?
You still receive an output, with a rejection envelope, a JSON file, a CSV mirror and a ZIP. The rejection carries a code and a reason, so a reviewer can see what happened.
Is the document processing pipeline deterministic?
Not fully, because the validators and arithmetic are deterministic, but model output is not. Description runs at temperature 0, extraction at 0.7 and flag proposals at 1.0.
Where does the pipeline run?
DaletParse runs as a self-hosted container. It calls Tesseract for OCR and a PaddleOCR service, and a GPU wrapper serves the vision and text models.
What teams said about DaletParse in the reviews they left
See how DaletParse fits the providers your team uses today
Book a short meeting for a walkthrough with your own providers in mind, or join an in-person class to learn the method first.