Improve language tag

#2
by lbourdois - opened
Files changed (1) hide show
  1. README.md +161 -149
README.md CHANGED
@@ -1,150 +1,162 @@
1
- ---
2
- datasets:
3
- - iimran/Medical-Intelligence-Questions
4
- base_model:
5
- - Qwen/Qwen2.5-3B
6
- language:
7
- - en
8
- tags:
9
- - medical
10
- - text-generation-inference
11
- - transformers
12
- - unsloth
13
- ---
14
- # Qwen2.5-3B-R1-MedicalReasoner
15
-
16
- **Qwen2.5-3B-R1-MedicalReasoner** is a clinical reasoning language model fine-tuned for advanced diagnostic and case-based problem solving. It has been developed for applications in medical education, clinical decision support, and research, with the capability to generate detailed chain-of-thought responses that include both the reasoning process and the final answer.
17
-
18
- ## Overview
19
-
20
- - **Model Name:** Qwen2.5-3B-R1-MedicalReasoner
21
- - **Base Architecture:** Qwen2.5 (3B)
22
- - **Primary Application:** Clinical reasoning and medical problem solving
23
- - **Key Features:**
24
- - **Chain-of-Thought Outputs:** Responds with structured reasoning (`<reasoning> ... </reasoning>`) followed by a concise answer (`<answer> ... </answer>`).
25
- - **Multi-Specialty Coverage:** Well-suited for scenarios in internal medicine, surgery, pediatrics, OB/GYN, emergency medicine, and more.
26
- - **Explainable AI:** Generates detailed, educational explanations that support clinical decision-making.
27
-
28
- ## Model Capabilities
29
-
30
- - **Expert-Level Clinical Reasoning:** Equipped to analyze complex clinical scenarios and provide in-depth diagnostic reasoning.
31
- - **Structured Outputs:** Enforces a response format that separates the thought process from the final answer, aiding transparency and interpretability.
32
- - **Optimized for Speed:** Uses Unsloth and vLLM for fast, efficient inference on GPU systems.
33
-
34
- ## Inference and Usage
35
-
36
- Below is an example of how to use the model for inference or refer to inference.py in files section:
37
-
38
- ```python
39
- from unsloth import FastLanguageModel, is_bfloat16_supported
40
- from vllm import SamplingParams
41
- from huggingface_hub import snapshot_download
42
- model, tokenizer = FastLanguageModel.from_pretrained(
43
- model_name="iimran/Qwen2.5-3B-R1-MedicalReasoner",
44
- load_in_4bit=True,
45
- fast_inference=True,
46
- gpu_memory_utilization=0.5
47
- )
48
- lora_rank = 64
49
- model = FastLanguageModel.get_peft_model(
50
- model,
51
- r=lora_rank,
52
- target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
53
- "gate_proj", "up_proj", "down_proj"],
54
- lora_alpha=lora_rank,
55
- use_gradient_checkpointing="unsloth",
56
- random_state=3407,
57
- )
58
- lora_path = snapshot_download("iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter")
59
- print("LoRA adapter downloaded to:", lora_path)
60
- model.load_lora(lora_path)
61
- SYSTEM_PROMPT = (
62
- "Respond in the following format:\n"
63
- "<reasoning>\n"
64
- "...\n"
65
- "</reasoning>\n"
66
- "<answer>\n"
67
- "...\n"
68
- "</answer>"
69
- )
70
- USER_PROMPT = (
71
- "In the context of disseminated intravascular coagulation (DIC), "
72
- "which blood component is expected to show an increase due to the excessive breakdown of fibrin?"
73
- )
74
- text = tokenizer.apply_chat_template(
75
- [
76
- {"role": "system", "content": SYSTEM_PROMPT},
77
- {"role": "user", "content": USER_PROMPT},
78
- ],
79
- tokenize=False,
80
- add_generation_prompt=True
81
- )
82
- sampling_params = SamplingParams(
83
- temperature=0.1,
84
- top_p=0.95,
85
- max_tokens=4096,
86
- )
87
- outputs = model.fast_generate(
88
- text,
89
- sampling_params=sampling_params,
90
- lora_request=None
91
- )
92
- print(outputs[0].outputs[0].text)
93
- ```
94
-
95
- ### Adapter Integration
96
-
97
- For further fine-tuning or experiments with LoRA adapters, the LoRA adapter for this model is available in a separate repository.
98
-
99
- - **LoRA Adapter Repo:** [iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter](https://huggingface.co/iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter)
100
-
101
- To download and integrate the LoRA adapter:
102
- ```python
103
- from huggingface_hub import snapshot_download
104
-
105
- # Download the LoRA adapter repository:
106
- lora_path = snapshot_download("iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter")
107
- print("LoRA adapter downloaded to:", lora_path)
108
-
109
- # Load the adapter into the model:
110
- model.load_lora(lora_path)
111
- ```
112
-
113
- ## Installation
114
-
115
- To use this model, install the required packages:
116
- ```bash
117
- pip install unsloth vllm trl datasets huggingface-hub
118
- ```
119
-
120
- A compatible GPU is recommended for optimal performance.
121
-
122
- ## Citation
123
-
124
- If you use **Qwen2.5-3B-R1-MedicalReasoner** in your research, please cite:
125
- ```bibtex
126
- @misc{sarwar2025reinforcement,
127
- author = {Imran Sarwar and Muhammad Rouf Mustafa},
128
- title = {Reinforcement Learning Elevates Qwen2.5-3B Medical Reasoning Performance},
129
- year = {2025},
130
- month = {Apr},
131
- day = {10},
132
- publisher = {Imran Sarwar's Blog},
133
- howpublished = {\url{https://www.imransarwar.com/blog-posts/Reinforcement-Learning-Elevates-Qwen2.5-Medical-Reasoning-Performance.html}},
134
- note = {Accessed: 2025-04-09}
135
- }
136
- ```
137
-
138
- ```bibtex
139
- @misc{Qwen2.5-3B-R1-MedicalReasoner,
140
- authors = {Imran Sarwar, Muhammad Rouf Mustafa},
141
- title = {Qwen 2.5-3B Meets Deepseek R1: A Fine-Tuned Medical Reasoning Model for Enhanced Diagnostics},
142
- year = {2025},
143
- publisher = {Hugging Face},
144
- url = {https://huggingface.co/iimran/Qwen2.5-3B-R1-MedicalReasoner}
145
- }
146
- ```
147
-
148
- ## Disclaimer
149
-
 
 
 
 
 
 
 
 
 
 
 
 
150
  This model is intended for research and educational purposes only. It should not be used as the sole basis for clinical decision-making. All outputs should be validated by qualified healthcare professionals.
 
1
+ ---
2
+ datasets:
3
+ - iimran/Medical-Intelligence-Questions
4
+ base_model:
5
+ - Qwen/Qwen2.5-3B
6
+ language:
7
+ - zho
8
+ - eng
9
+ - fra
10
+ - spa
11
+ - por
12
+ - deu
13
+ - ita
14
+ - rus
15
+ - jpn
16
+ - kor
17
+ - vie
18
+ - tha
19
+ - ara
20
+ tags:
21
+ - medical
22
+ - text-generation-inference
23
+ - transformers
24
+ - unsloth
25
+ ---
26
+ # Qwen2.5-3B-R1-MedicalReasoner
27
+
28
+ **Qwen2.5-3B-R1-MedicalReasoner** is a clinical reasoning language model fine-tuned for advanced diagnostic and case-based problem solving. It has been developed for applications in medical education, clinical decision support, and research, with the capability to generate detailed chain-of-thought responses that include both the reasoning process and the final answer.
29
+
30
+ ## Overview
31
+
32
+ - **Model Name:** Qwen2.5-3B-R1-MedicalReasoner
33
+ - **Base Architecture:** Qwen2.5 (3B)
34
+ - **Primary Application:** Clinical reasoning and medical problem solving
35
+ - **Key Features:**
36
+ - **Chain-of-Thought Outputs:** Responds with structured reasoning (`<reasoning> ... </reasoning>`) followed by a concise answer (`<answer> ... </answer>`).
37
+ - **Multi-Specialty Coverage:** Well-suited for scenarios in internal medicine, surgery, pediatrics, OB/GYN, emergency medicine, and more.
38
+ - **Explainable AI:** Generates detailed, educational explanations that support clinical decision-making.
39
+
40
+ ## Model Capabilities
41
+
42
+ - **Expert-Level Clinical Reasoning:** Equipped to analyze complex clinical scenarios and provide in-depth diagnostic reasoning.
43
+ - **Structured Outputs:** Enforces a response format that separates the thought process from the final answer, aiding transparency and interpretability.
44
+ - **Optimized for Speed:** Uses Unsloth and vLLM for fast, efficient inference on GPU systems.
45
+
46
+ ## Inference and Usage
47
+
48
+ Below is an example of how to use the model for inference or refer to inference.py in files section:
49
+
50
+ ```python
51
+ from unsloth import FastLanguageModel, is_bfloat16_supported
52
+ from vllm import SamplingParams
53
+ from huggingface_hub import snapshot_download
54
+ model, tokenizer = FastLanguageModel.from_pretrained(
55
+ model_name="iimran/Qwen2.5-3B-R1-MedicalReasoner",
56
+ load_in_4bit=True,
57
+ fast_inference=True,
58
+ gpu_memory_utilization=0.5
59
+ )
60
+ lora_rank = 64
61
+ model = FastLanguageModel.get_peft_model(
62
+ model,
63
+ r=lora_rank,
64
+ target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
65
+ "gate_proj", "up_proj", "down_proj"],
66
+ lora_alpha=lora_rank,
67
+ use_gradient_checkpointing="unsloth",
68
+ random_state=3407,
69
+ )
70
+ lora_path = snapshot_download("iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter")
71
+ print("LoRA adapter downloaded to:", lora_path)
72
+ model.load_lora(lora_path)
73
+ SYSTEM_PROMPT = (
74
+ "Respond in the following format:\n"
75
+ "<reasoning>\n"
76
+ "...\n"
77
+ "</reasoning>\n"
78
+ "<answer>\n"
79
+ "...\n"
80
+ "</answer>"
81
+ )
82
+ USER_PROMPT = (
83
+ "In the context of disseminated intravascular coagulation (DIC), "
84
+ "which blood component is expected to show an increase due to the excessive breakdown of fibrin?"
85
+ )
86
+ text = tokenizer.apply_chat_template(
87
+ [
88
+ {"role": "system", "content": SYSTEM_PROMPT},
89
+ {"role": "user", "content": USER_PROMPT},
90
+ ],
91
+ tokenize=False,
92
+ add_generation_prompt=True
93
+ )
94
+ sampling_params = SamplingParams(
95
+ temperature=0.1,
96
+ top_p=0.95,
97
+ max_tokens=4096,
98
+ )
99
+ outputs = model.fast_generate(
100
+ text,
101
+ sampling_params=sampling_params,
102
+ lora_request=None
103
+ )
104
+ print(outputs[0].outputs[0].text)
105
+ ```
106
+
107
+ ### Adapter Integration
108
+
109
+ For further fine-tuning or experiments with LoRA adapters, the LoRA adapter for this model is available in a separate repository.
110
+
111
+ - **LoRA Adapter Repo:** [iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter](https://huggingface.co/iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter)
112
+
113
+ To download and integrate the LoRA adapter:
114
+ ```python
115
+ from huggingface_hub import snapshot_download
116
+
117
+ # Download the LoRA adapter repository:
118
+ lora_path = snapshot_download("iimran/Qwen2.5-3B-R1-MedicalReasoner-lora-adapter")
119
+ print("LoRA adapter downloaded to:", lora_path)
120
+
121
+ # Load the adapter into the model:
122
+ model.load_lora(lora_path)
123
+ ```
124
+
125
+ ## Installation
126
+
127
+ To use this model, install the required packages:
128
+ ```bash
129
+ pip install unsloth vllm trl datasets huggingface-hub
130
+ ```
131
+
132
+ A compatible GPU is recommended for optimal performance.
133
+
134
+ ## Citation
135
+
136
+ If you use **Qwen2.5-3B-R1-MedicalReasoner** in your research, please cite:
137
+ ```bibtex
138
+ @misc{sarwar2025reinforcement,
139
+ author = {Imran Sarwar and Muhammad Rouf Mustafa},
140
+ title = {Reinforcement Learning Elevates Qwen2.5-3B Medical Reasoning Performance},
141
+ year = {2025},
142
+ month = {Apr},
143
+ day = {10},
144
+ publisher = {Imran Sarwar's Blog},
145
+ howpublished = {\url{https://www.imransarwar.com/blog-posts/Reinforcement-Learning-Elevates-Qwen2.5-Medical-Reasoning-Performance.html}},
146
+ note = {Accessed: 2025-04-09}
147
+ }
148
+ ```
149
+
150
+ ```bibtex
151
+ @misc{Qwen2.5-3B-R1-MedicalReasoner,
152
+ authors = {Imran Sarwar, Muhammad Rouf Mustafa},
153
+ title = {Qwen 2.5-3B Meets Deepseek R1: A Fine-Tuned Medical Reasoning Model for Enhanced Diagnostics},
154
+ year = {2025},
155
+ publisher = {Hugging Face},
156
+ url = {https://huggingface.co/iimran/Qwen2.5-3B-R1-MedicalReasoner}
157
+ }
158
+ ```
159
+
160
+ ## Disclaimer
161
+
162
  This model is intended for research and educational purposes only. It should not be used as the sole basis for clinical decision-making. All outputs should be validated by qualified healthcare professionals.