Case Study
AI Engineering

From a Week to a Day: AI-Assisted Parser Development

A chemical industry business needed to turn incoming purchase-order releases and delivery notes into validated, structured data despite wide variation in partner formats.

STX Next developed an AI-native approach that reduced the time needed to create and validate a parser for a new document format from a week to a day.

INDUSTRY
Chemical Industry
Location
United States
SERVICES
AI Engineering, Custom Software Development
TECH STACK
Python, Pydantic, LLMs, Tesseract OCR, PDF and spreadsheet processing libraries
The Client

Managing Purchase-Order Processing Across Multiple Formats

The client processes incoming purchase-order releases and delivery notes from multiple business partners through an automated workflow.

These documents arrive as PDFs, Excel files, email attachments, and embedded images. Each partner uses its own document layout, making it difficult to extract information consistently despite similar underlying business data.

The extracted information must be standardized and validated before being passed to downstream systems.

Industrial chemical plant with large storage tanks, tall distillation towers, and numerous interconnected pipes under a partly cloudy sky at dusk.
The Challenge

Manual Parser Development Became the Bottleneck

The main challenge was not simply extracting text. Scanned documents required OCR, while different partner layouts required their own extraction logic. Each incoming document had to be converted into a consistent set of validated fields that downstream systems could use reliably.

Initially, the team created a dedicated parser for each partner layout. The approach worked, but every new variation meant another parser to develop, test, and maintain.

With a large number of document types to support, creating and validating one new parser could take roughly a week.

The team also experimented with using an LLM to handle documents directly at runtime. While the results were often good, this introduced other limitations:

Response times were too slow for the required workflow

Each file would require a model call, increasing costs and introducing hallucination risks.

Sensitive content would need to be sent to an external model at runtime

Developing support for new document types remained the main engineering bottleneck

The Solution

AI-Assisted Parser Generation With Deterministic Processing

Wide view of an industrial chemical plant with tall smokestacks and complex piping, emitting white steam under a blue sky with scattered pink clouds during sunset.

Rather than using an LLM to read every production document, STX Next moved AI earlier in the workflow.

The team developed an approach in which a small worked example is used to generate a deterministic parser for a new document type. Once created and validated, the parser processes files in that format without requiring a model call for each document. The implemented system has two main layers: ingestion and routing.

Layer 1: Extracting and Validating Incoming Documents

The ingestion layer selects the appropriate extraction approach based on the incoming file type.

It supports:

  • PDF extraction, with a fallback approach and OCR for scanned documents
  • OCR for images, using Tesseract to extract text from image files
  • Excel processing, including hidden sheets
  • Email processing, including attachments and embedded images
  • A common typed and validated result structure across document types

Regardless of the original format, the extraction step produces data in the same validated structure before it moves further through the system.

SEE OUR OCR AND INTELLIGENT DOCUMENT PROCESSING SERVICES →

Layer 2: Routing Documents to the Right Processing Logic

The routing layer determines how the extracted content should be processed.

  • Known formats are sent to an existing deterministic parser
  • New formats can be passed to the parser-generation tool
  • Once a new parser has been generated and validated, it becomes part of the deterministic processing flow

This means documents handled by an existing deterministic parser do not require an LLM call for every file.

Standardizing New-Format Development

Every new implementation follows the same core setup:

  • A shared data model
  • A common parser base
  • Standard test scaffolding
  • Test-driven development
  • Validation against a worked example

Planning, coding, test creation, review, and debugging are handled within the generation workflow. The resulting code is run against the worked example and refined until it passes the generated tests.

This approach reduced development and validation time from about a week to about a day.

The IMPACT

Faster Support for New Document Formats Without Runtime LLM Calls

01

From a Week to a Day

The time required to develop and validate a parser for a new document format dropped from roughly a week to about a day.

02

Processing Without Per-Document LLM Calls

Once a parser has been created and validated, documents using that format are processed deterministically without sending each file through an external model.

03

Consistent Structured Output

Different source formats are converted into the same validated structure before the data moves into downstream systems.

04

A Repeatable Development Process

Shared structures, testing, and validation reduce the amount of one-off engineering required when new document types are introduced.

Industrial facility with a tall cylindrical chimney, a large metallic silo with a conical roof, and an elevated metal walkway against a partly cloudy blue sky.
Summary

The Role of AI in Document Automation

The project showed that the main question was not whether an LLM could extract the required information, but where AI added the most value. Direct runtime use produced good results, but introduced latency and required a model call for every incoming file. Using AI for code generation instead targeted the engineering effort behind supporting new layouts.

The project also highlighted the importance of validating generated output. Shared abstractions and validation against generated tests helped standardize parser implementations. Early experiments showed that plausible AI output can still be wrong when the underlying input fails, reinforcing the need to verify generated results against real source data.

In this setup, AI reduced development and validation time for a new document type from about a week to about a day. Once validated, the resulting deterministic parsers process supported formats without per-document LLM calls.

Need to Automate Complex Document Workflows?

See how AI engineering and custom software can help reduce manual development effort while keeping document-processing workflows consistent and easier to maintain.

Contact us

Our customers love to work with us