ocr-pipeline-and-quality

Guides changes and A/B quality evaluation of OCR backends, preprocessing, caching, and table reconstruction.

9.2k|581|Updated Jan 31, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/kreuzberg --skill ocr-pipeline-and-quality
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ocr-pipeline-and-quality
Source: https://github.com/kreuzberg-dev/kreuzberg/tree/main/.ai-rulez/skills/ocr-pipeline-and-quality
Command: npx skills add https://github.com/kreuzberg-dev/kreuzberg --skill ocr-pipeline-and-quality

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Modifying OCR behavior in Xberg is risky because backend outputs are not interchangeable measurements: confidence semantics, font sizes, and page acceptance differ across Tesseract, PaddleOCR, Candle, and custom backends. This Skill encodes the invariants needed to change or evaluate the OCR pipeline without silently corrupting quality metrics or cache behavior.

Core Features & Use Cases

  • Backend and execution rules: Covers the OcrBackend trait, OcrBackendType variants, blocking execution via tokio::task::spawn_blocking, language validation, and page orientation handling.
  • Configuration and cache safety: Explains the dual TesseractConfig defaults, the OCR cache key composition, and when to bump TESSERACT_RESULT_SCHEMA_VERSION for A/B or revert checks.
  • Quality invariants and tables: Documents confidence semantics, hOCR font metadata requirements, page acceptance behavior, and the correct row-then-column table reconstruction order.
  • Use Case: When rewriting OCR recall logic, use this Skill to require an independently grounded F1 A/B benchmark and avoid comparing Tesseract typography-derived font sizes against Sceptre/Paddle geometric proxies.

Quick Start

Load the ocr-pipeline-and-quality skill before changing the Tesseract preprocessing defaults and tell me which quality invariants and cache keys I need to update.

Frequently Asked Questions about ocr-pipeline-and-quality

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I change OCR preprocessing defaults in Xberg?

Default preprocessing is 300 DPI, deskew, and Otsu binarization, with auto-rotation, denoise, contrast enhancement, and color inversion off unless configured. Update both the public types::formats::TesseractConfig and internal ocr::types::TesseractConfig and keep their synchronization test passing.

How do I run an A/B quality comparison between OCR backends?

Require an independently grounded F1 A/B benchmark, since precision is the scarce resource on the current corpus. Bump TESSERACT_RESULT_SCHEMA_VERSION or disable the cache so unchanged inputs do not reuse stale results, and use the benchmark-workflow skill.

Can I compare confidence scores between Tesseract and PaddleOCR?

No, backend outputs are not interchangeable measurements. Query confidence_semantics() before interpreting confidence, and never threshold Uncalibrated output using a Tesseract-derived scale.

Why do OCR font sizes differ between backends?

Tesseract font size is typography from hOCR x_fsize and requires hocr_font_info=1, otherwise sizes fall back to 12 pt. Sceptre and Paddle font size is a geometric detection-box proxy, so the two quantities must not be compared or thresholded together.

Why does OCR table reconstruction produce spurious columns?

Detecting columns on raw words creates spurious columns for multi-word cells. Detect rows first, merge words into cell tokens, then detect columns on the merged tokens using reconstruct_table_with_columns.

When should I bump TESSERACT_RESULT_SCHEMA_VERSION?

Bump it whenever unchanged image and config inputs can produce different output, since the cache key's config hash includes the schema version but no build or code identity. Alternatively disable the cache for an A/B or revert check.