musaoc/Quran-reasoning-SFT
Viewer • Updated • 857 • 49 • 2
How to use Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned with Transformers:
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned", dtype="auto")How to use Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned with Unsloth Studio:
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 Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned to start chatting
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 Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned",
max_seq_length=2048,
)A fine-tuned version of Qwen3-4B specifically designed for Islamic Q&A with chain-of-thought reasoning capabilities. This model can provide detailed explanations about Islamic concepts, jurisprudence, theology, and Quranic interpretations.
This qwen3 model was trained 2x faster with Unsloth and Huggingface's TRL library.
pip install transformers torch soundfile ipython bitsandbytes
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
import torch
# Load the fine-tuned model
model_id = "Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
# Ask a question
messages = [
{"role" : "user", "content" : "What is Sabr?"},
]
text = tokenizer.apply_chat_template(
messages,
tokenize = False,
add_generation_prompt = True, # Must add for generation
enable_thinking = True, # Disable or Enable thinking
)
from transformers import TextStreamer
_ = model.generate(
**tokenizer(text, return_tensors = "pt").to("cuda"),
max_new_tokens = 256, # Increase for longer outputs!
temperature = 0.7, top_p = 0.8, top_k = 20, # For non thinking
streamer = TextStreamer(tokenizer, skip_prompt = True),
)
enable_thinking = True - Shows the model's reasoning processenable_thinking = False - Only shows the final answermax_new_tokens - Controls response length (default: 256)temperature - Controls randomness (0.1-1.0, default: 0.7)<think>
Sabr is a crucial concept in Islam that means patience, perseverance, and endurance in the face of difficulties. It is one of the essential pillars of faith, as emphasized in the Quran. Sabr is not just about enduring hardship but also about maintaining faith and trust in Allah's plan.
</think>
Sabr is a vital virtue in Islam that teaches patience and perseverance in the face of challenges.
@misc{qwen3-4b-quran-lora,
title={Qwen3-4B-Quran-LoRA-Fine-Tuned},
author={Ellbendls},
year={2025},
howpublished={\url{https://huggingface.co/Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned}},
}
This model is designed for educational and research purposes. For authoritative Islamic guidance, please consult qualified scholars and authentic Islamic sources.