Skip to content

Add OCR routing decision guide with recommended confidence thresholds and examples #254

Description

@yulinlina

Description

pdf-inspector provides classification, confidence scores, and per-page OCR routing, but the README and binding docs do not currently explain how to turn these outputs into a practical routing policy. A dedicated guide would help users decide when to extract text locally, when to send the whole document to OCR, and when to apply page-level OCR only.

Motivation

The main value proposition of this project is smart routing to avoid unnecessary OCR costs. However, users may not know what confidence threshold is safe for their workload, how to interpret Mixed results, or how to combine classification with per-page routing. Without guidance, integrators may choose overly conservative thresholds and still pay for OCR, or overly aggressive thresholds and miss scanned content.

Proposed Solution

Add a documentation page such as docs/ocr-routing.md that includes:

  • How to interpret TextBased, Scanned, ImageBased, and Mixed classifications
  • Recommended default confidence thresholds for common cost/accuracy tradeoffs
  • Examples of page-level routing using per-page results
  • Suggested fallback behavior for low-confidence documents, corrupted files, or encrypted PDFs
  • Short examples for Rust, Python, Node.js, and browser WASM bindings

A possible structure could be:

  1. If classification is TextBased and confidence is high, extract locally
  2. If classification is Scanned and confidence is high, route the whole document to OCR
  3. If classification is Mixed or confidence is borderline, use per-page routing or request a second check

Alternatives Considered

  • Add threshold configuration to the API first, but documentation is needed regardless and can land sooner
  • Put guidance only in the README, but a separate guide will be easier to maintain and link from language-specific docs
  • Provide an opinionated helper function in code later; the guide can define the recommended behavior first

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions