🔍 CLAIMS AUDIT: Rakīm AI (رَقِيم)
This document audits technical claims made in older project descriptions and reports, comparing them to the actual state of the codebase. It details which claims are supported, unsupported, or need modification, providing clean rewrites for the upcoming official report.
1. ONNX Runtime Acceleration & 30%-50% Latency Reduction
- Old Claim: The OCR engine is accelerated using ONNX Runtime, resulting in a 30% to 50% reduction in inference latency.
- Code Reality: UNSUPPORTED. There is no ONNX Runtime dependency or ONNX model file loaded anywhere in
kraken_service.py,lm_decoder.py, orconfig.py. The system loads PyTorch models (.mlmodelformat via Kraken's Torch-based engine) directly. - Why it matters: Claiming ONNX acceleration when the code runs raw PyTorch is technically incorrect and will be flagged during a rigorous code review.
- How to Rewrite:
"Performance optimization is achieved via PyTorch Mixed-Precision (FP16) execution on CUDA-enabled GPUs (e.g., NVIDIA RTX 4050), alongside a Fast Segmentation flag (
FAST_SEGMENTATION=true) that reduces layout analysis latency from 15–30 seconds down to 1–3 seconds. Additionally, a SQLite cache system speeds up subsequent page requests to 0 seconds on a cache hit."
2. 96.54% / 96.28% Character Recognition Accuracy
- Old Claim: The HTR system achieves 96.54% (or 96.28%) character recognition accuracy on historical manuscripts.
- Code/Metrics Reality: PARTIALLY SUPPORTED / CONTEXTUAL.
- The new model
exp6_best.mlmodelachieves 96.71% accuracy (3.29% CER) on trained/validation data. - On a frozen, unseen test set of 51 pages (RASAM dataset), it achieves 92.50% accuracy (7.50% CER).
- The legacy model
reg(96.5).mlmodelwas named after an accuracy claim but produced illegible text when tested on historical Maghrebi hands.
- The new model
- How to Rewrite:
"The specialized recognition model (
exp6_best.mlmodel), trained specifically on Maghrebi calligraphic hands, achieves a Character Error Rate (CER) of 3.29% (96.71% accuracy) on training sets and generalizes to unseen pages with a CER of 7.50% (92.50% accuracy). This is a highly competitive result for historical Arabic manuscripts, contrasting with the legacy model which failed to produce readable outputs."
3. CLAHE Image Preprocessing as the Default Solution
- Old Claim: Contrast Limited Adaptive Histogram Equalization (CLAHE) is used as the primary image enhancement method before segmentation.
- Code Reality: FLAGGED / DISABLED. In
config.py, theOCR_ENHANCEsetting (which triggers CLAHE and adaptive thresholding) is set tofalseby default. Developers noted that aggressive preprocessing breaks Kraken's neural BLLA segmentation (producing empty bounding boxes and slower runs). Instead, the system relies on raw images processed by Kraken's native Sauvola binarization (nlbin). - How to Rewrite:
"To preserve the structural integrity of neural line segmentations, the default pipeline bypasses aggressive pixel-level enhancements like CLAHE (which is kept as an optional, disabled configuration
OCR_ENHANCE=false). Instead, the system feeds raw binarized text directly into the neural layout segmenter via Kraken's native Sauvola binarization (nlbin), ensuring clean line extractions without empty region artifacts."
4. Comparisons to Commercial OCR Engines
- Old Claim: The system outperforms commercial engines (like Google Cloud Vision or Tesseract) by 40% on historical manuscripts.
- Code Reality: NOT VERIFIED. There are no benchmarking datasets or test logs comparing the system to Google Vision or Tesseract in the project directories.
- How to Rewrite:
"While general-purpose commercial OCR engines (e.g., Google Cloud Vision, Tesseract) are trained on modern printed Arabic and struggle with historical handwriting, Rakīm AI utilizes specialized local models trained on specific manuscript hands. This specialization makes it a viable, high-fidelity alternative for historical transcriptions where printed OCR engines fail."
5. Unified Post-Processing Yields an Additional 2%-4% Accuracy Boost
- Old Claim: An algorithmic post-processing script provides an additional 2%-4% boost in transcription accuracy.
- Code Reality: PARTIALLY SUPPORTED. The script
PostProcessor.process()(which uses a local Arabic n-gram lexicon to correct trailing spacing, dangling letters, and minor OCR typos) is implemented. However, the exact percentage boost is not documented. - How to Rewrite:
"Following transcription, an algorithmic post-processor (
PostProcessor) repairs spacing inconsistencies and dangling character fragments (such as trailing word boundaries), aligning the raw HTR predictions with standard logical Arabic vocabulary."
6. Language Model is an API-based ChatGPT Layer
- Old Claim: Language model corrections are applied in real-time using cloud-based LLMs.
- Code Reality: CONTEXTUAL.
- Core HTR decoding error correction is handled locally and offline via a character n-gram model (
char8_trainval.lm) during beam search decoding (reducing CER from 7.48% to 6.79% on RASAM). - Cloud LLMs (via OpenRouter/Gemini) are used strictly on-demand for high-level semantic analysis (page summaries, terminology explanations, entity extraction, and title suggestions) to manage API costs and latency.
- Core HTR decoding error correction is handled locally and offline via a character n-gram model (
- How to Rewrite:
"Rakīm AI features a dual-layer language correction system. The primary correction layer runs locally and offline, utilizing a character-level n-gram model (
char8_trainval.lm) integrated directly into the Kraken CTC beam search decoder. The secondary layer is generative, running on-demand via cloud LLM APIs to perform advanced semantic tasks such as page summarization, entity indexing, and context-aware term explanations."