初始化项目,由ModelHub XC社区提供模型

Model: NightPrince/Muslim-6B-PRO
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-08-29 11:48:16 +08:00
commit ecaf4c12a0
10 changed files with 404 additions and 0 deletions

38
.gitattributes vendored Normal file
View File

@@ -0,0 +1,38 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text
muslim-6b-pro-banner-dark.png filter=lfs diff=lfs merge=lfs -text
muslim-6b-pro-banner-light.png filter=lfs diff=lfs merge=lfs -text

189
README.md Normal file
View File

@@ -0,0 +1,189 @@
---
license: apache-2.0
language:
- ar
- en
base_model: Applied-Innovation-Center/Karnak-6B-v1.0
pipeline_tag: text-generation
library_name: transformers
tags:
- text-generation
- causal-lm
- arabic
- islamic
- tool-calling
- lora
- peft
- qwen3
- voice-assistant
---
<p align="center">
<img src="https://huggingface.co/NightPrince/Muslim-6B-PRO/resolve/main/muslim-6b-pro-banner-light.png" alt="Muslim-6B-PRO" width="100%" />
</p>
# Muslim-6B-PRO
**Muslim-6B-PRO** is a behavior-tuned Islamic voice-assistant model, fine-tuned from
[Karnak-6B-v1.0](https://huggingface.co/Applied-Innovation-Center/Karnak-6B-v1.0) (a
depth-extended Qwen3-4B-Instruct-2507) to serve as the reasoning core of **Muslim**, a
voice-first Islamic assistant. It is trained for tool-call routing, persona/scope discipline,
and calibrated general Islamic knowledge — not for reciting scripture from memory.
## Model Details
| | |
|---|---|
| **Base model** | [Karnak-6B-v1.0](https://huggingface.co/Applied-Innovation-Center/Karnak-6B-v1.0) (Qwen3 architecture) |
| **Parameters** | 5.94B |
| **Layers** | 54 |
| **Hidden size** | 2,560 |
| **Attention heads** | 32 (8 KV heads, GQA) |
| **Vocabulary** | 192,728 |
| **Context length** | 262,144 tokens |
| **Fine-tuning method** | QLoRA (4-bit NF4 base, fp16 compute) |
| **License** | Apache 2.0 |
| **Languages** | Arabic, English |
## Key Capabilities
- **Reliable tool-call routing** across the full Qur'an/hadith/tafsir/fatwa retrieval toolset
(31 tools, including mcp.tafsir.net's 17 tools, IslamQA's 5 tools, and local Qur'an audio
playback), with schemas verified against the live tool servers rather than assumed.
- **Clean, standards-correct tool-call JSON** — `tool_call.arguments` decodes with a single
`json.loads()`, matching the Hermes-style format used by the base Qwen3 model.
- **Full 114-surah coverage**, including alternate/colloquial surah names and named-ayah
nicknames (e.g. آية الكرسي, سورة براءة, سورة تبارك), each verified against real scholarly
source text to avoid ambiguous name→number mappings.
- **Calibrated general Islamic knowledge** — Seerah, stories of the prophets, aqeedah basics,
broad fiqh concepts, akhlaq, foundational history, and comparative/interfaith framing, with
appropriate hedging on genuinely contested specifics rather than flat assertions.
- **Persona and scope discipline**, including resistance to adversarial attempts to override
its identity or push it outside its intended scope.
## Intended Use
Muslim-6B-PRO is trained on **behavior**, not memorized facts, for anything requiring
exact, source-cited text — Qur'an wording, hadith matn/isnad, tafsir attribution. Those are
retrieved at inference time via tool calls, never generated from memory, because language
models reliably hallucinate scripture when asked to recite it directly. The one exception is
well-established, broadly-agreed general Islamic knowledge with no dedicated retrieval tool
(Seerah, stories of the prophets, aqeedah basics, broad fiqh concepts, akhlaq, foundational
history, comparative/interfaith framing) — there, the model is trained for calibrated tone and
appropriate hedging on contested specifics, not fact injection.
**This model is designed to be served with a tool-calling layer** (Qur'an/hadith/tafsir
retrieval, audio playback) and a system prompt defining its persona and scope. It is not
intended as a general-purpose scripture-reciting or fatwa-issuing model on its own.
## Quick Start
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "NightPrince/Muslim-6B-PRO"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto")
messages = [
{"role": "system", "content": "<your Muslim agent system prompt>"},
{"role": "user", "content": "ما هي آية الكرسي؟"},
]
inputs = tokenizer.apply_chat_template(
messages, tools=your_tool_schemas, add_generation_prompt=True,
return_tensors="pt", return_dict=True,
).to(model.device)
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
### Tool-calling format
Uses the same Hermes-style `<tool_call>` format as the base Qwen3 model. Bind your tool
schemas via the standard `tools=` argument to `apply_chat_template`. `tool_call.arguments`
decodes cleanly with a single `json.loads()` call.
### Try it live
**[huggingface.co/spaces/NightPrince/muslim-6b-pro-demo](https://huggingface.co/spaces/NightPrince/muslim-6b-pro-demo)**
— a free ZeroGPU chat demo with **real tool-calling**: it actually calls mcp.tafsir.net,
islamqa-mcp.org, and real Qur'an audio CDNs live, instead of a scripted response. Also exposes an
MCP server endpoint.
### GGUF quantizations
Quantized GGUF builds (Q2_K through Q8_0, plus F16) for `llama.cpp`-based local inference are
published separately at **[NightPrince/Muslim-6B-PRO-GGUF](https://huggingface.co/NightPrince/Muslim-6B-PRO-GGUF)**.
## Training Data
2,731 examples (59% tool-calling traces), from three ground-truth-checked sources: hand-curated
examples, real production voice-session turns, and real tool-augmented conversations — each
example checked against source-of-truth references, with anything that couldn't be verified
mechanically excluded rather than guessed at.
| Behavior | Count | Description |
|---|---|---|
| B1 | 1,943 | Tool routing |
| B2 | 42 | Scripture-audio guardrail |
| B3 | 271 | Persona/identity, incl. adversarial-override resistance |
| B4 | 63 | Scope discipline |
| B5 | 167 | Measured fiqh rulings |
| B6 | 22 | English / mixed-language |
| B7 | 66 | Seerah |
| B8 | 78 | Stories of the prophets |
| B9 | 21 | Aqeedah |
| B10 | 26 | Broad fiqh concepts |
| B11 | 14 | Akhlaq |
| B12 | 11 | Islamic history |
| B13 | 7 | Comparative / interfaith |
## Training Procedure
- **Method**: QLoRA (4-bit NF4 base, fp16 compute — trained on hardware with no native bf16
support) via TRL `SFTTrainer`.
- **LoRA config**: r=16, alpha=32, dropout=0.05, targeting `q/k/v/o/gate/up/down_proj`.
- **Schedule**: 3 epochs, cosine LR decay from 2e-4, 3% warmup, effective batch size 16.
- **Best checkpoint selection**: `load_best_model_at_end` on held-out eval loss across the full
3-epoch run — the published weights are the best-performing checkpoint, not simply the last.
## Limitations
- Not intended for direct scripture recitation or fatwa-issuing without the retrieval tool
layer it was trained to route through.
- Behavioral eval-gate results (57 adversarial/generalization probes) are pending publication —
loss curves alone do not fully capture tool-routing correctness or persona robustness; treat
this card as provisional on that front until updated.
- Trained and evaluated primarily on Arabic Islamic-assistant use cases; general-purpose
capability outside that domain is inherited from the base model and not separately verified.
## Citation
If you use this model, please cite it as:
```bibtex
@misc{muslim6bpro2026,
title = {Muslim-6B-PRO: A Behavior-Tuned Islamic Voice-Assistant Language Model},
author = {Alnwsany, Yahya},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/NightPrince/Muslim-6B-PRO}},
note = {Fine-tuned from Karnak-6B-v1.0}
}
```
**Related resources:**
- Base model: [Applied-Innovation-Center/Karnak-6B-v1.0](https://huggingface.co/Applied-Innovation-Center/Karnak-6B-v1.0)
- Training dataset: [NightPrince/muslim-6b-v1-dataset](https://huggingface.co/datasets/NightPrince/muslim-6b-v1-dataset)
- GGUF quantizations: [NightPrince/Muslim-6B-PRO-GGUF](https://huggingface.co/NightPrince/Muslim-6B-PRO-GGUF)
- Live demo: [NightPrince/muslim-6b-pro-demo](https://huggingface.co/spaces/NightPrince/muslim-6b-pro-demo)
- Fine-tuning code: [github.com/NightPrinceY/Karnak-6B-Finetuning](https://github.com/NightPrinceY/Karnak-6B-Finetuning)
## Copyright & License
Copyright © 2026 Yahya Alnwsany (NightPrince). This model's fine-tuning work — the LoRA
adapter, training data curation, and this model card — is released under the **Apache License
2.0**; see [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for the full text. Use of the
base model [Karnak-6B-v1.0](https://huggingface.co/Applied-Innovation-Center/Karnak-6B-v1.0)
remains subject to its own license terms from Applied Innovation Center.

54
chat_template.jinja Normal file
View File

@@ -0,0 +1,54 @@
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0]['role'] == 'system' %}
{{- messages[0]['content'] }}
{%- else %}
{{- 'You are Karnak, created by AIC. You are a helpful assistant.' }}
{%- endif %}
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
{%- else %}
{%- if messages[0]['role'] == 'system' %}
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
{%- else %}
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- for message in messages %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{{- '<|im_start|>' + message.role }}
{%- if message.content %}
{{- '\n' + message.content }}
{%- endif %}
{%- for tool_call in message.tool_calls %}
{%- if tool_call.function is defined %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '\n<tool_call>\n{"name": "' }}
{{- tool_call.name }}
{{- '", "arguments": ' }}
{{- tool_call.arguments }}
{{- '}\n</tool_call>' }}
{%- endfor %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
{{- '<|im_start|>user' }}
{%- endif %}
{{- '\n<tool_response>\n' }}
{{- message.content }}
{{- '\n</tool_response>' }}
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- endif %}

89
config.json Normal file
View File

@@ -0,0 +1,89 @@
{
"architectures": [
"Qwen3ForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": null,
"dtype": "float16",
"eos_token_id": 151645,
"head_dim": 128,
"hidden_act": "silu",
"hidden_size": 2560,
"initializer_range": 0.02,
"intermediate_size": 9728,
"layer_types": [
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention"
],
"max_position_embeddings": 262144,
"max_window_layers": 36,
"model_type": "qwen3",
"num_attention_heads": 32,
"num_hidden_layers": 54,
"num_key_value_heads": 8,
"pad_token_id": 151643,
"rms_norm_eps": 1e-06,
"rope_parameters": {
"rope_theta": 5000000,
"rope_type": "default"
},
"sliding_window": null,
"tie_word_embeddings": true,
"transformers_version": "5.12.1",
"use_cache": false,
"use_sliding_window": false,
"vocab_size": 192728
}

7
generation_config.json Normal file
View File

@@ -0,0 +1,7 @@
{
"_from_model_config": true,
"eos_token_id": 151645,
"pad_token_id": 151643,
"transformers_version": "5.12.1",
"use_cache": false
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:410f75d5e7eaec715ee94db04631b71a1bbabe8f70a8be854a8034c5b07af636
size 11887369032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e712e4e0fd118755ed240ffaa4a1f52b308e8003cb95478fdad9c5731bc98daf
size 238301

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b4478010053dc0bd9af322f60c44f6b1d0da1181c800f6e2324527501f58ff19
size 232878

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f644d71501367aaa569353e4787cd25cadb851169b709d8712bff51c72ce76f8
size 15658511

15
tokenizer_config.json Normal file
View File

@@ -0,0 +1,15 @@
{
"add_prefix_space": false,
"backend": "tokenizers",
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"is_local": true,
"local_files_only": false,
"model_max_length": 131072,
"pad_token": "<|endoftext|>",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}