Editor’s introduction
The study evaluates an AI workflow that converts unstructured batch manufacturing records (BMRs) into structured JSON format, preserving the original Group-Phase-Step hierarchy. The system uses token-based chunking, parallel large language model extraction, and a fixed schema covering 11 content types, with three layers of validation including JSON syntax, structural integrity, and GMP compliance. On three real-world BMRs ranging from 15 to 66 pages, it achieves composite confidence scores in the low to high eighties and reduces processing time from hours to minutes. The approach enables scalable, human-in-the-loop digitization and unlocks historical manufacturing data for analysis. Performance is limited by handwritten annotations and degraded scan quality, with the current OCR achieving about 85% accuracy on handwritten entries.
Introduction
The pharmaceutical manufacturing sector operates within a strict regulatory framework that requires comprehensive documentation throughout the production life cycle. Batch Manufacturing Records (BMRs), as mandated by regulatory authorities, including the United States Food and Drug Administration (21 CFR Part 211) and the European Medicines Agency (EU GMP Guidelines), constitute critical quality system components that document the complete manufacturing history of pharmaceutical products. These records encompass raw material specifications, equipment utilization, process parameters, quality control results, deviation documentation, and corrective action implementation. BMRs serve multiple critical functions: enabling traceability for regulatory audits, facilitating product recall procedures, and establishing fundamental safeguards for patient safety.
Current State of Documentation Practices
Contemporary pharmaceutical manufacturing facilities exhibit a stark contrast between sophisticated production technologies and outdated documentation methodologies. Despite significant technological advancement in manufacturing processes, documentation practices remain predominantly paper-based and manual in nature. Production operators continue to manually transcribe readings from digital instrumentation onto paper-based forms, perform mathematical calculations without computational assistance, and collect physical signatures. Quality assurance personnel subsequently have to manually review these documents, which often exceed 150 pages per batch, before they can be archived in physical storage facilities. Retrieval of documentation for regulatory investigations or quality audits requires physical access to these archived materials followed by manual examination.
Previous Research and Existing Approaches
The literature describes two different technological approaches developed to tackle the challenges of pharmaceutical documentation, but successfully integrating them has proven difficult. Newer artificial intelligence technologies have demonstrated capabilities in document extraction and digitization. Commercial solutions such as LlamaExtract and integrated frameworks combining LangChain with Pydantic validation have achieved success in converting standard business documentation—including invoices, contracts, and financial reports—into structured JSON formats. However, these general-purpose solutions show significant limitations when applied to pharmaceutical documentation, particularly in their inability to accommodate domain-specific requirements.
On the other hand, the pharmaceutical sector has developed specialized digitization platforms tailored to industry-specific requirements. Organizations such as Aizon have implemented intelligent batch record systems that automate manufacturing workflows and facilitate real-time data capture. Electronic Batch Record (EBR) systems have incorporated review-by-exception algorithms that reduce quality review time for newly manufactured batches. Nevertheless, these pharmaceutical-specific solutions primarily address prospective data capture rather than document conversion. Their reliance on standardized input formats makes them unsuitable for processing the diverse document formats accumulated over decades of manufacturing operations.
The Critical Gap
The existing technological landscape reveals a critical gap at the intersection of AI and the pharmaceutical domain. Current AI-based extraction tools, while having sophisticated document processing capabilities, lack the pharmaceutical domain knowledge necessary to ensure regulatory compliance and maintain data integrity. Conversely, pharmaceutical-specific systems, while incorporating requisite compliance features, lack the flexibility necessary to accommodate the natural variation present in documents. This technological gap leads to large amounts of manufacturing data, which holds decades of process knowledge, being difficult to use for analysis or process improvement.
No existing solution successfully integrates large language model (LLM) capabilities with pharmaceutical domain expertise to process BMR documents while maintaining regulatory compliance standards. This limitation constitutes a fundamental barrier preventing pharmaceutical organizations from leveraging manufacturing intelligence for continuous improvement and process optimization initiatives.
Operational Inefficiencies and Compliance Challenges
Manual BMR processing workflows represent an operational burden within pharmaceutical manufacturing operations. Empirical analysis demonstrates that each batch record requires approximately three hours of Quality Assurance review time. A representative mid-scale manufacturing facility producing 100 batches monthly generates approximately 1,200 BMRs annually, accumulating to tens of thousands of documents over a decadal period. Time-motion studies indicate that production operators allocate approximately 30% of available working time to documentation activities rather than value-generating manufacturing operations. These inefficiencies show as delayed batch release cycles, increased inventory costs, and operational disruptions during regulatory inspections.
Optical character recognition (OCR) and document extraction technologies demonstrate inadequate performance when applied to pharmaceutical batch records. While these systems successfully extract textual content, they lack capabilities for validating mathematical calculations, finding missing records for fixing problems, or maintaining the comprehensive audit trails mandated by 21 CFR Part 11 electronic records requirements. These technological limitations introduce regulatory compliance risks that may precipitate manufacturing line suspensions and necessitate resource-intensive remediation programs.
Documentation Errors and Quality Implications
Peer-reviewed studies in pharmaceutical quality literature identify documentation errors as a predominant source of manufacturing deviations, consistently ranking it among the primary factors in quality incidents. Manual documentation processes introduce multiple errors: operators may switch numerical values during equipment reading transcription, quality reviewers may fail to identify missing authorization signatures, and calculations may contain undetected computational errors. These documentation deficiencies extend beyond administrative considerations; they directly impact critical quality factors such as potency calculations and stability data that ensures medication efficacy throughout the designated shelf life.
Scalability Constraints
The inherently manual nature of current BMR processes imposes fundamental scalability limitations. Production volume expansion necessitates proportional increases in documentation personnel, establishing a linear cost relationship that constrains organizational growth trajectories. Economic modeling demonstrates that a facility attempting to scale production capacity from 50 to 200 batches monthly would require a four-fold increase in documentation resources, rendering expansion initiatives economically infeasible.
Historical document digitization initiatives encounter even more pronounced scalability challenges. Based on observed manual conversion rates of 2–3 documents per person-day, comprehensive digitization of a 20-year documentary archive (approximately 20,000 BMRs) would require 27 person-years of effort. These temporal requirements render manual digitization methodologies impractical for enterprise-scale digital transformation initiatives, resulting in valuable historical manufacturing intelligence remaining confined to paper-based storage systems.
Solution: User Perspective
The pharmaceutical industry requires a solution that transcends traditional document digitization. Generic extraction tools lack the domain knowledge necessary to ensure compliance, while conventional pharmaceutical systems lack the flexibility to process varied document formats. This gap demands an intelligent system that combines document processing capabilities with deep pharmaceutical understanding. We have developed an LLM-based agentic system specifically designed for BMR processing, incorporating both artificial intelligence adaptability and pharmaceutical expertise. This solution does not merely digitize documents; it validates calculations, identifies and links deviations with their corrective actions, maintains audit trails, and produces structured outputs that meet both regulatory requirements and operational needs. Because of the processing strategy, the system can convert large (more than 100-page) documents in minutes to tens of minutes.
When a pharmaceutical manufacturer uploads a Batch Manufacturing Record to our system, they initiate an intelligent transformation process that converts unstructured documentation into compliant, structured data. The following walkthrough demonstrates how our agentic AI workflow processes a hypothetical BMR document from a pharmaceutical manufacturing facility.
Initial Document Processing
Upon receiving a PDF batch record (in this example, a chemical purification process document) the system first extracts and analyzes the document structure. A typical BMR contains diverse manufacturing elements: equipment tables listing required materials and quantities, chemical preparation instructions with precise measurements, multi-step purification procedures, and quality control specifications with acceptable ranges. Our workflow identifies these varied content types and prepares them for intelligent parsing.
The system recognizes the document’s hierarchical nature immediately. Manufacturing procedures are not simply lists of steps; they follow a structured organization of groups, phases, and individual steps. The system models this pharmaceutical-specific structure, distinguishing between high-level operational groups like “Processing” or “Clearance” and detailed procedural steps within each phase.
Intelligent Content Extraction and Classification
As the workflow processes the document, it demonstrates sophisticated content understanding that goes beyond simple text extraction. When encountering an equipment table, for example, the system does not just capture text; it preserves the tabular structure, maintaining the relationship between equipment items and their quantities. The extracted JSON represents this as a structured table with headers and rows, enabling downstream systems to query specific equipment requirements.
Parallel Processing Architecture (User View)
To handle lengthy BMR documents efficiently, the workflow employs parallel processing capabilities. Rather than processing the entire document sequentially, the system intelligently chunks the content while maintaining critical relationships. Each chunk processes simultaneously, reducing overall processing time from hours of manual review to minutes or tens of minutes of automated extraction. The parallel architecture maintains document coherence: a deviation noted in chunk 3 remains properly linked to its corrective action in chunk 7. Because of this parallel processing, the system can chunk and process large 100-page documents in a single run.
Quality Assurance through Metrics
These metrics serve dual purposes. Internally, they guide iterative improvement—when coverage falls below a threshold, the system can reprocess specific sections. Externally, they provide users with transparency about extraction quality, presented as a composite confidence score (89.13% in this example).
User Experience and Transparency
From the user’s perspective, the complex orchestration of AI agents, parallel processing, and validation checks occurs seamlessly. They upload a PDF and receive structured JSON output within minutes or tens of minutes, complete with a confidence score and detailed metrics explaining that score. If the system encounters ambiguous content or achieves lower confidence in certain areas, it flags these for human review rather than making assumptions. What begins as a traditional paper document with handwritten notes, stamps, and complex formatting becomes structured JSON that preserves critical information while making it accessible for modern systems. Tables remain tables, calculations remain calculations, and the hierarchical structure of groups, phases, and steps stays intact. This structured JSON can later be displayed to the user through a clean UI.
Results
To evaluate our system, we processed three representative pharmaceutical batch records exhibiting the characteristics of real-world manufacturing documentation. These documents, ranging from 15 to 66 pages, encompassed diverse content including equipment tables, calculation sheets, handwritten quality annotations, regulatory stamps, and multi-page procedural instructions.
Processing Performance
The Metformin HCl Tabs BMR, despite being the longest document at 66 pages, demonstrated efficient processing with a total time of 1,912.7 seconds—substantially faster than the Sharp Packaging BMR’s 3,125.1 seconds. This efficiency occurred despite requiring 12 chunks for processing, the highest among all test documents. The average chunk processing time of 80.8 seconds for the Metformin document was the fastest among all three, suggesting that document structure and content type impact processing time more significantly than raw page count.
Analysis of Extraction Performance
The evaluation metrics reveal several noteworthy patterns in system performance. While crude word coverage varied across documents (54.19% to 71.33%), context-aware coverage (which evaluates semantic preservation rather than verbatim text matching) consistently exceeded 93% for all documents. This divergence suggests the system prioritizes pharmaceutical meaning over literal transcription, which is desirable given the prevalence of abbreviations, shorthand notation, and site-specific terminology in manufacturing records.
Critical pharmaceutical elements demonstrated perfect extraction fidelity. All calculation formulas, including variables, units, and acceptable ranges, were correctly identified and structured. Conditional logic statements, essential for capturing decision trees and procedural branching, maintained complete accuracy. These results validate the system’s capability to preserve GMP-critical information that directly impacts product quality and patient safety.
Error Analysis
First, handwritten annotations overlapping printed text created ambiguity in content attribution. Quality inspectors frequently write observations directly over pre-printed form fields, making it challenging to distinguish between template text and entered data. Second, site-specific abbreviations and notation systems not present in our pharmaceutical knowledge base led to misinterpretation of certain procedural elements. Third, tables spanning multiple pages with inconsistent header repetition patterns occasionally resulted in column misalignment or data attribution errors.
The 80% reference coverage for the Encapsulation BMR, while lower than the Sharp Packaging BMR’s perfect score, reflected challenges with certain non-standard reference formats rather than complete extraction failure. The system correctly extracted the referenced content but failed to establish explicit links for certain non-standard reference formats (e.g., “as per above procedure” rather than numbered references).
Document Complexity
Manufacturing records combine multiple content modalities within single pages—typed procedural text, handwritten measurements, official stamps, quality control signatures, and equipment diagrams. Scan quality varies dramatically, from clear digital forms to nth-generation photocopies with visible artifacts, shadowing, and paper degradation. Each facility employs unique form designs with site-specific modifications accumulated over years of process evolution. Quality control annotations frequently obscure underlying text through stamps, signatures, and handwritten notes added during batch review.
The system’s ability to achieve composite confidence scores exceeding 82% on such visually complex documents validates the effectiveness of our vision-language model approach over traditional OCR pipelines. The parallel architecture’s maintenance of document coherence despite this complexity demonstrates its suitability for production deployment.
Impact and Significance
The transformation from manual to intelligent processing delivers immediate operational benefits. Processing time drops from hours of manual review to minutes or tens of minutes of automated extraction. The structured output enables instant searching, trending analysis, and integration with other systems. Quality teams can query across thousands of processed BMRs to identify patterns, while compliance officers can quickly compile historical data for regulatory submissions.
More significantly, the intelligent grouping of information reveals insights that manual processing might miss. By understanding that certain steps belong to the same phase and phases to the same operational group, the system enables analysis at multiple levels of abstraction. Organizations can optimize at the step level, phase level, or examine entire operational groups for improvement opportunities.
Limitations
While our approach demonstrates significant improvements in schema adherence, several technical constraints merit discussion. First, the model’s performance degrades on documents with extensive handwritten annotations or degraded scan quality—a common characteristic of historical BMRs from the 1980s–2000s. Our current OCR preprocessing achieves approximately 85% accuracy on handwritten entries, creating an upper bound on overall system performance.
Second, the parallel chunking architecture, while enabling efficient processing of lengthy documents, occasionally struggles with cross-chunk dependencies. Complex deviation narratives spanning multiple pages may lose contextual coherence, requiring post-processing validation to ensure complete capture of corrective action chains. This limitation particularly affects documents exceeding 150 pages, where chunk boundary decisions become increasingly critical.
Ethical Considerations
Deploying AI systems in pharmaceutical manufacturing raises ethical considerations that extend beyond technical performance. Most fundamentally, our system is designed as a human-in-the-loop augmentation tool rather than an autonomous decision-maker. All extracted JSON outputs require qualified personnel review before integration into validated systems, maintaining human accountability for quality decisions that ultimately affect patient safety.
We acknowledge the potential for automation bias—the tendency for reviewers to over-rely on AI-generated outputs. To mitigate this risk, our confidence scoring deliberately errs on the conservative side, flagging ambiguous content for manual review even when the model has high internal certainty. This design choice prioritizes patient safety over processing efficiency.
Future Direction
The current implementation represents a foundational step in BMR digitization, but the potential for enhancement extends beyond document processing. Our immediate development roadmap focuses on expanding the system’s pharmaceutical domain knowledge through specialized training on GxP documentation, regulatory guidances, and industry-specific terminology. This will enable more nuanced understanding of complex pharmaceutical concepts like stability protocols, validation procedures, and change control documentation.
We envision the system evolving from a processing tool to an intelligent quality assistant, capable of not just extracting data but proactively identifying compliance risks, suggesting process optimizations, and predicting potential deviations based on historical patterns. Advanced features under development include multi-language support for global operations, real-time collaborative review capabilities where quality teams can validate and annotate extractions, and automated generation of regulatory submission packages from processed BMRs. As the system processes more documents and receives user feedback, its machine learning components will continuously refine extraction accuracy and develop deeper understanding of manufacturer-specific documentation patterns.


