Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

OpenITI BM25 Index

BM25 full-text search index for the OpenITI corpus (release 2025.1.9), built on SQLite FTS5. Part of the maktabati.ai Islamic RAG pipeline.

Designed to pair with Maktabati/openiti-vectors for hybrid retrieval (BM25 + Dense + RRF fusion).


Statistics

Source OpenITI 2025.1.9
Files indexed ~8,943 (one edition per work)
Languages Arabic (ar), Persian (fa), Turkish (tr), Urdu (ur)
Chunk size 512 tokens, 50-token overlap
Tokenizer intfloat/multilingual-e5-base

Files

File Description
bm25_openiti.db.zst.aa SQLite FTS5 database, zstd-compressed, split into 500 MB parts
build_bm25_openiti.py Build script — multiprocessing, resume-capable, CPU-only
requirements.txt Python dependencies

Download size: 5,4 GB compressed · Uncompressed: 23,3 GB

Download & Reconstruct

Command line:

pip install huggingface_hub
huggingface-cli download Maktabati/openiti-bm25 --repo-type dataset --local-dir .
cat bm25_openiti.db.zst.* | zstd -d -o bm25_openiti.db

Python:

from huggingface_hub import snapshot_download
import subprocess, pathlib

local = snapshot_download("Maktabati/openiti-bm25", repo_type="dataset")
parts = sorted(pathlib.Path(local).glob("bm25_openiti.db.zst.*"))
with open("bm25_openiti.db", "wb") as out:
    subprocess.run(["zstd", "-d", "--stdout"] + [str(p) for p in parts], stdout=out)

Install zstd: sudo apt install zstd / brew install zstd


Schema

CREATE VIRTUAL TABLE chunks USING fts5(
    text_norm,               -- normalized Arabic text (FTS5-indexed)
    point_id   UNINDEXED,    -- UUID → matches Qdrant point IDs in openiti-vectors
    author     UNINDEXED,    -- author name (Arabic preferred, Latin fallback)
    title      UNINDEXED,    -- work title
    file_name  UNINDEXED,    -- OpenITI filename (e.g. 0310Tabari.TarikhIslam.JK000001-ara1)
    page       UNINDEXED,    -- page marker (e.g. PageV01P042)
    death_year UNINDEXED,    -- author death year (Hijri)
    language   UNINDEXED,    -- ar / fa / tr / ur
    tokenize = 'unicode61'
);

The point_id is a deterministic 32-char hex string:

sha256(f"{full_file_path}#{chunk_nr}").hexdigest()[:32]

This matches exactly the Qdrant point IDs in openiti-vectors.


Arabic Normalization

Applied to text_norm at index time and to queries at search time:

  • Remove all diacritics (harakat, tanwin, shadda, Quranic signs …)
  • أإآٱ → ا · ة → ه · ى → ي
  • Remove OpenITI markup: PageV##P###, ~~, # headings
  • Collapse whitespace

Usage

Standalone BM25

import sqlite3, re

def normalize_arabic(text):
    text = re.sub(r'[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]', '', text)
    text = re.sub(r'[أإآٱ]', 'ا', text)
    text = text.replace('ة','ه').replace('ى','ي')
    text = re.sub(r'PageV\d+P\d+|~~|#\s*', '', text)
    return re.sub(r'\s+', ' ', text).strip()

conn  = sqlite3.connect("bm25_openiti.db")
query = normalize_arabic("ما حكم الصلاة بغير وضوء")
tokens    = [w for w in query.split() if w]
fts_query = " OR ".join('"' + w.replace('"','""') + '"' for w in tokens)

rows = conn.execute(
    "SELECT point_id, author, title, file_name, page "
    "FROM chunks WHERE text_norm MATCH ? ORDER BY rank LIMIT 20",
    (fts_query,)
).fetchall()

Hybrid Search (BM25 + Dense + RRF)

RRF formula: score(d) = Σ 1 / (k + rank_i), k = 60.


Edition Selection

One edition per work is selected from the TSV metadata:

  1. Primary edition (status = pri) preferred
  2. Fallback: longest edition by character count

This matches exactly the selection in index_openiti_v3.py (Qdrant indexer), ensuring UUID consistency.


Rebuild

# Build index (resume-capable, multiprocessing)
python build_bm25_openiti.py

# Compress and split for upload
bash compress_split_openiti.sh

Relation to openiti-vectors

openiti-bm25 openiti-vectors
Search type Lexical (BM25) Semantic (Dense)
Backend SQLite FTS5 Qdrant
Model intfloat/multilingual-e5-base
UUID scheme sha256(path#chunk_nr)[:32] identical

License

Text content from OpenITI — CC BY 4.0. Index structure and scripts: CC BY-SA 4.0.

Downloads last month
31