

Allow essential product analytics and error diagnostics?
No document contents, OCR text, AI prompts, tokens, or email addresses are sent in telemetry.

Automated document organization requires more than assigning a category label. Production systems must distinguish native from scanned content, recover evidence through optical character recognition (OCR), extract temporal context, generate hierarchical folder paths, expose the reasons for each decision, and decline to classify when evidence is insufficient. This paper presents a hybrid architecture that combines deterministic rules, OCR-assisted evidence extraction, confidence-aware routing, human review, and controlled rule updates. The design treats every classification as an evidence-backed decision record rather than an opaque prediction. Rules encode domain knowledge as auditable matchers; OCR is invoked selectively for image-dominant documents; date resolution is separated from document-type inference; and an abstention policy routes ambiguous inputs to an Unknown or review state. Human corrections are accumulated as proposed rule changes but are not promoted automatically without validation, conflict analysis, and rollback support. A threat and failure analysis addresses misleading filenames, OCR corruption, duplicated files, stale rules, tenant isolation, timeouts, and error propagation. No accuracy or operational-performance results are claimed. Instead, the paper defines a reproducible evaluation protocol covering macro- and per-class F1, hierarchical path correctness, calibration, risk-coverage behavior, OCR fallback yield, latency, and rule-update regression. The resulting architecture is intended for document rooms, due-diligence repositories, records systems, and other environments where traceability and safe uncertainty handling are as important as classification throughput.
Organizations rarely store documents as isolated class labels. A bank statement may belong under a financial workstream, a statement subtype, a year, a quarter, and a month. A financing filing may require a different workstream and retention policy. The useful output of classification is therefore often a structured destination plus a defensible explanation, not merely “class 17.”
Real repositories complicate this task. Files arrive as digitally generated PDFs, scans, photographs, word-processing documents, spreadsheets, and mixed-content packages. Filenames can be descriptive, generic, or actively misleading. Dates may represent execution, reporting period, filing, issue, or scan time. OCR may recover useful text but can also substitute digits and letters, fragment layout, or return nothing. A forced classifier hides these uncertainties behind a confident-looking label.
This paper proposes a hybrid architecture for explainable file organization. It uses rules as inspectable sources of domain knowledge, OCR as a conditional evidence-recovery mechanism, optional learned components as bounded evidence producers, and human review as a governed correction path. Its research questions are:
The contribution is a reference architecture and evaluation method. The work does not claim that rules are universally superior to learned models or that OCR resolves every scan. It argues that document automation should expose its evidence, model uncertainty explicitly, and make rule evolution a controlled software change.
Records-management systems organize documents to support retrieval, governance, retention, and accountability. ISO 15489-1 describes concepts and principles for creating, capturing, and managing records [1]. In this context, a classifier changes the information architecture of a repository. A wrong destination can affect discoverability, access control, retention, review scope, and downstream analytics.
The target should therefore be represented as a taxonomy with stable identifiers, display names, parent-child relationships, allowed date grouping, and version history. A human-readable path is a rendered view of that taxonomy, not the identity of the category itself.
Tesseract’s architecture evolved from connected-component analysis toward line recognition and recurrent sequence models [2], [3]. Regardless of engine, OCR output is an interpretation of pixels, not authoritative source text. Recognition quality depends on resolution, focus, orientation, script support, compression, noise, and layout. The system must retain the provenance of each extracted token: native text, OCR text, filename, metadata, or human annotation.
OCR should be invoked when native extraction is absent or insufficient, not automatically treated as a replacement for higher-fidelity embedded text. Page sampling, rendering resolution, preprocessing, and time limits must be recorded because they affect which evidence was available to classification.
Weak-supervision systems demonstrate how expert-written labeling functions can combine patterns, heuristics, and distant supervision while accounting for disagreement [4]. A rules-guided document system has a related but narrower goal: make domain knowledge explicit and auditable even when a learned label model is not used.
A rule can test a filename token, phrase, regular expression, date pattern, page location, metadata property, or relationship among signals. Rules should emit evidence and a candidate label rather than mutating a file directly. Conflicts must be visible, and a rule’s priority must not be confused with empirical reliability.
The NIST AI Risk Management Framework emphasizes validity, reliability, transparency, explainability, privacy, security, and accountability as characteristics of trustworthy AI [5]. For document classification, explainability is operational: a reviewer must be able to see why a category was selected, what contrary evidence existed, which rules fired, and why the decision was accepted or abstained.
This paper uses architectural decomposition and failure analysis. The system is separated into ingestion, content characterization, evidence extraction, candidate generation, evidence aggregation, abstention, path rendering, persistence, human review, and rule governance. Each stage has an explicit input, output, provenance record, timeout, and failure state.
The reference architecture is informed by a production-oriented document-classification case study, but private infrastructure identifiers, customer data, and proprietary rule content are excluded. No empirical dataset is analyzed in this paper. Section 9 defines the protocol for a future controlled study.
Ingestion validates file type, size, readability, and page count before expensive processing. A content fingerprint supports duplicate detection, but the fingerprint must not be used as a public identifier or cross-tenant lookup key. The original filename, detected media type, byte size, and ingestion time are recorded as metadata; none is assumed to be semantically correct.
Exact duplicates can reuse a prior decision only when the taxonomy version, tenant boundary, and policy allow it. Near-duplicate detection is a separate capability and should not silently merge documents that differ by signature, date, account, or annotation.
The characterizer determines whether content is digitally extractable, image-dominant, mixed, encrypted, malformed, or unsupported. A PDF with one text page and several scanned pages is mixed, not simply “native.” Characterization produces a processing plan that specifies extraction method, page sample, rendering resolution, OCR language, timeout, and resource limit.
Sampling is a risk-control decision. Reading only the first page may be adequate for a cover-led document type but unsafe when signatures, schedules, or decisive clauses appear later. The plan should use taxonomy-specific sampling policies and record every omitted page range.
Evidence is normalized into typed observations:
The source may be filename, native text, OCR, embedded metadata, structural feature, or reviewer annotation. Location identifies a page and optional coordinates. Quality records extractor-specific indicators but is not automatically interpreted as probability.
Normalization includes Unicode handling, conservative whitespace repair, case folding for comparison, and preservation of the original value. Sensitive text must not enter ordinary application logs. Errors report extractor state and page identifiers without copying document content into telemetry.
OCR is activated when native text is unavailable, below an evidence threshold, or inconsistent with the visible page. The fallback pipeline may deskew, normalize contrast, and render selected pages at a bounded resolution. It must preserve page aspect ratio and avoid aggressive transformations that change character shapes.
OCR can fail in four distinct ways: unavailable engine, unreadable render, successful recognition with no tokens, and low-quality or contradictory tokens. Collapsing these into “no text found” prevents diagnosis and can create false confidence. The result record therefore distinguishes execution state from recognition content.
Candidate generators are independent and side-effect free. Example generators include:
Each generator emits a candidate category, supporting evidence identifiers, contrary evidence, raw score, rule or model version, and explanation template. It does not emit a final folder path.
Let c be a candidate category and rj an evidence-producing rule. A transparent baseline score can be written as
where mj represents supporting matches, qk represents contradictions, and weights are versioned configuration. This is a ranking score, not a calibrated probability unless calibration has been demonstrated on held-out data.
Agreement across independent sources should generally carry more weight than repeated matches from the same derived text. Ten phrase matches from one OCR page are not ten independent observations. Aggregation should group correlated evidence to avoid score inflation.
If a learned classifier participates, its score remains one evidence channel. Modern neural-network confidence can be miscalibrated, and post-hoc calibration must be evaluated rather than assumed [6]. The system retains both raw and calibrated scores with model and calibrator versions.
Selective classification allows a system to abstain on uncertain inputs rather than force a decision [7]. An acceptance policy can require:
where c* is the highest-ranked category, c2 the runner-up, τc a category-specific threshold, δ a minimum margin, and C an unresolved-conflict indicator. If calibrated probabilities are unavailable, the same form can use explicitly named decision scores without probability notation.
Abstention reasons include insufficient evidence, close candidates, contradictory dates, unsupported content, OCR failure, stale configuration, timeout, and policy restriction. “Unknown” must remain a first-class result with evidence and reason codes, not a miscellaneous category that absorbs failures.
Document-type inference and date inference are separate. A statement may contain transaction dates, print time, due date, and reporting period. Date resolvers emit typed candidates such as issue date, effective date, filing date, period start, and period end. Category policy determines which type controls folder grouping.
After category and controlling date are accepted, a deterministic renderer maps stable taxonomy identifiers to a path:
For a monthly policy, the rendered suffix may be year/quarter/month; for a non-temporal category, date segments may be omitted. Missing dates produce an explicit undated branch only if the taxonomy permits it. Rendering is deterministic and independently testable.
Every outcome produces an immutable decision record containing:
The record supports audit and replay. A later rule version can re-evaluate the same evidence without erasing what the earlier system decided.
Human review is reserved for decisions where additional judgment has value. NIST research on human-in-the-loop technical-document annotation demonstrates a machine-assisted workflow in which human expertise remains central to domain-specific analysis [8]. A review interface should show the document, proposed destination, relevant evidence in context, competing candidates, abstention reason, and taxonomy alternatives.
The reviewer may accept, choose another category, correct the controlling date, mark a duplicate, or declare the document out of scope. A correction requires a reason code and becomes a new decision version. Review latency and disagreement are measurable system properties; they should not be hidden behind a simple “accuracy” figure.
Review prioritization should consider expected risk and information value, not only low score. A high-confidence classification into a sensitive or retention-critical category may warrant sampling. Random review samples are also needed to detect confidently wrong automation.
Human corrections can reveal missing vocabulary, overbroad expressions, date ambiguity, or taxonomy gaps. They should generate rule proposals, not immediate production mutations. This is analogous to software change management:
A proposal should be rejected if it solves a small error set by overmatching a broader class. Rule priority is not a substitute for resolving semantic conflicts. Tenant-specific rules must not leak examples or vocabulary into another tenant’s configuration without an explicit governance process.
| Failure mode | Consequence | Detection | Control |
|---|---|---|---|
| Misleading filename | Wrong category with plausible explanation | Filename conflicts with content | Treat filename as one evidence source |
| OCR digit or letter substitution | Wrong date, identifier, or rule match | Format checks and source disagreement | Preserve coordinates; require corroboration |
| First-page-only sampling | Decisive evidence missed | Low coverage or category policy mismatch | Adaptive, recorded sampling policy |
| Overbroad rule | Systematic false positives | Regression and conflict analysis | Versioned rules and rollback |
| Forced classification | Incorrect file placement | Low margin or unresolved contradiction | Abstain to Unknown/review |
| Stale taxonomy | Invalid or obsolete destination | Version mismatch | Fail closed and re-resolve taxonomy |
| Timeout | Partial evidence appears complete | Processing-plan completion state | Mark incomplete and abstain |
| Duplicate reuse across boundaries | Data or policy leakage | Tenant/taxonomy mismatch | Scope duplicate cache and decisions |
| Automatic rule promotion | Error amplification | Post-update correction spike | Human approval and staged rollout |
The key threat is not only an incorrect label. It is an incorrect label that appears authoritative, is placed into the repository, and later becomes training evidence for the same mistake.
Multi-tenant systems require configuration and evidence isolation. Each classification request resolves a tenant-specific taxonomy, rule version, date policy, storage destination, and authorization context. Cross-account or delegated access should use short-lived credentials and least privilege. Secrets and raw document content must not be copied into rule artifacts or diagnostic summaries.
Large documents require explicit resource budgets. The system may impose page, rendered-pixel, OCR-time, memory, and total-latency limits. Limits should produce a structured incomplete result, not a silent sample presented as a full-document decision. Asynchronous processing is appropriate when synchronous gateway limits cannot accommodate the required evidence plan.
Idempotency prevents retries from creating duplicate files or contradictory decisions. A request key should bind the file fingerprint, tenant, taxonomy version, and processing policy. Persistence occurs only after a decision record and destination are validated together.
Evaluation requires an authorized, de-identified corpus stratified by file type, category, scan quality, language, date pattern, page count, and document age. Near duplicates and versions must remain within one split to prevent leakage. Rules and thresholds are developed on training and validation data; the test set remains frozen until final evaluation.
The ground truth includes category identifier, controlling date type and value, expected path, duplicate relationship, and review rationale. Ambiguous documents may have an adjudicated set of acceptable labels rather than a fabricated single answer.
Per-class precision, recall, and F1 expose category-specific behavior. Macro-F1 gives equal weight to classes and is therefore useful when common documents would otherwise dominate a micro average [9]. Confusion matrices should be published with class support. Exact path accuracy is reported separately because a correct category can still produce the wrong date bucket.
Metrics include:
Forced-decision accuracy is insufficient for an abstaining system. Let coverage be the fraction of documents automatically accepted and risk the error rate among accepted documents. Report a risk-coverage curve as the acceptance threshold varies. Also report review precision: the fraction of routed cases that contain a real ambiguity or automation error.
Calibration is evaluated with reliability diagrams and a declared calibration error measure. Category-specific thresholds are selected only on validation data. The test set reports both quality and coverage at the frozen thresholds.
OCR evaluation measures fallback invocation rate, execution success, useful-evidence yield, character or word error rate on an annotated subset, and classification lift relative to the same pipeline without OCR. The study must also count harm: cases where incorrect OCR changed a previously correct or safely Unknown decision into an incorrect accepted decision.
Measure median and 95th-percentile latency by file type and page-count band, extraction and OCR time, timeout rate, peak memory, processed pages, and retry rate. Rule governance is evaluated through proposed-rule acceptance, regression failures, rollback frequency, correction rate before and after release, and cross-tenant isolation tests.
The evaluation should compare:
This isolates which components improve accepted-decision quality and which merely increase coverage.
A general model may identify semantic patterns that rules miss, but it does not remove the need for taxonomy versions, date policy, evidence provenance, abstention, access control, deterministic path rendering, or review. If used, model output should enter as versioned evidence with a constrained schema and independent validation. The architecture does not assume that generated explanations are faithful to internal model reasoning.
Rules are inspectable but can become brittle, overlapping, and expensive to maintain. They are strongest where vocabulary and structure are stable. Learned models can improve recall for variable language, while rules can enforce policy and high-precision anchors. The correct division depends on measured error, review cost, and domain change.
An Unknown state preserves repository integrity when available evidence cannot support a destination. Its value is visible only when evaluation reports coverage alongside error. A system that classifies every file can appear productive while moving uncertainty into hidden misfiling.
Reviewers need highlighted evidence and competing candidates. Engineers need extractor states, rule versions, and score components. Auditors need decision history and authorization context. End users need a concise reason and a correction path. One verbose trace cannot serve every audience; explanations should be generated from the same structured decision record at appropriate levels of detail.
This paper presents an architecture and evaluation protocol, not a completed comparative experiment. It reports no measured classification accuracy, OCR accuracy, latency, cost, or user-study result. Weighted-rule equations are illustrative and require validation and calibration for a particular taxonomy. The design does not establish legal compliance, records-retention policy, or suitability for a regulated workflow. Handwriting, multilingual content, complex tables, adversarial documents, encrypted archives, and audio-visual records require additional study. Third-party OCR and model behavior may change by version and must be re-evaluated.
Explainable document classification is a controlled decision pipeline, not a single prediction call. The proposed architecture characterizes each file, extracts provenance-bearing evidence, invokes OCR selectively, generates independent candidates, aggregates evidence without overstating score meaning, and accepts a decision only when policy permits. Category inference, date resolution, folder rendering, human review, and rule evolution remain separate and testable.
The central safety mechanism is the ability to abstain. Unknown and review outcomes prevent incomplete or contradictory evidence from becoming an authoritative repository structure. When corrections are converted into governed, regression-tested rule proposals rather than immediate self-modification, the system can improve without turning individual mistakes into automated policy. This combination of explainability, selective automation, and controlled learning provides a practical foundation for trustworthy document organization.
This manuscript is an architectural research paper. It does not claim peer review, independent certification, regulatory compliance, or measured superiority. Product and dependency behavior must be verified against the versions and deployment conditions used in a future empirical study.
Chaitanya, K. (2026). Explainable document classification: A rules-guided and OCR-assisted architecture for automated file organization. IRIQ AI Research.
@techreport{chaitanya2026explainable,
author = {Kranthi Chaitanya},
title = {Explainable Document Classification: A Rules-Guided and OCR-Assisted Architecture for Automated File Organization},
institution = {IRIQ AI Research},
year = {2026},
month = {July},
url = {https://iriqai.com/papers/explainable-document-classification},
note = {ORCID: 0009-0009-3105-4603}
}