Applying OCR to Automating Accounting Documents

Dmitry Moskalev23 May 2026

Problem

Accountants at MegaFon enter journal entries in SAP by hand from primary documents such as delivery notes and invoices. This causes delays and errors, especially at regional peaks. The pipeline must read 14 document types (about 332 fields) from scans, photos, PDFs and office files of uneven quality. The customer's targets: about 60,800 documents a month, up to 240 seconds per document, and 60% accuracy on non-machine-readable files and 90% on machine-readable ones.

Example from the article: a PDF shows "Vsego naimenovaniy 1", but its text layer reads "Vsegr naimenrvaniy", with Cyrillic "o" replaced by "r". Any model that reads the text layer then hallucinates.

Solution in brief

Cheap CPU checks come first: a machine-readability test and image cleanup. A router then sends each file down the right path, so the vision-language model (Qwen 3.5) runs only where needed. A lightweight NER model (GLiNER) fills a per-type field schema from the text, and post-processing swaps Latin lookalikes for Cyrillic letters.

Questions this case answers
  • How to extract fields from scanned and digital documents of many types with a schema per type, using cheap checks to skip an expensive vision model when a file already has machine-readable text
  • How to handle visually identical characters from different alphabets in extracted text
  • How to automate extraction of fields from scanned and PDF accounting documents
  • How to build an OCR plus NER pipeline for Russian-language documents without sending data to an external API

Tools and methods

  • Machine-readability check and image cleanup — CPU-only preprocessing
  • Router — picks direct parsing, a vision-language model or a CNN
  • Qwen 3.5 — OCR with a seven-instruction prompt
  • GLiNER — NER model that fills fields from a schema
  • Regular expressions — a fallback for fields where NER is not enough
Continue reading — it's free

Google or a one-time email code. No password.