BanglaDocIndex / README.md
NafisAshraf's picture
Dataset card
8f4b073 verified
|
Raw History Blame Contribute Delete
14 kB
metadata
license: odc-by
language:
  - bn
pretty_name: BanglaDocIndex
size_categories:
  - 10M<n<100M
task_categories:
  - image-to-text
  - feature-extraction
tags:
  - bangla
  - bengali
  - documents
  - ocr
  - pdf
  - embeddings
  - internet-archive
  - common-crawl
configs:
  - config_name: pages
    default: true
    data_files:
      - split: train
        path: core/catalog/pages/*/*/*.parquet
  - config_name: documents
    data_files:
      - split: train
        path: core/catalog/documents/*/*/*.parquet
  - config_name: embeddings
    data_files:
      - split: train
        path: core/derived/embeddings/model=embeddinggemma-2/tokens=70/v=1/*.parquet
  - config_name: source_items
    data_files:
      - split: train
        path: core/catalog/source_items/*/*/*.parquet
  - config_name: shards
    data_files:
      - split: train
        path: core/catalog/shards/*/*/*.parquet

BanglaDocIndex

An index of 19,873,418 Bangla document pages from 525,618 PDFs: where every page comes from, what is known about it, and an image embedding for every page.

BanglaDocIndex catalogues the Bangla PDFs that can be found on the Internet Archive, in FinePDFs (PDFs found by Common Crawl) and on the NCTB textbook site. Every page was rendered once and embedded with EmbeddingGemma 2, so the whole collection can be searched, clustered and sampled without downloading a single PDF.

No page images are included. Each page points back to its source document, and the fetch_pages.py script rebuilds any page image from its source, checked against the recorded hashes.

At a glance

Source Fetched from Documents Pages
Internet Archive archive.org 68,102 16,697,212
FinePDFs (ben_Beng) Common Crawl WARC record 426,967 1,138,687
FinePDFs (ben_Beng) original website ("live") 30,440 2,020,790
NCTB textbooks (2026, classes 6–10) NCTB download links 109 16,729
Total 525,618 19,873,418

A further 14,811 documents are byte-identical copies of another document (duplicate_of); they are listed in documents but their pages appear only once.

Table (config) Rows Files Size
pages 19,873,418 4,307 1.19 GiB
documents 540,429 4,369 187 MiB
embeddings 19,873,418 4,307 21.3 GiB
source_items 630,804 714 128 MiB
shards 5,198 4,307 16 MiB

Quick start

from datasets import load_dataset

docs = load_dataset("OpenCR-lab/BanglaDocIndex", "documents", split="train")   # 187 MiB
pages = load_dataset("OpenCR-lab/BanglaDocIndex", "pages", split="train", streaming=True)
emb = load_dataset("OpenCR-lab/BanglaDocIndex", "embeddings", split="train", streaming=True)

print(next(iter(pages)))

Tables join on doc_id (documents, pages) and page_id (pages, embeddings). Each embedding file covers exactly the pages of one shard, so pages.shard_key and the embedding file name match: blobs/pages/.../shard-000123-ab12cd34.tar ↔ .../v=1/shard-000123-ab12cd34.parquet.

Downloading part of the index

split="train[:10%]" still downloads the whole table first. To take only part:

# Stream: rows arrive as you read them; stop whenever you like.
first_1000 = list(load_dataset("OpenCR-lab/BanglaDocIndex", "pages", split="train",
                               streaming=True).take(1000))

# Pick files: e.g. only the NCTB pages, or a few embedding files.
nctb = load_dataset("OpenCR-lab/BanglaDocIndex",
                    data_files="core/catalog/pages/source=nctb/*/*.parquet", split="train")
some_emb = load_dataset("OpenCR-lab/BanglaDocIndex",
                        data_files="core/derived/embeddings/model=embeddinggemma-2/tokens=70/v=1/shard-00000*.parquet",
                        split="train")

Command line, by folder:

hf download OpenCR-lab/BanglaDocIndex --repo-type dataset --local-dir BanglaDocIndex \
    --include "core/catalog/*"                 # the catalog only (1.5 GiB)

SQL over the Hub with DuckDB, which reads only the columns and files a query needs:

import duckdb
duckdb.sql("""
    SELECT d.source, d.fetch_method, count(*) AS pages
    FROM 'hf://datasets/OpenCR-lab/BanglaDocIndex/core/catalog/pages/**/*.parquet' p
    JOIN 'hf://datasets/OpenCR-lab/BanglaDocIndex/core/catalog/documents/**/*.parquet' d USING (doc_id)
    GROUP BY ALL ORDER BY pages DESC
""").show()

Using the embeddings

import numpy as np
from datasets import load_dataset

part = load_dataset("OpenCR-lab/BanglaDocIndex",
                    data_files="core/derived/embeddings/model=embeddinggemma-2/tokens=70/v=1/shard-00001*.parquet",
                    split="train").with_format("numpy")
ids, vectors = part["page_id"], part["embedding"].astype(np.float32)   # (n, 768), unit length
nearest = np.argsort(-(vectors @ vectors[0]))[:10]                      # pages most similar to the first
print(ids[nearest])

Getting the page images

git clone https://github.com/OpenCR-lab/BanglaDocIndex && cd BanglaDocIndex && uv sync
uv run python examples/fetch_pages.py f0747b20d08a09027bbf42ea8f0dcc35-p000001 --out pages/
uv run python examples/fetch_pages.py --doc f0747b20d08a09027bbf42ea8f0dcc35 --out pages/

The script fetches the identical PDF, checks its SHA-256 (documents.pdf_sha256) and renders the pages with the recorded recipe (core/recipes/). Given a local copy of the catalog (--catalog) it also checks every image against pages.image_sha256 and pages.phash. By hand, per documents.fetch_method:

fetch_method Where the PDF is
http (Internet Archive, NCTB) source_url
cc_warc bytes warc_offset … warc_offset + warc_length - 1 of https://data.commoncrawl.org/<warc_path> (one gzipped WARC record holding the PDF)
live source_url on the original website; it may have changed or gone (check pdf_sha256)

Page page_number (1-based) of that PDF is page <doc_id>-p<page_number:06d>. Pages were rendered at 150 DPI, never above a scan's native resolution (native_dpi), at most 8 MP, as RGB JPEG quality 88.

Tables

All tables also carry ingest_run_id (the run that wrote the row; see core/runs/) and schema_version.

pages: one row per page

Column Meaning
page_id <doc_id>-pNNNNNN, 1-based page number
doc_id, source, page_number the document and the page's position in it
width, height, dpi, native_dpi rendered size in pixels, rendering DPI, the scan's own DPI (scans only)
render_recipe rendering recipe, defined in core/recipes/<render_recipe>.json
image_sha256, phash SHA-256 of the rendered JPEG and a 64-bit perceptual hash (DCT), to check rebuilt images
split train / val / test (90 / 5 / 5 %), assigned per document from a hash, so all pages of a document share a split
shard_key, member, offset, length location in the private image archive. Not publicly resolvable; kept so the files are identical to the archive's catalog. shard_key names the embedding file

documents: one row per PDF

Column Meaning
doc_id hash of source, source item and file name
source, source_item_id, source_filename e.g. ia, the Internet Archive identifier, the PDF's file name
source_url, fetch_method, warc_path, warc_offset, warc_length where the PDF was fetched (see above)
title, creator, pub_year, language descriptive metadata, as given by the source
pdf_bytes, pdf_sha256, source_md5 the fetched PDF's size and hash, and the source's own checksum where published
page_count pages in the PDF
duplicate_of set when an identical PDF was already catalogued; its pages are not repeated
license_url, rights_raw licence and rights statements from the source, verbatim
source_metadata the source's metadata record for this file (JSON)
kept_pdf_shard, kept_pdf_offset, kept_pdf_length copy of the PDF in the private archive (live websites and NCTB). Not publicly resolvable
split as in pages

embeddings: one row per page

Column Meaning
page_id joins with pages
embedding 768 × float16, L2-normalised

Model google/embeddinggemma-2 through sentence-transformers, image input, a budget of 70 image tokens per page, bfloat16 on an NVIDIA L4. Large scans were decoded at reduced JPEG scale with the long side at least 1,536 px before the model's own resize (cosine similarity to full-size decoding: mean 1.000, 1st percentile ≥ 0.995 on a test set). The folder name records the model, the token budget and the version (model=…/tokens=70/v=1), so embeddings made with other settings can sit beside these later.

source_items: everything discovered

One row per item the discovery step looked at, whether or not it produced a document: status is accepted, no_pdf, skipped or error. It includes the script composition of the item's text where the source provides one (script_bengali, script_latin, …, script_method) and the source's metadata record verbatim (raw_metadata, JSON). An item that failed and was retried has one row per attempt (1,775 Internet Archive items, mostly HTTP 500 and 401 responses); the row with the latest checked_at is the final status.

shards: the archive's tar files

One row per page or PDF tar in the private archive (kind = pages or pdfs), with size, SHA-256, MD5 and member count (two members per page: the JPEG and a small JSON). Useful mainly to map an embedding file to its pages.

Other files

Path Content
core/recipes/*.json the rendering recipe: DPI rule, pixel cap, JPEG settings, pdfium / Pillow / libjpeg-turbo versions
core/runs/*.json one record per ingestion run: code commit, settings, counters
core/sources/finepdfs/manifest-*.parquet the FinePDFs ben_Beng document list this index started from

Licensing

The index itself (catalog, metadata compilation and embeddings) is released under the Open Data Commons Attribution License (ODC-By) 1.0, the licence also used by FineWeb and FinePDFs. Please credit BanglaDocIndex and its sources.

The source documents are not part of this release and keep their own licences. What their sources state, by pages:

Licence stated by the source Documents Pages
Public domain mark / CC0 (Internet Archive) 5,088 1,172,077
CC BY / CC BY-SA (Internet Archive) 153 7,574
Non-commercial CC (NC, without ND) (Internet Archive) 249 40,890
No-derivatives CC (ND) (Internet Archive) 1,662 354,183
NCTB textbooks (government free distribution) 109 16,729
Not stated (Internet Archive) 60,950 15,122,488
Not stated (FinePDFs: web PDFs; see FinePDFs' terms) 457,407 3,159,477

documents.license_url and documents.rights_raw hold the statements per document. Anyone who rebuilds page images is responsible for respecting the licence of each document.

The embeddings were produced with google/embeddinggemma-2, which is provided under the Gemma Terms of Use.

Removal requests. If you are a rights holder and want a document removed from the index, open an issue at github.com/OpenCR-lab/BanglaDocIndex/issues with the doc_id or source URL.

How it was built

  1. Discovery. Internet Archive: every item tagged Bengali, kept when at least 80% of its text's letters are Bengali script. FinePDFs: every ben_Beng document. NCTB: the 2026 secondary textbooks (classes 6–10).
  2. Fetching. Internet Archive and NCTB over HTTP; FinePDFs from the Common Crawl WARC record when the crawl stored the whole PDF, otherwise from the live website. Byte-identical PDFs are catalogued once (duplicate_of).
  3. Rendering. pypdfium2, one JPEG per page (recipe above). Pages pdfium could not render are left out; they show up as gaps in page_number.
  4. Catalog. A row reaches the catalog only after its page images are safely stored.
  5. Embedding. Every page image, on Colab L4 GPUs.

Ingestion ran 2026-10-23 to 2026-10-28 on Google Cloud; embedding finished 2026-11-12. The code, design record and operating notes are on GitHub.

Known limitations

  • Mostly Internet Archive. 84% of pages come from Internet Archive scans, many of them older books; modern born-digital documents come mainly from FinePDFs.
  • Live documents can disappear. 2.02M pages were fetched from the original websites; some of those PDFs will change or vanish, so their images may no longer be rebuildable.
  • Licences are mostly unstated. Most sources give no licence; see the table above.
  • Metadata as given. Titles, creators and years come from the sources unchanged and are incomplete (pub_year is set for 48,434 documents).
  • Catalog correction. One catalog part (3,001 pages of one shard) was written twice after a crash during ingestion; the duplicate was removed before release.

Citation

@misc{ashraf2026bangladocindex,
  title        = {BanglaDocIndex: An Index of 19.9 Million Bangla Document Pages},
  author       = {Ashraf, Nafis},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/datasets/OpenCR-lab/BanglaDocIndex}}
}