scieee AI-readable full text Open interactive document viewer

pyonb: an open-source API and optical character recognition SDK for automated document-to-text conversion of clinical records

Roberts, Thomas; Noor, Kawsar; Lai, Wai Shing; Piatek, Stefan; Dobson, Richard; Harris, Steve; Eshaghi, Arman; Keating, Sarah

Abstract

Optical character recognition (OCR) software is becoming increasingly prevalent with the expanding computational power and advancements in natural language processing, which enables reuse of previously untapped data due to the lack of tools for converting images into computer-readable text. Broadly, OCR is the analysis, recognition and extraction of text from documents. There are numerous open-source OCR software toolkits (Tesseract, Docling, olmOCR, PaddleOCR, Marker, Sparrow, MinerU, etc.) providing automatic conversion of images or filetypes such as PDF and DOCX into structured outputs.Data storage is significantly heterogenous across and within UK hospitals. Medical data is often stored within data warehouses containing hundreds of millions of documents. This volume of data combined with the difficulty of information extraction from scanned documents represents a significant data processing challenge. From a research and innovation perspective, automatic text extraction of hospital documents enables innumerable possibilities such as improving diagnostics, clinical workflows and administrative processes. For example, AI methods can be applied to decades of untapped historical records to create prognostic models that cannot be developed in any other way. Here, we present pyonb (https://github.com/SAFEHR-data/pyonb), an open-source Python SDK for automated document-to-text conversion, designed for clinical processing (although it is content-agnostic so useable for any text extraction task). pyonb bundles multiple open-source OCR tools (including Marker, Sparrow, PaddleOCR, and more) with a central forwarding API for requesting which OCR tool to execute. pyonb is designed as a suite of containerised services which can be deployed on a server to retrieve documents from a data warehouse for automated OCR and text extraction.In this work we describe:the user requirements which motivated our design decisionsthe software architecturehow developers can deploy the software and extend it to integrate their preferred OCR toolthe performance and processing speeds of a subset of OCR toolsAcknowledgements This study was funded by the National Institute for Health and Care Research (NIHR, award code NIHR302495) and University College London Hospitals Biomedical Research Centre. The views expressed are those of the author(s) and not necessarily those of the NIHR or the Department of Health and Social Care.

Full text

INTRO •Numerous open-source OCR tools have emerged from recent advances in natural language processing •Millions of archival hospital records are stored as non-computer-readable files •Multiple sclerosis (MS) is a chronic disease, hence patient records often span many years •Availability of hospital records in plaintext would enable the application of AI methods to decades of untapped patient data for developing new prognostic models •pyonb is an open-source Python application for automated document-to-text conversion LOCAL HOSPITAL SETUP pyonb was deployed locally as a set of Docker services and an Apache Airflow DAG with the following sequence of operators: 1. PDFs in SQL database uploaded to pyonb via HTTP POST request 2. pyonb performs OCR tool document-to-text conversion 3. JSON response output to researcher API endpoint Advancements in open-source OCR tools enable large-scale digitisation of documents into computer-readable text DISCUSSION •Docling was the most performant OCR tool, but processing time was ~3x slower than Marker and Paddle •Marker yielded the optimal balance between performance and document processing time •Processing times were constrained by CPU-bound infrastructure – GPU enables <0.1 second per document •Future: •Examine further OCR tools and output quality for medical research •Scale up to 350,000 MS records pyonb: an optical character recognition (OCR) toolkit for document-to-text conversion OCR PERFORMANCE EVALUATION METHODS n = 20 randomly selected MS clinical records (1-3 pages) Processing time = mean ± s.d. time per document (seconds) PERFORMANCE METRICS •Character Error Rate (CER) •Word Error Rate (WER) •Normalised Edit Distance (NED) •All metrics assessed by string comparison of JSON response vs. ground-truth copy-paste of PDF contents •For all metrics: lower score = higher similarity with ground truth RESULTS Digital version Tom Roberts, Kawsar Noor, Wai Shing Lai, Paul Smith, Stefan Piatek, Richard Dobson, Steve Harris, Arman Eshaghi, Sarah Keating { “document_content”: “Anytown Practice\n\n\n Mrs. A. N. Individual\n 12 Somewhere Avenue\n Someplace\n ...” } .PDF, .JPEG, etc. Forwarding API Docling Marker Paddle ~5-90s seconds (CPU only) “py-on-bee” 26 ± 27s 9 ± 4s 8 ± 3s github.com/SAFEHR-data/pyonb MS-PINPOINT [email protected]