You need to agree to share your contact information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

BhartiOCR Hero Banner

Hugging Face License: Multiple / Other Format: POSIX WebDataset HTTP Streamable Total Volume POSIX Shards Languages Writing Systems

BhartiOCR

16,750,000 paired image-text instances · 31 languages · 12 writing systems · 3,350 WebDataset shards

BhartiOCR is a large-scale, controlled synthetic OCR and document dataset spanning 31 South Asian languages and 12 writing systems, designed for multilingual OCR pretraining, fine-tuning, document recognition, layout research, and controlled robustness research. BhartiOCR contains 16,750,000 paired image-text instances distributed across 3,350 standardized WebDataset POSIX .tar archives (exactly 5,000 samples per shard). All records are encoded as WebP images (quality=85) paired with UTF-8 JSON metadata containing token-level logical bounding coordinates, font identifiers, structural tier tags, and recorded augmentation sequences.


1. Overview

BhartiOCR provides a controlled, scalable synthetic corpus to train and evaluate vision-language backbones, sequence-to-sequence OCR models (e.g., TrOCR, CRNN), and document understanding architectures (e.g., Donut, Nougat, Florence-2) across the typographic and orthographic complexity of South Asian scripts.

Four structural tiers with token-level bounding coordinates in standard WebDataset format:

  • Linguistic Purity: Unicode NFC text buffers screened against out-of-domain foreign stopwords and non-native scripts.
  • OpenType Complex Text Layout (CTL): Shaped via HarfBuzz (uharfbuzz) with explicit OpenType script and language tags, handling conjunct ligatures (samyuktaksharas), half-forms, reordering, and bidirectional text directionality (LTR Brahmic and RTL Extended Arabic).
  • FreeType Glyph Rasterization: Rendered via FreeType with font-metric vertical padding to mitigate diacritic truncation across upper and lower extremities.
  • 4 Structural Tiers: Spanning isolated words/tokens (30%), single reading lines (55%), multi-line paragraph blocks (13%), and full-page broadsheet documents (2%).
  • Physical Degradation Library: Samples are degraded using procedural paper substrates, ink capillary bleeding, bureaucratic stamps, creases, dust noise, contrast shifts, and optical distortions.
  • POSIX WebDataset Packaging: Serialized into high-throughput .tar shards for direct HTTP streaming into training loops without local disk extraction.

2. Dataset Summary

Property Dataset Specification
Dataset Name BhartiOCR
Total Scale 16,750,000 paired image-text instances
Archive Topology 3,350 WebDataset POSIX .tar archives (exactly 5,000 paired samples per shard)
Language Coverage 31 South Asian languages (22 Eighth Schedule languages + 9 additional regional/South Asian languages)
Writing Systems 12 distinct scripts (10 Brahmic LTR, 1 Extended Arabic RTL, 1 Alphabetic LTR)
Active Verified Fonts 134 verified open-source OpenType / TrueType fonts (1 additional font quarantined)
Structural Granularity 4 tiers: Full Page (2%), Paragraph (13%), Reading Line (55%), Word/Token (30%)
Image Format WebP lossy encoding at quality=85 (.webp)
Annotation Format UTF-8 JSON (.json) with token-level logical bounding boxes [x0, y0, x1, y1]
Degradation Distribution 12.5% Clean Baseline Controls (global_idx % 8 == 0) / 87.5% Stochastic Degradation
Degradation System 54-operator reference library; cloud production runner executes a controlled 12-substrate + 7-transform subset
Shard File Naming 100% published as {lang}_train_{shard:05d}.tar (no separate physical _val_ or _test_ files)
Partition Recipe Deterministic shard-index slicing recommended (e.g., ~90% train, ~5% val, ~5% test)
Reproducibility Pseudo-deterministic (seeded PRNG; preserves statistical structure across reruns)
Primary Tasks Multilingual OCR, Document Layout Research, Token Localization Research, Controlled Robustness Evaluation
Licensing Software & metadata: Apache-2.0; Fonts: SIL OFL 1.1 / GPL+FE / Apache-2.0; Upstream text: multi-license

3. Why BhartiOCR Exists

Optical Character Recognition and Document Understanding models trained on Latin-script corpora or clean synthetic renders frequently fail when deployed on South Asian printed material. BhartiOCR targets three specific engineering bottlenecks:

3.1 Complex Text Layout (CTL) and Conjunct Integrity

Brahmic writing systems are alpha-syllabaries (abugidas) where consonants carry an inherent vowel that is modified by dependent vowel signs (matras). Consonant clusters combine through halants (viramas) into complex conjunct ligatures (samyuktaksharas), half-forms, or vertically stacked glyphs. Perso-Arabic scripts (Urdu, Kashmiri, Sindhi) require cursive, context-sensitive glyph shaping across initial, medial, final, and isolated positions, formatted in Nastaliq or Naskh typographic styles.

Standard rasterization tools (such as default PIL rendering) bypass OpenType GSUB/GPOS tables, producing disconnected graphemes, misplaced diacritics, or missing-glyph tofu boxes (.notdef Glyph ID 0). BhartiOCR routes all text buffers through uharfbuzz with explicit script tags, language specifiers, and bidirectional flags (ltr vs rtl).

3.2 Diacritic Containment and Vertical Zone Padding

Indic scripts feature vertical vowel signs, nasal markers (anusvaras), breath markers (visargas), and nuance dots (nuktas) placed above the headline (shirorekha) or below the base consonant. Standard bounding-box tight-cropping clips these extremities, leading to systematic character and conjunct substitution errors during visual recognition.

The rendering pipeline adds font-metric-derived vertical padding to reduce diacritic and glyph-extremity clipping: Height=Ascender Zone+Descender Zone+Safety Padding\text{Height} = \text{Ascender Zone} + \text{Descender Zone} + \text{Safety Padding} This padding is designed to reduce clipping across upper and lower extremities.

3.3 Realistic Non-Sterile Document Degradation

Standard synthetic datasets present clean black text on uniform white backgrounds. Real-world South Asian documents (newspapers, archival books, court filings, administrative circulars) exhibit thin newsprint pulp bleed, toner micro-voids, ink feathering, handling folds, bureaucratic rubber stamps, uneven illumination shadows, and camera perspective tilt.

BhartiOCR applies a multi-stage degradation pipeline combining procedural paper substrates, ink compositing, and physical/optical noise to narrow the domain gap between synthetic pretraining and physical document recognition.


4. Generation Pipeline

[Raw Upstream Text Corpora]
          │
          ▼
[Stage 1: Unicode NFC Normalization] ──> Preserves ZWJ (\u200D) & ZWNJ (\u200C)
          │
          ▼
[Stage 2: Linguistic Purity Gate] ────> Stopword exclusion & >=3 native script chars
          │
          ▼
[Stage 3: Font Selection & cmap Gate] ─> Rejects font-string pairs missing codepoints
          │
          ▼
[Stage 4: HarfBuzz OpenType Shaping] ──> Script-tagged CTL, GSUB/GPOS, LTR/RTL
          │
          ▼
[Stage 5: FreeType Glyph Raster] ─────> Glyph bitmap rasterization & metric vertical padding
          │
          ▼
[Stage 6: Structural Tier Packaging] ──> 4 Tiers: Full Page, Paragraph, Line, Word
          │
          ▼
[Stage 7: Production Degradation] ────> 12 Substrates + Ink Bleed + 2–4 Stochastic Transforms
          │
          ▼
[Stage 8: Integrity Assertions] ───────> assert token_count > 0, assert glyph_id != 0
          │
          ▼
[Stage 9: Serialization] ─────────────> WebP (quality=85) + UTF-8 JSON
          │
          ▼
[Stage 10: POSIX Tar Packaging] ──────> 5,000 paired samples per shard
          │
          ▼
[Stage 11: SHA-256 Checksum] ─────────> Shard integrity verification
          │
          ▼
[Stage 12: Stream-and-Evict Hub Push] -> Background upload; stream-and-evict shard lifecycle
Figure 2: Actual Generation Pipeline

Figure 2: Actual production synthesis pipeline from normalized Unicode buffers to verified WebDataset shards.


5. Language & Writing-System Coverage

BhartiOCR encompasses 31 South Asian languages (22 Eighth Schedule languages + 9 additional regional/South Asian languages) spanning 12 distinct writing systems:

5.1 Full 31-Language Master Inventory

# Language ISO 639-3 Script Family Direction Shards Live Samples Live Hub Directory
1 Assamese asm Bengali-Assamese (Beng) LTR 100 500,000 data/assamese/
2 Bengali ben Bengali-Assamese (Beng) LTR 200 1,000,000 data/bengali/
3 Bhojpuri bho Devanagari (Deva) LTR 100 500,000 data/bhojpuri/
4 Bodo brx Devanagari (Deva) LTR 100 500,000 data/bodo/
5 Dogri doi Devanagari (Deva) LTR 50 250,000 data/dogri/
6 Gujarati guj Gujarati (Gujr) LTR 100 500,000 data/gujarati/
7 Hindi hin Devanagari (Deva) LTR 200 1,000,000 data/hindi/
8 Kannada kan Kannada (Knda) LTR 100 500,000 data/kannada/
9 Kashmiri kas Extended Arabic (Arab) RTL 100 500,000 data/kashmiri/
10 Konkani gom Devanagari (Deva) LTR 50 250,000 data/konkani/
11 Maithili mai Devanagari (Deva) LTR 50 250,000 data/maithili/
12 Malayalam mal Malayalam (Mlym) LTR 100 500,000 data/malayalam/
13 Manipuri mni Meetei Mayek (Mtei) LTR 100 500,000 data/manipuri/
14 Marathi mar Devanagari (Deva) LTR 200 1,000,000 data/marathi/
15 Nepali nep Devanagari (Deva) LTR 100 500,000 data/nepali/
16 Odia ori Odia (Orya) LTR 100 500,000 data/odia/
17 Punjabi pan Gurmukhi (Guru) LTR 100 500,000 data/punjabi/
18 Sanskrit san Devanagari (Deva) LTR 100 500,000 data/sanskrit/
19 Santali sat Ol Chiki (Olck) LTR 100 500,000 data/santali/
20 Sindhi snd Extended Arabic (Arab) RTL 100 500,000 data/sindhi/
21 Tamil tam Tamil (Taml) LTR 200 1,000,000 data/tamil/
22 Telugu tel Telugu (Telu) LTR 100 500,000 data/telugu/
23 Urdu urd Extended Arabic (Arab) RTL 200 1,000,000 data/urdu/
24 Awadhi awa Devanagari (Deva) LTR 100 500,000 data/awadhi/
25 Magahi mag Devanagari (Deva) LTR 50 250,000 data/magahi/
26 Chhattisgarhi hne Devanagari (Deva) LTR 50 250,000 data/chhattisgarhi/
27 Marwari mwr Devanagari (Deva) LTR 100 500,000 data/marwari/
28 Tulu tcy Kannada (Knda) LTR 100 500,000 data/tulu/
29 Angika anp Devanagari (Deva) LTR 100 500,000 data/angika/
30 Bishnupriya Manipuri bpy Bengali-Assamese (Beng) LTR 100 500,000 data/bishnupriya/
31 Newari (Nepal Bhasa) new Devanagari (Deva) LTR 100 500,000 data/newari/
Total 31 Languages 12 Writing Systems 3,350 16,750,000

5.2 Authoritative Writing System Aggregation

Writing System Script Code Direction Associated Languages Shards Total Samples
Devanagari Deva LTR Hindi, Marathi, Sanskrit, Nepali, Bhojpuri, Bodo, Dogri, Konkani, Maithili, Awadhi, Magahi, Chhattisgarhi, Marwari, Angika, Newari (15 languages) 1,450 7,250,000
Bengali-Assamese Beng LTR Bengali, Assamese, Bishnupriya Manipuri (3 languages) 400 2,000,000
Extended Arabic Arab RTL Urdu, Kashmiri, Sindhi (3 languages) 400 2,000,000
Kannada Knda LTR Kannada, Tulu (2 languages) 200 1,000,000
Tamil Taml LTR Tamil (1 language) 200 1,000,000
Gujarati Gujr LTR Gujarati (1 language) 100 500,000
Malayalam Mlym LTR Malayalam (1 language) 100 500,000
Odia Orya LTR Odia (1 language) 100 500,000
Gurmukhi Guru LTR Punjabi (1 language) 100 500,000
Ol Chiki Olck LTR Santali (1 language) 100 500,000
Meetei Mayek Mtei LTR Manipuri (1 language) 100 500,000
Telugu Telu LTR Telugu (1 language) 100 500,000
Total 12 Writing Systems (31 Languages) 3,350 16,750,000

6. Four Structural Tiers

Every 5,000-sample WebDataset shard is composed across four document structural tiers to support diverse OCR and document-AI modeling tasks:

Tier Granularity Volume Share Total Samples Live Typical Canvas Dimensions Word Count Target Modeling Focus
Tier 1 Full-Page Documents 2.0% 335,000 $1000 \times 1350$ px 80–350 Multi-column reading order, document layout research, table/spread parsing
Tier 2 Paragraph Blocks 13.0% 2,177,500 Max width $700$ px (variable height) 25–80 Multi-line text block recognition, wrapped paragraph reading order
Tier 3 Reading Lines 55.0% 9,212,500 Variable width $\times$ dynamic metric height 4–18 Sequence-to-sequence line recognition (TrOCR, CRNN), CTC loss
Tier 4 Words / Tokens 30.0% 5,025,000 Word advance width $\times$ dynamic metric height 1–3 Word/token recognition, vocabulary coverage, and complex-conjunct examples
Total 100.0% 16,750,000
Figure 1: Corpus Architecture

Figure 1: Corpus architecture across four structural tiers, 31 languages, and 12 writing systems.

  • Tier 1 (Full-Page Spreads): Rendered on fixed $1000 \times 1350$ px canvases simulating archival documents, government gazettes, and daily broadsheets with headers, horizontal column rules, and multi-block paragraphs.
  • Tier 2 (Paragraph Blocks): Formatted text blocks wrapped to a maximum width of 700 pixels with uniform line leading and font sizes (20–28 pt).
  • Tier 3 (Reading Lines): Continuous syntactic lines, poetry verses, and headlines with font sizes ranging from 26 to 38 pt.
  • Tier 4 (Words and Isolated Tokens): Isolated lexical items, compound words, numerals, and complex conjuncts (32–44 pt). Annotations provide word/token-level boundary coordinates.

7. Rendering & Complex Text Layout

Text rendering is implemented in Python via uharfbuzz and freetype-py:

  1. Unicode NFC & Joiner Retention: Ingested text is normalized to Unicode NFC via unicodedata.normalize('NFC', text). Zero-Width Joiner (\u200D / ZWJ) and Zero-Width Non-Joiner (\u200C / ZWNJ) codepoints are strictly preserved to maintain authentic half-consonant forms (e.g., Hindi हल्) and ligature suppression.
  2. HarfBuzz Buffer Configuration: For each text line, an empty uharfbuzz.Buffer is initialized, assigned the target ISO 15924 script tag (Deva, Beng, Taml, Arab, Mtei, Olck, etc.), ISO 639-3 language specifier, and directional mode (ltr for Brahmic scripts; rtl for Extended Arabic).
  3. OpenType Feature Shaping: uharfbuzz.shape(hb_font, hb_buffer) executes OpenType GSUB (glyph substitution) and GPOS (glyph positioning) rules, producing output glyph IDs, cluster associations, advance widths (x_advance), and positional offsets (x_offset, y_offset).
  4. FreeType Glyph Rasterization: Glyph IDs are loaded via freetype.Face.load_glyph(gid, FT_LOAD_RENDER | FT_LOAD_NO_HINTING) to rasterize 8-bit anti-aliased alpha bitmaps. Bitmaps are blitted onto a grayscale NumPy canvas using cumulative cursor positions.
  5. Bidirectional Cursor Tracking: For LTR scripts, the horizontal pen cursor advances by x_advance // 64. For RTL scripts (urd, kas, snd), the cursor begins at canvas_width - padding and decrements by x_advance // 64.
  6. Canvas Compositing: Pillow (PIL.Image) wraps the rendered NumPy array for subsequent paper-physics blending and format serialization.

8. Font Validation & Typography

The repository contains 134 active, verified OpenType and TrueType fonts organized across language and script directories:

  • Font Verification Gate: Before rendering, every font undergoes character-map validation via fontTools.ttLib.TTFont. The active Unicode cmap table is extracted via font.getBestCmap(). If a candidate string contains even a single character unmapped in the font's cmap, the font-text pair is rejected.
  • Quarantine Policy: Fonts that fail minimum script codepoint thresholds ($< 20$ target script codepoints in cmap) or generate invalid metrics are isolated in fonts/quarantine_broken_fonts/ (1 font currently quarantined).
  • Script Allocation: High-resource scripts (Devanagari, Bengali, Tamil, Extended Arabic) utilize diverse font pools spanning classical serif, modern sans-serif, and display typefaces. Scripts with smaller open-source typography ecosystems (Ol Chiki, Meetei Mayek) utilize verified authoritative typefaces (e.g., Noto Sans Ol Chiki, Noto Sans Meetei Mayek).

9. Annotation Schema & Geometry

Each sample within a WebDataset archive consists of a WebP image (.webp) and a paired UTF-8 JSON metadata record (.json).

Figure 4: Annotation Geometry & JSON Schema

Figure 4: Token-level geometry specification and paired JSON metadata schema.

9.1 JSON Schema Example (Tier 3 Reading Line)

{
  "sample_key": "nep_0000003",
  "tier": "Tier_3_Line",
  "lang": "nep",
  "font_name": "RozhaOne-Regular.ttf",
  "is_clean": false,
  "canvas_size": [614, 71],
  "text": "टाढा दक्षिणबाट पल्लवहरूद्वारा पराजित भए जसको फलस्वरूप",
  "tokens": [
    {
      "text": "टाढा",
      "bbox": [23, 29, 66, 44]
    },
    {
      "text": "दक्षिणबाट",
      "bbox": [69, 22, 167, 46]
    },
    {
      "text": "पल्लवहरूद्वारा",
      "bbox": [170, 29, 303, 48]
    },
    {
      "text": "पराजित",
      "bbox": [306, 22, 381, 45]
    },
    {
      "text": "भए",
      "bbox": [386, 29, 418, 44]
    },
    {
      "text": "जसको",
      "bbox": [421, 23, 488, 45]
    },
    {
      "text": "फलस्वरूप",
      "bbox": [491, 29, 590, 45]
    }
  ],
  "token_count": 7,
  "word_count": 7,
  "applied_augmentations": [
    "#02 Substrate: aged_paper",
    "#19 Mobile JPEG",
    "#21 Diagonal Fold",
    "#40 Keystone Tilt",
    "#15 Shadow Gradient"
  ]
}

9.2 Field Definitions

Field Name Type Description
sample_key string Unique identifier formatted as {lang}_{global_idx:07d} (e.g., kan_0008644).
tier string Structural tier: Tier_1_FullPage, Tier_2_Paragraph, Tier_3_Line, Tier_4_Word.
lang string ISO 639-3 three-letter language identifier.
font_name string Base filename of the font file utilized during shaping and rendering.
is_clean boolean Flag indicating whether the instance is an undegraded control sample (12.5%).
canvas_size [int, int] Canvas dimensions [width, height] in pixels.
text string Ground truth text transcription in normalized Unicode NFC.
tokens list[dict] Token-level annotations containing token text and bounding coordinates bbox.
token_count int Total number of annotated tokens in the instance.
word_count int Count of whitespace-delimited words in the input text buffer.
applied_augmentations list[string] Ordered list of physical degradation operations applied to the instance.
shaped_glyphs list[dict] Optional debug trace of shaped OpenType glyph IDs and cluster indices (first 30 glyphs).

9.3 Bounding Box Semantics

  • Format: Bounding boxes are formatted as [x0, y0, x1, y1] in absolute integer pixel coordinates with origin (0, 0) at the top-left corner.
  • Semantic Definition: Bounding boxes represent logical token boundary zones derived from text advance widths and vertical font metrics, computed as: $$x_0 = \text{cursor position}, \quad x_1 = \text{cursor position} + \text{token advance width}$$ $$y_0 = \text{baseline} - \text{ascender height} + 4, \quad y_1 = \text{baseline} + \text{descender depth} - 4$$
  • Important Caveat: Bounding boxes represent logical word/token layout cells based on HarfBuzz advance metrics. They are not tight pixel-level connected-component ink contours, nor are they character-level or conjunct-level bounding boxes.

10. Degradation System

BhartiOCR maintains a distinction between its comprehensive reference library and its active cloud production runner configuration:

Figure 3: Degradation Architecture

Figure 3: Two-layer degradation architecture: 54-operator reference library vs. active production runner configuration.

10.1 Reference 54-Operator Library

BhartiOCR documents a comprehensive reference library of 54 procedural degradation operators detailed in AUGMENTATION_REGISTRY.md, categorized into five functional domains:

  • Category A: Procedural Substrates (12 operators): Simulates diverse paper stocks, age-induced acid toning, pulp grain, moisture stains, notebook rulings, and formal stationery.
  • Category B: Physical Degradation Operators (14 operators): Models mechanical handling wear, ink capillary bleeding, toner erosion, photostat clipping, folds, carbon dye, and bureaucratic stamps.
  • Category C: Historical Manuscript Decay (11 operators): Captures archival aging phenomena including wormholes, craquelure, iron gall acid corrosion, fungal foxing, and margin embrittlement.
  • Category D: Geometric, Optical & Sensor Distortions (11 operators): Replicates capture artifacts including perspective tilt, optical defocus, sensor noise, dynamic range extremes, and compression loss.
  • Category E: Handwriting Kinematic Deformations (6 operators): Implements synthetic handwriting dynamics, stroke pressure modulation, slant, and elastic deformation models.

For full mathematical specifications, implementation parameters, and visual examples of all 54 operators, see AUGMENTATION_REGISTRY.md.

10.2 Active Production Runner Configuration

To sustain cloud throughput on CPU workers while preventing unreadable text corruption, the high-throughput production runner (indicpixel_kaggle_production_pipeline.py) executed a controlled subset of this library:

  • Procedural Substrates: 1 of 12 procedural paper substrates selected uniformly at random (clean_white, aged_paper, book_page, newspaper, ruled_notebook, parchment, weathered, coffee_stained, old_book, recycled_kraft, cream, ivory).
  • Ink Bleed Composite: Simulated capillary ink bleed composited directly onto the procedural substrate.
  • Stochastic Transforms: 2 to 4 transforms drawn from the active pool:
    • #26 Bureaucratic Stamp (semi-transparent colored seals)
    • #15 Non-Uniform Shadow (linear illumination gradients)
    • #20/#21 Paper Crease / Diagonal Fold (3D fold shadows)
    • #47 Dust / Sensor Noise (Gaussian normal noise)
    • #40 Keystone Tilt (affine rotation within $\pm 1.0^\circ$)
    • #44/#45 High / Low Contrast (dynamic range scaling)
    • #19 Mobile JPEG Compression (quality factor 68–85)

10.3 Clean vs Degraded Balance

  • Clean Baseline Controls: Exactly 12.5% of samples (global_idx % 8 == 0) are saved as undegraded control samples on white backgrounds (#01 Clean White Scan Baseline).
  • Degraded Samples: Exactly 87.5% receive the procedural substrate, ink bleed, and 2 to 4 stochastic transforms.

11. Quality Assurance

The synthesis pipeline implements automated validation gates at generation time and periodic forensic audits:

11.1 Automated Production Gates

  • Unicode Normalization Gate: Text buffers undergo NFC normalization; unmapped control characters and broken surrogate pairs are discarded.
  • Native Script Character Gate: Every candidate string must contain at least 3 alphabetical characters within the target script's Unicode block, rejecting punctuation-only noise strings (e.g., ,,,).
  • Language-Specific Contamination Filters: Ingested text is checked against language-specific exclusion lexicons to prevent cross-language stopword leakage (e.g., filtering out Hindi stopwords when synthesizing Bodo or Maithili).
  • Font cmap Assertion: Reject any candidate text line if even one character is missing from the candidate font's cmap table.
  • .notdef Post-Shaping Assertion: In production, every shaped sample is asserted:
    assert all(g.get("glyph_id", 1) != 0 for g in glyphs), f"Glyph ID 0 detected in {sample_key}"
    
    Samples triggering Glyph ID 0 (.notdef) are rejected and not serialized. Smoke-test batches audited during production runs reported zero .notdef occurrences.
  • Non-Empty Token Assertion: Every instance must contain at least one valid token (assert meta["token_count"] > 0).
  • Checksum Verification: Cloud workers verify local .tar shard integrity and calculate SHA-256 digests prior to uploading.

11.2 Offline Forensic Auditing Tools

  • 5,000-Sample Cloud Smoke Tests: Executed in isolated environments prior to deploying full-scale production fleets for newly integrated languages.
  • Visual Inspection Plates: Forensic multi-tier broadsheets generated to visually inspect conjunct formation, matra placement, and background substrate realism.
  • Diacritic Ownership Gate: An offline reference verification tool used to verify ink pixel containment within token bounding envelopes. (Note: Diacritic ownership verification is run as an offline forensic tool rather than an inline per-sample check inside the cloud production runner).

12. WebDataset Structure & Streaming

BhartiOCR archives use the POSIX WebDataset .tar format. Each sample shares a common key prefix:

  • {sample_key}.webp: WebP encoded image (quality=85)
  • {sample_key}.json: UTF-8 JSON metadata record

12.1 Shard Organization on Hugging Face Hub

All 3,350 WebDataset archives are partitioned by language into subdirectories under data/{language}/ (see Section 5.1 for individual directory mappings). Within each language directory, shards follow the standard naming convention:

data/{language}/{lang}_train_{shard:05d}.tar

Each shard contains exactly 5,000 paired .webp and .json instances (e.g., data/kannada/kan_train_00000.tar contains samples kan_0000000 through kan_0004999).

12.2 Direct HTTP Streaming Example (PyTorch + WebDataset)

import json
import webdataset as wds
from torch.utils.data import DataLoader

# Define shard URL pattern (e.g., Kannada shards on Hugging Face Hub)
shard_url = "https://huggingface.co/datasets/Faizaniqbal/BhartiOCR/resolve/main/data/kannada/kan_train_{00000..00099}.tar"

# Stream shards over HTTP without downloading the full dataset
dataset = (
    wds.WebDataset(shard_url, shardshuffle=True, resampled=False)
    .shuffle(1000)
    .decode("pil")
    .to_tuple("webp", "json")
)

dataloader = DataLoader(dataset, batch_size=32, num_workers=4)

for images, json_bytes_or_dicts in dataloader:
    # images: list of PIL Images
    # json_bytes_or_dicts: paired metadata records with text and bboxes
    for img, meta in zip(images, json_bytes_or_dicts):
        if isinstance(meta, (bytes, str)):
            meta = json.loads(meta)
        print(f"Sample: {meta['sample_key']}, Lang: {meta['lang']}, Tier: {meta['tier']}")
        print(f"Text: {meta['text']}")
        print(f"Tokens: {len(meta['tokens'])}, Canvas: {meta['canvas_size']}")
    break

13. Recommended Dataset Splitting

All 3,350 shards published on the Hugging Face Hub carry _train_ filenames (e.g., hin_train_00000.tar through hin_train_00199.tar). There are currently no separate physical validation or test archives published on the Hub.

Researchers conducting evaluation should create deterministic partitions by slicing shard indices within each language folder:

13.1 Deterministic Shard Slicing Guide (~90% Train / ~5% Validation / ~5% Test)

Language Allocation Total Shards Train Partition Validation Partition Test Partition
200-Shard Languages (hin, mar, urd, ben, tam) 200 Shards 00000..00179 (180 shards, 900K — 90%) Shards 00180..00189 (10 shards, 50K — 5%) Shards 00190..00199 (10 shards, 50K — 5%)
100-Shard Languages (21 languages) 100 Shards 00000..00089 (90 shards, 450K — 90%) Shards 00090..00094 (5 shards, 25K — 5%) Shards 00095..00099 (5 shards, 25K — 5%)
50-Shard Languages (doi, gom, mai, mag, hne) 50 Shards 00000..00043 (44 shards, 220K — 88%) Shards 00044..00046 (3 shards, 15K — 6%) Shards 00047..00049 (3 shards, 15K — 6%)

(Note: For 50-shard languages, integer shard quantization yields an approximate 88% train / 6% validation / 6% test partition).

  • Leakage Considerations: Because upstream source texts were partitioned sequentially into shards, researchers requiring strictly leak-free linguistic evaluation sets should apply document-level deduplication or hash-based text filtering across split boundaries.

14. Provenance & Licensing

BhartiOCR incorporates multiple components with distinct licensing conditions:

14.1 License Framework

Component Source / Typology Governing License Terms & Notes
Pipeline Code & Orchestration BhartiOCR Engine Apache-2.0 Permissive open-source; modification and distribution permitted.
Metadata & Annotations BhartiOCR Annotation Schema Apache-2.0 Token bounding boxes and pipeline metadata released under Apache-2.0.
Typography & Fonts Open-source typefoundries SIL OFL 1.1 / GPL+FE Permissive open-source font licenses allowing embedding and bundling.
Upstream Text (General Prose) Open multilingual text corpora CC-BY-SA 3.0 / 4.0 Attribution; ShareAlike conditions apply to derived textual works.
Upstream Text (Literature & Poetry) Open cultural anthologies Public Domain / MIT Free cultural and academic reuse.
Upstream Text (Dialogue & Transcripts) Open research speech/dialogue CC-BY-4.0 Attribution required.
Upstream Text (Technical & Parallel) Academic parallel corpora Non-Commercial Research Certain upstream technical sentence slices carry non-commercial research conditions (e.g., CC-BY-NC-SA 4.0).

14.2 Licensing and Commercial Compliance Notice

  • License Differentiation: While the synthesis codebase and generated metadata are licensed under Apache-2.0, the underlying textual data includes diverse public and academic corpora. Certain upstream textual source subsets carry non-commercial research licenses (e.g., CC-BY-NC-SA 4.0).
  • Downstream Responsibility: BhartiOCR makes no legal assertion that synthetic rendering or rasterization eliminates upstream copyright or licensing restrictions. Downstream users intending to utilize trained models in commercial settings must independently review upstream corpus terms and, where necessary, filter out subsets derived from non-commercial upstream sources.
  • Hugging Face Hub Metadata: Categorized under license: other to reflect this multi-tier licensing framework.

15. Reproducibility

  • Deterministic Framing: The dataset generation is pseudo-deterministic.
  • Seed Configuration: The pipeline initializes Python random.seed(42) and NumPy np.random.seed(42) at worker start.
  • Reproducibility Scope: Parallel worker pools execute independent shard tasks without per-sample PRNG re-anchoring. Consequently, re-running generation produces statistically and structurally consistent datasets (identical tier distributions, font allocations, and degradation categories), but individual rendered pixel arrays are not guaranteed to be bitwise pixel-identical.
  • Environment: Built using Python 3.10–3.12 with uharfbuzz==0.39.3, freetype-py==2.4.0, Pillow>=10.0.0, opencv-python>=4.8.0, and fonttools>=4.42.0.

16. Limitations

Researchers and practitioners should consider the following technical boundaries:

  1. Synthetic Document Nature: Although the degradation engine simulates paper fibers, ink bleeding, and photographic noise, synthetic images cannot reproduce all idiosyncratic physical anomalies found in natural historical manuscripts (e.g., uneven hand-carved woodblocks, physical water submersion, parchment buckling).
  2. Lossy WebP Compression: Images are encoded as WebP with quality=85. They are not lossless rasters. High-frequency pixel noise undergoes mild lossy compression.
  3. Advance-Width Bounding Boxes: Serialized bounding boxes [x0, y0, x1, y1] are logical token bounding cells derived from HarfBuzz cumulative advance widths and font metric vertical bounds. They do not represent tight connected-component ink contours, character-level boxes, or conjunct-level boxes.
  4. Transform/Geometry Invariance Limitation: The degradation function apply_micro_tilt() applies small affine rotations ($\pm 1.0^\circ$) to image rasters without recomputing serialized bounding box coordinates. Bounding boxes in micro-tilted samples retain their pre-rotation coordinates.
  5. Absence of Pre-Split Validation/Test Archives: All 3,350 shards are published with _train_ filenames on the Hub. Users must implement programmatic shard slicing to create held-out validation and test sets.
  6. Degradation Library vs. Production Subset: While the reference library documents 54 operators, the high-throughput production cloud runner executed a controlled subset (12 substrates, ink bleed, and 7 active transforms).
  7. Linguistic Corpus Boundaries: Lexical diversity is bounded by the source corpora (Wikipedia, OSCAR, Tatoeba, government gazettes). Modern colloquial slang, conversational chat acronyms, and non-standard orthography may be underrepresented.

17. Intended Uses

17.1 Supported Research & Modeling Use Cases

  • Multilingual OCR Pretraining: Large-scale visual pretraining for encoder-decoder models (TrOCR, CRNN, Donut, Nougat, Florence-2, Qwen2-VL) across South Asian writing systems.
  • Document Layout & Reading-Order Research: Intended research exploring layout parsing, multi-column reading order, and block decomposition on broadsheets (Tier 1) and paragraphs (Tier 2). Serialized annotations reflect logical token layout zones rather than semantic segmentation masks or dedicated layout-benchmark labels.
  • Token Localization Research: Exploring token boundary detection, reading-line baseline tracking, and word-level localization. Bounding boxes are derived from HarfBuzz advances and font metrics rather than tight polygon ink ground truth.
  • Controlled Robustness Research: Evaluating model resilience against ink bleed, paper discoloration, stamps, and sensor noise under controlled parameter sweeps.
  • Transfer Learning & Fine-Tuning: Adapting pre-trained vision models to low-resource South Asian languages (e.g., Bodo, Santali, Manipuri, Tulu, Newari).

17.2 Out-of-Scope Uses

  • Evaluating real-world OCR performance solely against synthetic metrics without evaluating on naturally scanned document collections.
  • Automated extraction of legal, clinical, or identity data without human verification.
  • Demographic, religious, or identity profiling based on synthetic text contents.

18. Citation

If you use BhartiOCR in your research, please cite:

@dataset{bhartiocr_2026,
  author       = {Faizan Iqbal},
  title        = {BhartiOCR: A Controlled Synthetic Multilingual OCR Dataset for South Asian Languages},
  year         = {2026},
  publisher    = {Hugging Face},
  url          = {https://huggingface.co/datasets/Faizaniqbal/BhartiOCR}
}

19. Dataset Maintenance & Inquiries

BhartiOCR is actively maintained by Faizan Iqbal.

  • Repository Inquiries & Issues: For questions regarding shard integrity, script support, or annotations, please open a discussion on the Hugging Face Discussion Board.
  • Author / Maintainer: Faizan Iqbal (@Faizaniqbal)
Downloads last month
1,772