Text Generation
Transformers
Safetensors
English
qwen2
text-generation-inference
unsloth
conversational
Instructions to use hozifa1/Faqih-R1-14B-Islamic-AI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hozifa1/Faqih-R1-14B-Islamic-AI with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hozifa1/Faqih-R1-14B-Islamic-AI") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hozifa1/Faqih-R1-14B-Islamic-AI") model = AutoModelForCausalLM.from_pretrained("hozifa1/Faqih-R1-14B-Islamic-AI", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hozifa1/Faqih-R1-14B-Islamic-AI with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hozifa1/Faqih-R1-14B-Islamic-AI" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hozifa1/Faqih-R1-14B-Islamic-AI", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hozifa1/Faqih-R1-14B-Islamic-AI
- SGLang
How to use hozifa1/Faqih-R1-14B-Islamic-AI with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hozifa1/Faqih-R1-14B-Islamic-AI" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hozifa1/Faqih-R1-14B-Islamic-AI", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "hozifa1/Faqih-R1-14B-Islamic-AI" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hozifa1/Faqih-R1-14B-Islamic-AI", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use hozifa1/Faqih-R1-14B-Islamic-AI with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for hozifa1/Faqih-R1-14B-Islamic-AI to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for hozifa1/Faqih-R1-14B-Islamic-AI to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for hozifa1/Faqih-R1-14B-Islamic-AI to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="hozifa1/Faqih-R1-14B-Islamic-AI", max_seq_length=2048, ) - Docker Model Runner
How to use hozifa1/Faqih-R1-14B-Islamic-AI with Docker Model Runner:
docker model run hf.co/hozifa1/Faqih-R1-14B-Islamic-AI
Update comprehensive Model Card (Arabic & English)
Browse files
README.md
CHANGED
|
@@ -1,59 +1,111 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
```python
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
|
|
|
| 32 |
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
- Transformers: 5.5.0
|
| 40 |
-
- Pytorch: 2.11.0
|
| 41 |
-
- Datasets: 4.3.0
|
| 42 |
-
- Tokenizers: 0.22.2
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
title = {{TRL: Transformer Reinforcement Learning}},
|
| 53 |
-
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
|
| 54 |
-
year = 2020,
|
| 55 |
-
journal = {GitHub repository},
|
| 56 |
-
publisher = {GitHub},
|
| 57 |
-
howpublished = {\url{https://github.com/huggingface/trl}}
|
| 58 |
-
}
|
| 59 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- ar
|
| 4 |
+
- en
|
| 5 |
+
license: apache-2.0
|
| 6 |
tags:
|
| 7 |
+
- islamic-ai
|
| 8 |
+
- fiqh
|
| 9 |
+
- comparative-fiqh
|
| 10 |
+
- tafsir
|
| 11 |
+
- hadith
|
| 12 |
+
- deepseek-r1
|
| 13 |
+
- qwen2.5
|
| 14 |
+
- reasoning
|
| 15 |
+
- safetensors
|
| 16 |
+
pipeline_tag: text-generation
|
| 17 |
+
base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-14B
|
| 18 |
+
datasets:
|
| 19 |
+
- hozifa1/faqih_sft_dataset
|
| 20 |
---
|
| 21 |
|
| 22 |
+
# 🕋 Faqih-R1-14B: The Islamic Jurisprudence & Scholarly AI
|
| 23 |
+
### الفقيه الذكي (Faqih-R1): نموذج الذكاء الاصطناعي الموسوعي للفقه المقارن وعلوم الشريعة
|
| 24 |
|
| 25 |
+
<p align="center">
|
| 26 |
+
<img src="https://raw.githubusercontent.com/hozifa460/islamic-content/main/assets/banner.png" alt="Faqih-R1 Banner" width="100%" onerror="this.style.display='none'"/>
|
| 27 |
+
</p>
|
| 28 |
|
| 29 |
+
<p align="center">
|
| 30 |
+
<b>Faqih-R1-14B</b> هو نموذج ذكاء اصطناعي رائد متخصص في <b>الفقه المقارن، علوم القرآن، وتخريج الأحاديث النبوية</b> وفق منهج أهل السنة والجماعة. يجمع بين قوة التفكير والاستدلال العميق لمعمارية <b>DeepSeek-R1-Distill-Qwen-14B</b>، والأمانة العلمية في استعراض أقوال المذاهب الأربعة مع أدلتها.
|
| 31 |
+
</p>
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## ✨ المميزات والقدرات الفقهية (Key Capabilities)
|
| 36 |
+
|
| 37 |
+
* 📚 **الفقه المقارن المعتمد:** تحرير أقوال أئمة المذاهب الأربعة (الحنفية، المالكية، الشافعية، الحنابلة) مع أدلتهم من الكتاب والسنة.
|
| 38 |
+
* 🧠 **الاستدلال والتفكير العميق (`<think>`):** يحلل المسألة الفقهية ويفكك محل النزاع خطوة بخطوة قبل صياغة الجواب.
|
| 39 |
+
* 📜 **تخريج وشرح الأحاديث:** الاستدلال بالأحاديث الصحيحة مع بيان درجتها وحكم المحدثين والفوائد الفقهية.
|
| 40 |
+
* 📖 **التفسير الموضوعي:** ربط الأحكام بالآيات القرآنية بالرسم العثماني وبيان أسباب النزول والمقاصد.
|
| 41 |
+
* 🤲 **الأذكار والأدعية المحققة:** إيراد الأدعية المأثورة بنصوصها وضبطها وتخريجها.
|
| 42 |
+
* 🛡️ **التأدب الفقهي والأمان:** الامتناع عن الإفتاء بغير علم في النوازل المعقدة والتحويل إلى دور الإفتاء المعتمدة.
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## ⚡ التشغيل والاستخدام (Quickstart with Python & Transformers)
|
| 47 |
|
| 48 |
```python
|
| 49 |
+
import torch
|
| 50 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
| 51 |
|
| 52 |
+
MODEL_ID = "hozifa1/Faqih-R1-14B-Islamic-AI"
|
| 53 |
+
|
| 54 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 55 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 56 |
+
MODEL_ID,
|
| 57 |
+
torch_dtype=torch.bfloat16,
|
| 58 |
+
device_map="auto"
|
| 59 |
+
)
|
| 60 |
|
| 61 |
+
SYSTEM_PROMPT = (
|
| 62 |
+
"أنت الفقيه المحقق (Faqih-R1)، نموذج ذكاء اصطناعي إسلامي موسوعي متخصص في الفقه المقارن "
|
| 63 |
+
"والعلوم الشرعية وفق منهج أهل السنة والجماعة. فصّل الأدلة من الكتاب والسنة وأقوال المذاهب الأربعة."
|
| 64 |
+
)
|
| 65 |
|
| 66 |
+
question = "ما حكم تارك الصلاة تكاسلاً عند المذاهب الأربعة مع تفصيل الأدلة والترجيح؟"
|
| 67 |
+
prompt = f"<|im_start|>system\n{SYSTEM_PROMPT}<|im_end|>\n<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant\n<think>\n"
|
| 68 |
|
| 69 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 70 |
+
streamer = TextStreamer(tokenizer, skip_prompt=False)
|
| 71 |
|
| 72 |
+
with torch.no_grad():
|
| 73 |
+
output = model.generate(
|
| 74 |
+
**inputs,
|
| 75 |
+
streamer=streamer,
|
| 76 |
+
max_new_tokens=2048,
|
| 77 |
+
temperature=0.6,
|
| 78 |
+
top_p=0.95,
|
| 79 |
+
do_sample=True,
|
| 80 |
+
)
|
| 81 |
+
```
|
| 82 |
|
| 83 |
+
---
|
| 84 |
|
| 85 |
+
## 🏎️ التشغيل السريع عبر vLLM (High-Throughput Inference)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
+
```bash
|
| 88 |
+
vllm serve hozifa1/Faqih-R1-14B-Islamic-AI \
|
| 89 |
+
--tensor-parallel-size 1 \
|
| 90 |
+
--dtype bfloat16 \
|
| 91 |
+
--max-model-len 8192
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
|
| 96 |
+
## 📦 النسخ المكممة المتاحة (GGUF Quantizations)
|
| 97 |
+
للتشغيل على الأجهزة الشخصية وتطبيقات LM Studio و Ollama، يرجى زيارة المستودع المخصص:
|
| 98 |
+
👉 **[`hozifa1/Faqih-R1-14B-GGUF`](https://huggingface.co/hozifa1/Faqih-R1-14B-GGUF)**
|
| 99 |
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## 📊 بيانات التدريب (Training Data)
|
| 103 |
+
تم تدريب النموذج بالاعتماد على داتا سيت **Faqih Gold SFT v2**:
|
| 104 |
+
👉 **[`hozifa1/faqih_sft_dataset`](https://huggingface.co/datasets/hozifa1/faqih_sft_dataset)**
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
|
| 108 |
+
## ⚖️ إخلاء مسؤولية وضوابط الاستخدام (Fiqh & Ethical Disclaimer)
|
| 109 |
+
1. هذا النموذج مخصص لأغراض **البحث العلمي، المدارسة الفقهية، والمساعدة الاستدلالية**.
|
| 110 |
+
2. لا يُعتبر بديلاً عن الفتوى القضائية الرسمية في قضايا الأحوال الشخصية، الجنايات، والنزاعات المالية المعقدة.
|
| 111 |
+
3. نلتزم بمنهج أهل السنة والجماعة، ولا نتحمل مسؤولية أي سوء استخدام خارج الأطر الشرعية المعتبرة.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|