Ellbendls commited on
Commit
4b0fd3c
·
verified ·
1 Parent(s): 1dfdb9e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +115 -3
README.md CHANGED
@@ -1,22 +1,134 @@
 
1
  ---
2
- base_model: unsloth/qwen3-4b-unsloth-bnb-4bit
3
  tags:
4
  - text-generation-inference
5
  - transformers
6
  - unsloth
7
  - qwen3
8
  - trl
 
 
9
  license: apache-2.0
10
  language:
11
  - en
 
 
12
  ---
13
 
14
- # Uploaded model
15
 
16
  - **Developed by:** Ellbendls
17
  - **License:** apache-2.0
18
- - **Finetuned from model :** unsloth/qwen3-4b-unsloth-bnb-4bit
 
 
 
 
19
 
20
  This qwen3 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  ---
3
+ base_model: Qwen/Qwen3-4B
4
  tags:
5
  - text-generation-inference
6
  - transformers
7
  - unsloth
8
  - qwen3
9
  - trl
10
+ - islamic-qa
11
+ - chain-of-thought
12
  license: apache-2.0
13
  language:
14
  - en
15
+ datasets:
16
+ - musaoc/Quran-reasoning-SFT
17
  ---
18
 
19
+ # Qwen3-4B-Quran-LoRA-Fine-Tuned
20
 
21
  - **Developed by:** Ellbendls
22
  - **License:** apache-2.0
23
+ - **Base Model:** Qwen/Qwen3-4B
24
+ - **Fine-tuned from:** unsloth/qwen3-4b-unsloth-bnb-4bit
25
+ - **Training Dataset:** musaoc/Quran-reasoning-SFT
26
+
27
+ 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.
28
 
29
  This qwen3 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
30
 
31
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
32
+
33
+ ## Model Features
34
+
35
+ - **Chain-of-Thought Reasoning**: Shows detailed thinking process before providing answers
36
+ - **Islamic Knowledge**: Specialized in Islamic concepts, jurisprudence, and theology
37
+ - **Flexible Output**: Can enable/disable thinking process based on user preference
38
+ - **Streaming Support**: Real-time response generation
39
+
40
+ ## Quick Start
41
+
42
+ ### Installation
43
+
44
+ ```bash
45
+ pip install transformers torch soundfile ipython bitsandbytes
46
+ ```
47
+
48
+ ### Usage
49
+
50
+ ```python
51
+ from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
52
+ import torch
53
+
54
+ # Load the fine-tuned model
55
+ model_id = "Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned"
56
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
57
+ model = AutoModelForCausalLM.from_pretrained(
58
+ model_id,
59
+ torch_dtype=torch.float16,
60
+ device_map="auto",
61
+ trust_remote_code=True
62
+ )
63
+
64
+ # Ask a question
65
+ messages = [
66
+ {"role" : "user", "content" : "What is Sabr?"},
67
+ ]
68
+ text = tokenizer.apply_chat_template(
69
+ messages,
70
+ tokenize = False,
71
+ add_generation_prompt = True, # Must add for generation
72
+ enable_thinking = True, # Disable or Enable thinking
73
+ )
74
+
75
+ from transformers import TextStreamer
76
+ _ = model.generate(
77
+ **tokenizer(text, return_tensors = "pt").to("cuda"),
78
+ max_new_tokens = 256, # Increase for longer outputs!
79
+ temperature = 0.7, top_p = 0.8, top_k = 20, # For non thinking
80
+ streamer = TextStreamer(tokenizer, skip_prompt = True),
81
+ )
82
+ ```
83
+
84
+ ## Parameters
85
+
86
+ - `enable_thinking = True` - Shows the model's reasoning process
87
+ - `enable_thinking = False` - Only shows the final answer
88
+ - `max_new_tokens` - Controls response length (default: 256)
89
+ - `temperature` - Controls randomness (0.1-1.0, default: 0.7)
90
+
91
+ ## Example Output
92
+
93
+ ```
94
+ <think>
95
+ 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.
96
+ </think>
97
+
98
+ Sabr is a vital virtue in Islam that teaches patience and perseverance in the face of challenges.
99
+ ```
100
+
101
+ ## Training Details
102
+
103
+ - **Training Method**: LoRA (Low-Rank Adaptation) fine-tuning
104
+ - **Dataset**: 857 examples from musaoc/Quran-reasoning-SFT
105
+ - **Training Steps**: 30 (demonstration model)
106
+ - **LoRA Configuration**:
107
+ - Rank: 32
108
+ - Alpha: 32
109
+ - Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
110
+ - **Batch Size**: 2 per device with gradient accumulation steps of 4
111
+ - **Learning Rate**: 2e-4
112
+ - **Optimizer**: adamw_8bit
113
+
114
+ ## Limitations
115
+
116
+ - **Religious Guidance**: This model provides educational information about Islamic concepts but should not be considered as official religious guidance
117
+ - **Scholarly Consultation**: For important religious matters, always consult qualified Islamic scholars
118
+ - **Training Data**: Model responses are based on training data and may not cover all Islamic perspectives
119
+
120
+ ## Citation
121
+
122
+ ```bibtex
123
+ @misc{qwen3-4b-quran-lora,
124
+ title={Qwen3-4B-Quran-LoRA-Fine-Tuned},
125
+ author={Ellbendls},
126
+ year={2025},
127
+ howpublished={\url{https://huggingface.co/Ellbendls/Qwen3-4b-Quran-LoRA-Fine-Tuned}},
128
+ }
129
+ ```
130
+
131
+ ---
132
+
133
+ *This model is designed for educational and research purposes. For authoritative Islamic guidance, please consult qualified scholars and authentic Islamic sources.*
134
+