text stringlengths 0 96 |
|---|
# maktabati.ai — Shamela Indexing Pipeline |
# Install: pip install -r requirements.txt |
# Qdrant vector database client |
qdrant-client>=1.9.0 |
# Embedding model |
transformers>=4.40.0 |
torch>=2.0.0 |
# For GPU (ROCm / AMD): |
# torch is installed via: pip install torch --index-url https://download.pytorch.org/whl/rocm6.2 |
# For NVIDIA (CUDA): |
# pip install torch --index-url https://download.pytorch.org/whl/cu121 |
# Metadata / Parquet support |
polars>=0.20.0 |
# Progress bars |
tqdm>=4.65.0 |
# HuggingFace CLI (for downloading source dataset) |
huggingface-hub>=0.22.0 |
🇬🇧 English
The largest open-source vector database of the complete al-Maktaba al-Shamela (المكتبة الشاملة) Islamic text corpus, prepared for semantic search and Retrieval-Augmented Generation (RAG). Includes the full Quran text (6,236 verses, Hafs 'an 'Asim).
Statistics:
- ~8–11M chunks from 8,589 classical Islamic books (final count pending — indexing in progress)
- 6,236 Quran verses (one verse = one chunk)
- 40 categories covering the full breadth of Islamic scholarship
- Period: 1st century AH to 15th century AH
- Language: Arabic (primary)
⚠️ Dataset upload in progress — indexing is currently running on a local machine. The Parquet files will be uploaded once indexing and HNSW build are complete. This README already reflects the final schema and usage instructions.
Schema is fully consistent with Maktabati/openiti-vectors — same field names, types, and conventions. Both datasets can be queried together seamlessly.
🔍 Live Demo
Try the search demo directly in your browser — no setup required:
👉 maktabati.ai · Shamela Search (coming soon)
Keyword search (author, title, full text). For semantic / vector search, import into Qdrant using the instructions below.
🇸🇦 العربية
أكبر قاعدة بيانات متجهية مفتوحة المصدر للمكتبة الشاملة، تضمّ ما يزيد على 7 ملايين مقطع نصي مستخرج من 8,589 كتابًا من كتب التراث الإسلامي، مُعدَّة للبحث الدلالي وتطبيقات الذكاء الاصطناعي التوليدي (RAG).
تشمل المجموعة كامل القرآن الكريم برواية حفص عن عاصم (6,236 آية) — آية واحدة لكل مدخل — وهو ما يجعل الاسترجاع القرآني دقيقًا على مستوى الآية.
تم التضمين والفهرسة بالكامل على حاسوب شخصي دون أي خدمات سحابية، باستخدام نموذج intfloat/multilingual-e5-base بأبعاد 768 ومسافة كوساين.
الإحصاءات:
- ~8–11 مليون مقطع نصي من 8,589 كتابًا (الفهرسة جارية حاليًا)
- 6,236 آية قرآنية (آية = مقطع واحد)
- 40 تصنيفًا تغطي علوم الإسلام كاملةً
- النصوص من القرن الأول إلى الخامس عشر الهجري
- منجز على حاسوب شخصي — دون خدمات سحابية
🇩🇪 Deutsch
Die größte Open-Source-Vektordatenbank des vollständigen al-Maktaba al-Shamela-Korpus islamischer Texte, vorbereitet für semantische Suche und Retrieval-Augmented Generation (RAG). Enthält den vollständigen Korantext (6.236 Verse, Hafs 'an Asim).
Statistiken:
- ~8–11 Millionen Textabschnitte aus 8.589 klassischen islamischen Büchern
- 6.236 Koranverse (ein Vers = ein Abschnitt)
- 40 Kategorien — das gesamte Spektrum der islamischen Wissenschaften
- Zeitraum: 1. bis 15. Jahrhundert n. H.
- Sprache: Arabisch
Vollständig eingebettet und indiziert auf einem handelsüblichen Heimcomputer ohne Cloud-Dienste. Das Schema ist konsistent mit Maktabati/openiti-vectors.
🇹🇷 Türkçe
al-Maktaba al-Shamela İslami metin külliyatının tamamına ait en büyük açık kaynaklı vektör veritabanı; anlamsal arama ve Üretim Destekli Geri Getirme (RAG) için hazırlanmıştır. Tam Kur'an metnini içermektedir (6.236 ayet, Hafs rivayeti).
İstatistikler:
- 8.589 klasik İslami kitaptan ~8–11 milyon metin parçası
- 6.236 Kur'an ayeti (bir ayet = bir parça)
- 40 kategori — İslam ilimlerinin tüm alanlarını kapsar
- Dönem: Hicri 1. ila 15. yüzyıl
- Dil: Arapça
Bulut hizmeti kullanılmadan, tüketiciye yönelik bir bilgisayarda tamamen gömülü ve dizine eklenmiştir. Şema Maktabati/openiti-vectors ile tam uyumludur.
🇮🇷 فارسی
بزرگترین پایگاه داده برداری متنباز از مجموعه کامل المکتبة الشاملة، آمادهشده برای جستجوی معنایی و تولید متن مبتنی بر بازیابی (RAG). شامل متن کامل قرآن کریم (۶٬۲۳۶ آیه، روایت حفص از عاصم) میباشد.
آمار:
- ~۸ تا ۱۱ میلیون قطعه متنی از ۸٬۵۸۹ کتاب اسلامی کلاسیک
- ۶٬۲۳۶ آیه قرآنی (هر آیه = یک قطعه)
- ۴۰ دستهبندی — پوشش کامل علوم اسلامی
- دوره: قرن اول تا پانزدهم هجری
- زبان: عربی
بهطور کامل بر روی یک رایانه شخصی و بدون استفاده از خدمات ابری پردازش شده است. طرحواره با Maktabati/openiti-vectors کاملاً سازگار است.
Technical Details
| Parameter | Value |
|---|---|
| Embedding Model | intfloat/multilingual-e5-base |
| Vector Dimension | 768 |
| Distance Metric | Cosine |
| Chunk Size | 512 tokens |
| Overlap | 50 tokens |
| Tokenizer | XLM-RoBERTa (via multilingual-e5-base) |
| Passage Prefix | passage: (indexing) |
| Query Prefix | query: (search) |
Indexed and embedded on a consumer-grade home PC:
| Component | Spec |
|---|---|
| CPU | AMD Ryzen 9 5900X |
| RAM | 32GB DDR4 |
| GPU | AMD Radeon RX 6900 XT (16GB VRAM, ROCm) |
No cloud services used; fully reproducible on consumer hardware.
Dataset Fields
Common Fields (identical with Maktabati/openiti-vectors)
| Field | Type | Description |
|---|---|---|
text |
string | Original chunk text with full tashkeel |
text_norm |
string | Normalized text (no tashkeel, unified alef variants) |
sha256 |
string | SHA-256 hash of chunk text (64 chars) |
author |
string | Arabic author name (e.g. ابن كثير) |
title |
string | Arabic book title (e.g. تفسير ابن كثير) |
death_year |
int32 | Author death year in AH |
language |
string | "ar" |
page |
string | Page reference — books: "V02P045", Quran: "2:255" |
char_start |
int32 | Character offset start within page text |
char_end |
int32 | Character offset end within page text |
chunk_no |
int32 | Chunk index within page |
indexed_at |
string | ISO 8601 timestamp of indexing |
Shamela-specific Fields
| Field | Type | Description |
|---|---|---|
source |
string | "shamela" or "quran" |
book_id |
int32 | Shamela book ID |
page_id |
int32 | Global page ID |
page_num |
int32 | Page number within volume |
part |
int32/string | Volume/part number (numeric or Arabic label e.g. "المقدمة") |
category_id |
int32 | Shamela category ID |
category_name_ar |
string | Category name in Arabic (e.g. كتب السنة) |
sequence_num |
int32 | Reading order sequence number within book |
book_type_label |
string | Book type (كتاب، رسالة، ...) |
Quran-specific Additional Fields
| Field | Type | Description |
|---|---|---|
surah_num |
int32 | Surah number (1–114) |
surah_name |
string | Surah name in Arabic (e.g. البقرة) |
ayah_num |
int32 | Ayah number within surah |
global_id |
int32 | Sequential Quran verse ID (1–6236) |
Note on Quran
text_norm: Unlike book entries,text_normis identical totextfor Quran verses — no normalization applied, preserving ة and ى.
Source Data
- Shamela corpus: AuthenticIlm/Shamela4_Full_DB
- Quran text: Hafs 'an 'Asim (رواية حفص عن عاصم), Majma' al-Malik Fahd (مجمع الملك فهد لطباعة المصحف الشريف), via Shamela4_Full_DB
- Quran verification: Spot-checked Al-Fatiha, Ayat al-Kursi (2:255), Al-Ikhlas, An-Nas — all correct
Usage
Import into Qdrant
import pyarrow.parquet as pq
from pathlib import Path
from qdrant_client import QdrantClient
from qdrant_client.models import (
VectorParams, Distance, PointStruct,
HnswConfigDiff, OptimizersConfigDiff
)
client = QdrantClient("http://localhost:6333")
# Create collection (vectors on disk, HNSW in RAM)
client.create_collection(
collection_name="shamela",
vectors_config=VectorParams(size=768, distance=Distance.COSINE, on_disk=True),
hnsw_config=HnswConfigDiff(m=16, ef_construct=100, on_disk=False),
optimizers_config=OptimizersConfigDiff(indexing_threshold=0),
on_disk_payload=True
)
# Import Parquet files
for path in sorted(Path("shamela-vectors").glob("*.parquet")):
table = pq.read_table(path)
points = [
PointStruct(
id=row["id"],
vector=row["vector"],
payload={k: row[k] for k in table.schema.names if k not in ("id", "vector")}
)
for row in table.to_pylist()
]
client.upsert(collection_name="shamela", points=points, wait=False)
# Enable HNSW indexing after upload
client.update_collection(
collection_name="shamela",
optimizers_config=OptimizersConfigDiff(
indexing_threshold=1,
max_optimization_threads=4
)
)
# Wait until indexed_vectors_count == points_count
Semantic Search
from transformers import AutoTokenizer, AutoModel
import torch
from qdrant_client import QdrantClient
model_name = "intfloat/multilingual-e5-base"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)
model.eval()
def embed(text: str) -> list:
# Important: use "query: " prefix for search queries
encoded = tokenizer(f"query: {text}", return_tensors="pt",
truncation=True, max_length=512)
with torch.no_grad():
output = model(**encoded)
emb = output.last_hidden_state.mean(dim=1)
return torch.nn.functional.normalize(emb, p=2, dim=1)[0].tolist()
client = QdrantClient("http://localhost:6333")
vector = embed("ما حكم الصلاة في الأماكن المغصوبة")
results = client.search(
collection_name="shamela",
query_vector=vector,
limit=10,
with_payload=True
)
for r in results:
print(f"Score: {r.score:.3f} | {r.payload['author']} | {r.payload['title']}")
print(r.payload['text'][:200])
print()
Filter by Source or Category
from qdrant_client.models import Filter, FieldCondition, MatchValue
# Quran only
results = client.search(
collection_name="shamela",
query_vector=vector,
query_filter=Filter(must=[
FieldCondition(key="source", match=MatchValue(value="quran"))
]),
limit=10
)
# Hadith books only (كتب السنة)
results = client.search(
collection_name="shamela",
query_vector=vector,
query_filter=Filter(must=[
FieldCondition(key="category_name_ar",
match=MatchValue(value="كتب السنة"))
]),
limit=10
)
# Filter by author
results = client.search(
collection_name="shamela",
query_vector=vector,
query_filter=Filter(must=[
FieldCondition(key="author", match=MatchValue(value="ابن كثير"))
]),
limit=10
)
Related Datasets
- Maktabati/openiti-vectors — OpenITI corpus vectors, same schema (Arabic, Persian, Turkish, Urdu)
License
The texts are from al-Maktaba al-Shamela and subject to their respective licenses. The embeddings and metadata in this dataset are released under CC BY 4.0.
Citation
@dataset{maktabati_shamela_vectors_2026,
title = {Shamela Vector Database},
author = {maktabati.ai},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/datasets/Maktabati/shamela-vectors},
note = {Complete al-Maktaba al-Shamela corpus: 8,589 books + 6,236 Quran verses,
embedded with intfloat/multilingual-e5-base on consumer hardware}
}
- Downloads last month
- 15