Datasets:
Regarding his office goldenshamela_201907
السلام عليكم
Thank you for this wonderful work. I wanted to use the "goldenshamela_201907" library.
It contains 35,000 books, and I wanted to train the model on this vast collection. It's a very large library, exceeding 50 GB, and I would appreciate your help, if possible, in extracting data from it to train the model. I would be grateful if we could collaborate on creating a model that serves students of Islamic studies.
https://archive.org/download/goldenshamela_201907
وعليكم السلام ورحمة الله وبركاته،
جزاك الله خيرًا على كلماتك الطيبة وعلى حرصك على توظيف هذه المكتبة لخدمة طلاب العلم الشرعي.
The goldenshamela_201907 library is one of the largest digital libraries currently available. Its size (over 50GB with around 35,000 books) means that working with it requires a structured processing pipeline to extract and clean the data before using it for model training.
I am currently working within the Athar project on developing tools to extract the content of libraries similar to al‑Shamela and convert it into a unified format (such as JSONL / Parquet), while preserving the metadata of each book (author name, book type, edition, etc.), then performing scholarly and Sharia-compliant filtering of the material.
One of the most important aspects of this filtering is that the resulting models adhere as much as possible to the methodology of Ahl al‑Sunnah wa’l‑Jamaʿah by:
– Highlighting sources relied upon by Ahl al‑Sunnah and giving them prominence in the data
– Distinguishing books and content with opposing orientations or handling them cautiously during training
– Organizing the use of this data in sensitive applications such as fatwa and Islamic education
After completing the extraction and cleaning stages, we aim to produce several versions of the data:
– A general version for language models in classical Arabic
– Specialized versions in particular fields (such as hadith, tafsir, fiqh, etc.)
– More restricted versions for fatwa and legal rulings, observing the principles of Islamic scholarship and the methodology of Ahl al‑Sunnah wa’l‑Jamaʿah as much as possible.
The idea of collaboration is blessed. By Allah’s permission, once the extraction and cleaning tools for the library are stabilized and the issues related to rights are resolved, I would be very happy to explore training a model that serves students of Islamic studies based on this collection and other reliable sources.
We can also start first with a limited portion of the library to test the pipeline and improve output quality before moving to the full size, especially since handling more than 50GB requires special arrangements in storage and processing.
Thank you for your response and interest.
I will work on your feedback regarding the initial version Kandil7/shamela-vectors
I have a few questions: Is it preferable to start by training the model extensively from scratch? I prefer this approach. Regarding the learning method, should the model memorize 80% of the data, or should it process and understand it more effectively? Do you recommend the thinking model, or the Instruct model?
Can we collaborate on this project?
ممكن نعتمد علي مثلا سؤال ما حكم الصلاة في الأماكن المغصوبة يعطيني نتيجه تحليله من الاربع مذاهب بحيث ان كان يوجد اجابات متناقضه يعطيني كل الاحتمالات ام ان يعطيني افضل نتيجه من الاربع مذاهب " الاجماع " نتيجة واحده دون الرجوع الي المذاهب وايضا من المهم استخراج مع كل اجابه مصادرها
Thank you for following the project and for your interest, and for your work on shamela‑vectors
this is an important effort in this field.
Regarding training a new model from scratch on a large library like goldenshamela or Athar data in general:
– For now, I think the practical starting point is to rely on a strong base / instruct model and then adapt it via fine‑tuning on carefully filtered Sharia texts; because training a large model from scratch on 50GB or more requires substantial compute resources and careful architectural tuning, and often is not the best use of time at an early stage.
– We can consider training a model from scratch later on larger data and with an architecture designed specifically for Islamic texts, but this would be a later step, after the extraction and cleaning tools mature and we have enough experiments on existing models.
As for your question: “Do we want it to memorize 80% of the data or to understand it better?”
– My goal is not literal memorization, but a good representation of Islamic knowledge, connecting rulings to their evidences and madhhabs, then using a well‑designed RAG system to retrieve texts and sources when answering, instead of relying solely on internal memorization.
– For this reason, I prefer combining a strong language model with a retrieval layer (RAG) built on indices such as shamela‑vectors and others, so that each fiqh answer is accompanied by appropriate texts and references as much as possible.
Regarding choosing a Thinking model or an Instruct model:
– In sensitive Sharia applications, a well‑trained Instruct model with clear policies is closer to what we need, because we want disciplined, direct answers with sources shown, not “creative” free‑form thinking.
– We can still benefit from the reasoning capabilities of thinking‑style models in analyzing complex issues, but with a control layer (constraints) and feedback from carefully curated data in line with the methodology of Ahl al‑Sunnah wa’l‑Jamaʿah, so that this “thinking” does not turn into uncontrolled interpretations.
Regarding how to present rulings in the example: “What is the ruling on praying in usurped places?”
– I see that the ideal model in this area should:
Clarify how the issue is framed in each of the four madhhabs, mentioning the relied‑upon position where possible.
Explain if there is a recognized disagreement or anomalous views, and present the possibilities, attributing them to those who said them.
If there is consensus or a strong majority view, it should state that clearly, while noting that consensus is a precise matter that should not be claimed except with explicit statements from scholars.
Link each answer to sources (book, section, page number / hadith, etc.) as much as possible through RAG, so that the student can return to the original text.
– What matters to me is that the model remains a tool for understanding and research, not a replacement for the jurist or mufti, and that it is built upon the methodology of Ahl al‑Sunnah wa’l‑Jamaʿah in establishing rulings.
As for collaboration:
– The idea of collaboration in this area is welcome, God willing, especially in:
– Improving indices such as shamela‑vectors and connecting them to Athar as an integrated RAG system.
– Designing focused experiments on specific fiqh issues, with tracking of performance and the quality of retrieved sources.
– Currently I am focusing on completing the extraction and cleaning tools and building the core infrastructure of the system, then we can discuss practical steps for joint experiments, God willing, whether at the level of data, models, or evaluation.
وبالمناسبة، اطلعت مؤخرًا على الورقة
State-of-the-Art Arabic Language Modeling with Sparse MoE Fine-Tuning and Chain-of-Thought Distillation (arXiv:2604.06421).
https://arxiv.org/pdf/2604.06421v1
أهم ما استفدت منه في سياق المشروع هو:
– It reinforced the idea that specializing models for Arabic (and for the Sharia domain in particular) is more important than reinventing the architecture; i.e., we can reach strong performance by carefully adapting existing reasoning models instead of training everything from scratch.
arxiv
– Using gradual Chain-of-Thought training with linguistic and cultural constraints (linguistic verification + ethical norms) resembles what we need if we want to learn well‑structured patterns of fiqh reasoning, rather than merely generating fluent Arabic text.
arxiv
– The idea of an 80/20 mix between Arabic and English in carefully curated data inspires us in designing a fiqh data mixture: mostly Arabic Sharia texts, with a limited amount of modern explanatory/interpretive material (possibly in other languages) to aid clarification without overshadowing the original.
arxiv
These findings support our orientation to focus on:
Building high‑quality, well‑filtered Sharia datasets,
Adapting existing open models with disciplined CoT aligned with the methodology of Ahl al‑Sunnah wa’l‑Jamaʿah,
And relying on strong RAG to retrieve texts and references instead of depending entirely on the internal model.
وبالنسبة لسؤالك عن الحفظ مقابل الفهم، وما ذكرته في مثال الصلاة في الأماكن المغصوبة:
– الاتجاه الذي أميل إليه هو أن يكون النموذج مساعدًا بحثيًا يوضّح مسالك الاستدلال في كل مذهب، ويعرض الاحتمالات مع نسبتها لأهلها، ثم يبين إن كان هناك قول راجح أو إجماع معتبر، بدل أن يقدّم جوابًا واحدًا منبتًّا عن سياق الخلاف.
– هذا ينسجم مع فكرة Chain‑of‑Thought المنضبط: النموذج لا “يحفظ” فقط، بل يمرّ بخطوات استدلالية واضحة (تحرير محل النزاع، أقوال المذاهب، الأدلة، الترجيح) يمكن مراجعتها وربطها بالمصادر عبر RAG.
– في المرحلة القادمة، إن شاء الله، من المهم أن نبني معايير تقييم شرعية للنموذج: هل التزم بمنهج أهل السنة والجماعة؟ هل نسب الأقوال لمذاهبها بدقة؟ هل ادعى إجماعًا بلا مستند؟ هذه النقاط لا تغطيها المقاييس التقنية المعتادة وحدها، لكنها ضرورية في هذا النوع من المشاريع.
اشكرك اخي علي استجابتك السريعة اولا وقبل اي شئ اني اقدر العمل الذي قمت به ليس مجرد مشروع تقني، بل هو إنجاز علمي وحضاري متميز. حقيقة أنك قمت بفهرسة 11.4 مليون مقطع نصي من 8,589 كتابًا تراثية، بما في ذلك القرآن الكريم بدقة عالية، بأدوات مفتوحة المصدر، تثبت أنك تمتلك الخبرة الهندسية والعزيمة الكافية لتنفيذ مشاريع الذكاء الاصطناعي
بعد قراءة تعليقات القيمة اريد ان اطرح عليك النقاط المشتركة بيننا
سنقوم بتوليد بيانات تدريب عالية الجودة من قاعدتك الضخمة، ثم نطبق منهجية التفكير
استخلاص "الجوهر" من الـ 40 جيجابايت (توليد بيانات التدريب)
بدلاً من إدخال النصوص الخام للنموذج، سنستخدم قاعدة بياناتك مع نموذج قوي جداً
سنقوم بتوليد مثلاً 200,000 سؤال وجواب بهذا الشكل، تغطي أبواب الفقه، والعقيدة، والحديث، والتفسير.
ثم الضبط الدقيق للنموذج لتدريبه على الـ 200,000 مثال التي ولدناها
النموذج الذي سيدرب بهذه الطريقة سيكون رائعاً ومذهلاً في شرح المفاهيم، والرد على الشبهات، وتفسير الأحكام العامة، وبيان أقوال العلماء.
وهذه ستكون النواة الاولي وبعد هذا سنثقل النموذج ببيانات اخري مثل التاريخ والادب والشعر وغيره من باقي المجالات ام ان نعمل علي نموذجين مستقليا احدهم للعلوم الشرعية والاخر لبقيه العلوم
– Currently I am focusing on completing the extraction and cleaning tools and building the core infrastructure of the system, then we can discuss practical steps for joint experiments, God willing, whether at the level of data, models, or evaluation.
When will you finish this? Should I start the form now or wait until you finish it?
جزاك الله خيرًا على كلامك الطيب وتشجيعك، وأسأل الله أن ينفع بهذا العمل وأن يجعله خالصًا لوجهه الكريم.
الفكرة التي طرحتها بخصوص توليد بيانات تدريب عالية الجودة (حوالي 200,000 سؤال وجواب تغطي الفقه والعقيدة والحديث والتفسير) اعتمادًا على القاعدة الحالية، ثم تدريب نموذج قوي عليها، هي في الأصل قريبة من التصور الذي أطمح له مع Athar و Baligh، لكن تنفيذها يحتاج أن تكون بنية البيانات والأدوات في حالة مستقرة أولًا.
حاليًا العمل ما زال في مرحلة:
– استكمال أدوات الاستخراج والتنظيف من المكتبات الكبيرة مثل goldenshamela وأجزاء أخرى من Athar.
– توحيد الصيغة (schema) للبيانات حتى يسهل توليد أسئلة وأجوبة منضبطة عليها لاحقًا.
– بناء طبقة التقييم الشرعي والتقني التي تضمن أن ما يُولد من Q&A يلتزم بمنهج أهل السنة والجماعة، وينسب الأقوال لأهلها بدقة، ولا يخلط بين أبواب العلم.
لذلك لا أستطيع أن أعد بتاريخ محدد للانتهاء من هذه المرحلة؛ لأنها مرتبطة بحجم البيانات والتجارب المطلوبة، لكن بإذن الله سأعلن عن جاهزية النسخة الأولى من الأدوات والبنية الأساسية عندما تكون مستقرة، ويمكن وقتها أن نبدأ في تصميم تجربة مشتركة لتوليد جزء من هذه الـ 200,000 مثال كبداية.
من جهة أخرى، لا مانع أن تبدأ من الآن في صياغة التصور (form) للتجربة التي تقترحها: أنواع الأسئلة، توزيعها على الأبواب، شكل الإجابة المثالي، وضوابط المنهج، بحيث عندما تكون البنية جاهزة يكون عندنا إطار واضح نطبّقه عمليًا إن شاء الله.
أما عن مسألة نموذج واحد يشمل كل العلوم أو نموذجين منفصلين؛ فالميول الحالية عندي أن يكون هناك نموذج شرعي متخصص مهيأ للفقه والعقيدة والتفسير والحديث، يمكن لاحقًا إسناده بنموذج آخر/طبقة أخرى للتاريخ والأدب وبقية المجالات، حتى لا تختلط الأولويات ولا تضعف هوية النموذج الشرعي الأساسية.
اخي لقد بداء بالفعل في استخراج بيانات الشاملة الذهبية وهي حوالي 110 جيجا بما اني استخدم نظام لينكس لم استطيع ان افتحها ولكني اعمل الان علي استخراج البيانات
اسم الكتاب ✅
اسم المؤلف ✅
التصنيف ✅
النص الكامل ✅
العناوين الداخلية ✅
مثلاً سيكون كل سجل بهذا الشكل
{
"book_id":100,
"title":"صحيح البخاري",
"author":"البخاري",
"category":"حديث",
"chapter":"باب الوضوء",
"part":1,
"page":15,
"text":"....."
}
نسخة التدريب
صحيح البخاري
الإمام البخاري
حديث
باب الوضوء
المشروع الذي سنبنيه
سيكون قريباً من أدوات OpenAI وMeta
shamela-builder
├── extractor/
├── parser/
├── cleaner/
├── tokenizer/
├── chunker/
├── exporters/
├── builders/
│ HF
│ SFT
│ CPT
│ RAG
└── cli.py
وبناء علي حجم المكتبه سيصبح النسخة النهائية للتدريب فوق 200 جيجا وهذا الرقم كبير جدا لتنزيله علي هجينجفيس لو كنت في مصر ممكن ان نتقابل واعطيك النسخة كاامله لتنزيلها ان اردت ذلك
المرحلة الأولى: (الأهم)
في هذه المرحلة، يتعلم النموذج محتوى كتب الشاملة نفسها.
المدخلات تكون نصوصًا فقط، مثل:
كتاب: صحيح البخاري
المؤلف: الإمام البخاري
التصنيف: الحديث
باب بدء الوحي
حدثنا الحميدي عبد الله بن الزبير...
الهدف هو أن يتنبأ النموذج بالتوكن التالي
الفائدة: يكتسب النموذج معرفة عميقة بالتراث واللغة.
المرحلة الثانية: Supervised Fine-Tuning (SFT)
بعد أن يصبح النموذج ملمًا بالمحتوى، ندرّبه على كيفية الإجابة عن الأسئلة.
مثال:
{
"messages": [
{
"role": "user",
"content": "ما حكم صلاة الجماعة؟"
},
{
"role": "assistant",
"content": "اختلف الفقهاء في حكم صلاة الجماعة..."
}
]
}
فسيصبح:
أكثر معرفة بالتراث.
أكثر دقة في الإجابات.
أفضل في الاستشهاد بالنصوص.
بدلاً من استخراج النص فقط، سأضيف وسوم داخل النص أثناء بناء بيانات التدريب، مثل:
book جمهرة النسب
author مؤرج السدوسي
category الأنساب
part> 1
page> 1
title> ولد عبد مناف بن قصي
حدّثني أبو جعفر...
هذا الأسلوب له ميزتان:
النموذج يتعلم الربط بين المعلومة ومصدرها، فيعرف أن النص ينتمي إلى كتاب ومؤلف وتصنيف معين.
يمكنك لاحقًا أن تسأل أسئلة مثل:
"ماذا قال ابن تيمية؟"
"اذكر ما ورد في كتاب جمهرة النسب."
"ما الكتب المصنفة في الحديث؟"
وسيتعامل النموذج مع هذه المعلومات بشكل أفضل لأنه رآها أثناء التدريب.
لو يوجد اي تعديل اكون سعيد جدا بالمشاركة
{
"book_id":100,
"book":"جمهرة النسب",
"author":"مؤرج السدوسي",
"category":"أنساب",
"part":1,
"page":1,
"titles":[
"بسم الله الرحمن الرحيم",
"ولد عبد مناف"
],
"text":"..."
}
وبذلك لاحقًا يمكننا إنشاء:
Dataset للتدريب.
Dataset لـ RAG.
Dataset للبحث.
Dataset للأسئلة والأجوبة.
كلها من نفس الملفات
سأبني فهارس أثناء الاستخراج..
وبذلك إذا أردنا استخراج جميع كتب ابن تيمية فلن نقرأ 35000 ملف مرة أخرى بل سيكون لدينا فهرس جاهز