Views
No views yet
pip install transformers torch soundfile ipython bitsandbytes1from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
2import torch
3
4# Load the fine-tuned model
5model_id = "Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned"
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 device_map="auto",
11 trust_remote_code=True
12)
13
14# Ask a question
15messages = [
16 {"role" : "user", "content" : "What is Sabr?"},
17]
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize = False,
21 add_generation_prompt = True, # Must add for generation
22 enable_thinking = True, # Disable or Enable thinking
23)
24
25from transformers import TextStreamer
26_ = model.generate(
27 **tokenizer(text, return_tensors = "pt").to("cuda"),
28 max_new_tokens = 256, # Increase for longer outputs!
29 temperature = 0.7, top_p = 0.8, top_k = 20, # For non thinking
30 streamer = TextStreamer(tokenizer, skip_prompt = True),
31)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.1@misc{qwen3-4b-quran-lora,
2 title={Qwen3-4B-Quran-LoRA-Fine-Tuned},
3 author={Ellbendls},
4 year={2025},
5 howpublished={\url{https://huggingface.co/Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned}},
6}