Qwen3-4B fine-tuned on Islamic Arabic Q&A via QLoRA — merged FP16, ready for direct inference.
This is the canonical, fully merged version of a Qwen3-4B model fine-tuned on 17,944 high-quality Islamic Arabic question-answer pairs spanning Fiqh, Fatwa, Aqeedah, Quran Sciences, and Islamic Finance. The LoRA adapter has been merged into the base weights and saved in FP16; no additional adapter loading is required.
17,944 train / 2,101 val / 1,042 test — Islamic Arabic Q&A pairs
Training Metrics
Loss Curve
Checkpoint
Train Loss
Eval Loss
Step 0 (init)
—
—
Step 843 (final)
1.8918
2.4094 (best)
Token Accuracy
Phase
Token Accuracy
Early training
~50%
End of training
~60%
MCQ evaluation coming soon — a multiple-choice benchmark (Islamics domain) is prepared but requires serving the model via vLLM. Results will be posted here once available.
Usage
Transformers Inference
fromtransformersimportAutoTokenizer,AutoModelForCausalLMimporttorchmodel_id="NightPrince/Qwen3-4B-Islamic-Arabic"tokenizer=AutoTokenizer.from_pretrained(model_id)model=AutoModelForCausalLM.from_pretrained(model_id,torch_dtype=torch.float16,device_map="auto",)SYSTEM_PROMPT=("أنت مساعد عالم إسلامي متخصص. ""أجب على الأسئلة بدقة استناداً إلى القرآن الكريم والسنة النبوية والفقه الإسلامي الكلاسيكي. ""استشهد بالمصادر حيثما أمكن. كن موجزاً لكن شاملاً.")messages=[{"role":"system","content":SYSTEM_PROMPT},{"role":"user","content":"ما حكم الزكاة على المال المدخر؟"},]text=tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True,)inputs=tokenizer(text,return_tensors="pt").to(model.device)withtorch.no_grad():outputs=model.generate(**inputs,max_new_tokens=512,temperature=0.7,top_p=0.9,do_sample=True,)response=tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:],skip_special_tokens=True)print(response)
vLLM Serving
The merged FP16 model is ~7.6 GB. Use at least tensor_parallel_size=2 on 11 GB GPUs (e.g., RTX 2080 Ti), or a single 24 GB+ GPU.
# Install vLLM if needed
pip install vllm
# Serve with tensor parallelism across 2 GPUs
vllm serve NightPrince/Qwen3-4B-Islamic-Arabic \
--dtype float16 \
--tensor-parallel-size 2\
--max-model-len 4096\
--port 8000
Query the running server:
fromopenaiimportOpenAIclient=OpenAI(base_url="http://localhost:8000/v1",api_key="token-abc123")SYSTEM_PROMPT=("أنت مساعد عالم إسلامي متخصص. ""أجب على الأسئلة بدقة استناداً إلى القرآن الكريم والسنة النبوية والفقه الإسلامي الكلاسيكي. ""استشهد بالمصادر حيثما أمكن. كن موجزاً لكن شاملاً.")response=client.chat.completions.create(model="NightPrince/Qwen3-4B-Islamic-Arabic",messages=[{"role":"system","content":SYSTEM_PROMPT},{"role":"user","content":"ما حكم الزكاة على المال المدخر؟"},],max_tokens=512,temperature=0.7,)print(response.choices[0].message.content)
Domain scope: The model is optimized for Islamic Arabic Q&A. General Arabic tasks or non-Islamic domains may show degraded quality compared to the base Qwen3-4B.
Source attribution: While the model is trained to cite sources, citations should be independently verified — the model can produce plausible-sounding but incorrect references.
Classical vs. contemporary Fiqh: The training data emphasizes classical scholarship. Contemporary jurisprudential debates, especially minority or regional opinions, may be underrepresented.
Language: The model performs best in Arabic (Modern Standard and Classical). Responses in other languages are not guaranteed to be accurate or fluent.
Citation
@misc{alnwsany2026qwen3islamicarbic,author={Yahya Alnwsany},title={Qwen3-4B-Islamic-Arabic: QLoRA Fine-Tuning of Qwen3-4B on Islamic Arabic Q\&A},year={2026},howpublished={\url{https://huggingface.co/NightPrince/Qwen3-4B-Islamic-Arabic}},note={Base model: Qwen/Qwen3-4B. Dataset: NightPrince/islamic-arabic-qa.}}
License
This model is released under the Apache 2.0 license, consistent with the base model Qwen/Qwen3-4B. See LICENSE for details.