sczzz commited on
Commit
4f806e4
·
verified ·
1 Parent(s): a6b3c79

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +319 -0
README.md ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
5
+ pipeline_tag: text-generation
6
+ library_name: transformers
7
+ tags:
8
+ - medical
9
+ ---
10
+
11
+
12
+ ## Overview
13
+
14
+ **RaDaR (Rare Disease navigatoR)** is a 32B-parameter reasoning large language model specialized for rare-disease differential diagnosis from free-text clinical narratives.
15
+
16
+ RaDaR was initialized from [DeepSeek-R1-Distill-Qwen-32B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B) and further trained using real-world rare-disease case reports and phenotype-anchored synthetic clinical cases, followed by supervised fine-tuning (SFT) and direct preference optimization (DPO).
17
+
18
+ RaDaR is designed to process **free-text clinical records directly**, without requiring users to first convert the clinical narrative into Human Phenotype Ontology (HPO) terms.
19
+
20
+ One motivation for releasing RaDaR as an open-weight model is to support **local deployment**, including settings in which sensitive clinical data should remain within an institution's own computing environment.
21
+
22
+ ## Resources
23
+
24
+ * **Training and synthetic-data construction code:** https://github.com/sczzz3/RaDaR
25
+ * **Paper:** https://arxiv.org/abs/2606.24510
26
+ * **Web application:** https://raredx.datummed.com
27
+
28
+ ## Clinical-use notice
29
+
30
+ RaDaR is a research and clinical decision-support model. It is not intended to replace qualified healthcare professionals or to provide autonomous diagnosis or treatment decisions. Model outputs may be incorrect, incomplete, or overconfident and should always be independently reviewed by qualified clinicians.
31
+
32
+
33
+ ## Quick start
34
+
35
+ This section provides step-by-step instructions for downloading RaDaR and running it locally.
36
+
37
+ ### 1. Hardware and storage
38
+
39
+ The released RaDaR-32B checkpoint is stored in BF16 format and occupies approximately **65.5 GB** of disk space. We recommend reserving at least **70 GB of free disk space** for the model files, plus additional space for the Python environment and model cache. Because the BF16 model weights alone occupy approximately 65.5 GB, GPU inference requires additional memory beyond the raw model size for runtime overhead and the key-value cache. Depending on the available hardware, users can run RaDaR on:
40
+
41
+ - a single high-memory GPU;
42
+ - multiple GPUs using automatic model sharding; or
43
+ - multiple GPUs using tensor parallelism with an inference engine such as vLLM.
44
+
45
+ Actual memory requirements depend on the input length, output length, inference backend, and number of concurrent requests. For users with limited GPU memory, shorter context lengths can substantially reduce runtime memory requirements.
46
+
47
+
48
+ ### 2. Create a Python environment
49
+
50
+ We recommend Python 3.11.
51
+
52
+ ```bash
53
+ conda create -n radar python=3.11 -y
54
+ conda activate radar
55
+ ```
56
+
57
+ Install the required packages:
58
+
59
+ ```bash
60
+ pip install torch
61
+ pip install transformers accelerate safetensors huggingface_hub
62
+ ```
63
+
64
+ The released checkpoint was saved with Transformers 4.45.2. If you encounter version-related compatibility issues, you can use:
65
+
66
+ ```bash
67
+ pip install transformers==4.45.2
68
+ ```
69
+
70
+ ### 3. Download RaDaR
71
+
72
+ Install or update the Hugging Face Hub command-line utility:
73
+
74
+ ```bash
75
+ pip install -U huggingface_hub
76
+ ```
77
+
78
+ Download the complete model to a local directory:
79
+
80
+ ```bash
81
+ hf download sczzz/RaDaR-32B \
82
+ --local-dir ./RaDaR-32B
83
+ ```
84
+
85
+ After the download completes, the local directory should contain the model weights, tokenizer files, configuration files, and generation configuration. You can also skip this manual download step and use the Hugging Face repository name directly in `from_pretrained()`. However, explicitly downloading the checkpoint is recommended when preparing a fully offline clinical environment.
86
+
87
+
88
+ ### 4. Local inference with Transformers
89
+
90
+ Create a file called `run_radar.py`:
91
+
92
+ ```python
93
+ import torch
94
+ from transformers import AutoModelForCausalLM, AutoTokenizer
95
+
96
+ # Path to the locally downloaded checkpoint.
97
+ MODEL_PATH = "./RaDaR-32B"
98
+
99
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
100
+
101
+ model = AutoModelForCausalLM.from_pretrained(
102
+ MODEL_PATH,
103
+ torch_dtype=torch.bfloat16,
104
+ device_map="auto",
105
+ )
106
+
107
+ model.eval()
108
+
109
+ # ---------------------------------------------------------------------
110
+ # Replace the example text below with your own de-identified or locally
111
+ # governed clinical narrative.
112
+ # ---------------------------------------------------------------------
113
+
114
+ case_text = """
115
+ A 38-year-old male visited the surgery clinic with a year-long history of upper abdominal pain. The pain was described as dull and aching, with episodes of increased intensity lasting 1 to 2 hours...
116
+ """
117
+
118
+ prompt = f"""
119
+ As a medical expert, enumerate the top 10 most likely diagnoses for the following patient in descending order of likelihood, with the most likely disease listed first. Ensure that each diagnosis is as specific as possible, avoiding vague terms like "rare genetic disease".
120
+
121
+ Here is the case:
122
+ {case_text}
123
+
124
+ Only output the diagnosis in numeric order, one per line. For example:
125
+ 1. Disease A;
126
+ 2. Disease B;
127
+ ...
128
+
129
+ Do not output anything else!
130
+ """
131
+
132
+ # For the DeepSeek-R1-Distill model family, instructions are placed
133
+ # directly in the user message rather than in a separate system prompt.
134
+ messages = [
135
+ {"role": "user", "content": prompt}
136
+ ]
137
+
138
+ formatted_prompt = tokenizer.apply_chat_template(
139
+ messages,
140
+ tokenize=False,
141
+ add_generation_prompt=True,
142
+ )
143
+
144
+ inputs = tokenizer(
145
+ formatted_prompt,
146
+ return_tensors="pt",
147
+ ).to(model.device)
148
+
149
+ with torch.no_grad():
150
+ outputs = model.generate(
151
+ **inputs,
152
+ max_new_tokens=32768,
153
+ do_sample=True,
154
+ temperature=0.6,
155
+ top_p=0.95,
156
+ pad_token_id=tokenizer.eos_token_id,
157
+ )
158
+
159
+ generated_tokens = outputs[0][inputs["input_ids"].shape[-1]:]
160
+
161
+ response = tokenizer.decode(
162
+ generated_tokens,
163
+ skip_special_tokens=True,
164
+ )
165
+
166
+ print(response)
167
+ ```
168
+
169
+ Run the script:
170
+
171
+ ```bash
172
+ python run_radar.py
173
+ ```
174
+
175
+ The first model load may take several minutes depending on disk and GPU speed.
176
+
177
+
178
+ ### Optional: local API deployment with vLLM
179
+
180
+ RaDaR can also be served as a local API for integration with an institutional interface or clinical research application.
181
+
182
+ Install vLLM:
183
+
184
+ ```bash
185
+ pip install vllm
186
+ ```
187
+
188
+ For example, to serve RaDaR using two GPUs:
189
+
190
+ ```bash
191
+ vllm serve ./RaDaR-32B \
192
+ --dtype bfloat16 \
193
+ --tensor-parallel-size 2 \
194
+ --max-model-len 32768 \
195
+ --served-model-name RaDaR-32B
196
+ ```
197
+
198
+ Adjust `--tensor-parallel-size` to match the number of GPUs available. The maximum model length can also be reduced if GPU memory is limited. The server listens locally on port 8000 by default.
199
+
200
+ An example request is:
201
+
202
+ ```bash
203
+ curl http://127.0.0.1:8000/v1/chat/completions \
204
+ -H "Content-Type: application/json" \
205
+ -d '{
206
+ "model": "RaDaR-32B",
207
+ "messages": [
208
+ {
209
+ "role": "user",
210
+ "content": "Based on the following clinical information, provide a ranked differential diagnosis of up to five rare diseases.\n\nClinical information:\n[CLINICAL RECORD]"
211
+ }
212
+ ],
213
+ "temperature": 0.6,
214
+ "top_p": 0.95,
215
+ "max_tokens": 32768
216
+ }'
217
+ ```
218
+
219
+ For a fully offline deployment, start the server from the local checkpoint after enabling offline mode:
220
+
221
+ ```bash
222
+ export HF_HUB_OFFLINE=1
223
+
224
+ vllm serve ./RaDaR-32B \
225
+ --dtype bfloat16 \
226
+ --tensor-parallel-size 2 \
227
+ --max-model-len 32768 \
228
+ --served-model-name RaDaR-32B
229
+ ```
230
+
231
+ This allows a local application to interact with RaDaR without sending clinical records to an external LLM API.
232
+
233
+
234
+ ## Input format
235
+
236
+ RaDaR is primarily designed for **free-text clinical narratives**.
237
+
238
+ Useful information may include:
239
+
240
+ * age, sex, and age of symptom onset;
241
+ * major symptoms and physical examination findings;
242
+ * relevant past medical and family history;
243
+ * laboratory results;
244
+ * imaging findings;
245
+ * pathology or procedural findings;
246
+ * previous diagnostic investigations;
247
+ * treatment history and treatment response;
248
+ * genetic or genomic findings, when available.
249
+
250
+
251
+ ## Output
252
+
253
+ RaDaR generates diagnostic reasoning and candidate rare-disease diagnoses. For clinical decision support, the output should be interpreted as a **differential diagnosis list**, not as a definitive diagnosis. The primary diagnostic evaluation in our study used a top-5 differential-diagnosis setting, reflecting the intended use of RaDaR as a tool for prioritizing a short list of diseases for clinician review.
254
+
255
+
256
+ ## Model development
257
+
258
+ RaDaR was initialized from:
259
+
260
+ ```text
261
+ DeepSeek-R1-Distill-Qwen-32B
262
+ ```
263
+
264
+ The training corpus included:
265
+
266
+ * **49,170** publicly available real-world rare-disease cases; and
267
+ * **104,666** phenotype-anchored synthetic rare-disease cases.
268
+
269
+ Training consisted of two reasoning-enhancement stages:
270
+
271
+ 1. **Supervised Fine-Tuning (SFT)** using rare-disease clinical narratives paired with diagnostic reasoning trajectories; and
272
+ 2. **Direct Preference Optimization (DPO)** using preferred and dispreferred diagnostic reasoning outputs.
273
+
274
+ The full methodology is described in the accompanying paper. Code for phenotype sampling, synthetic-case construction, SFT, and DPO is available at: https://github.com/sczzz3/RaDaR
275
+
276
+
277
+ ## Citation
278
+
279
+ If you use RaDaR in your research, please cite:
280
+
281
+ ```bibtex
282
+ @article{chen2026radar,
283
+ title = {A specialized reasoning large language model for accelerating rare disease diagnosis: a randomized AI physician-assistance trial},
284
+ author = {Chen, Haichao and
285
+ Zhou, Songchi and
286
+ Zhao, Zhengyun and
287
+ Hu, Shikai and
288
+ Jin, Xianghong and
289
+ Ji, Hongwei and
290
+ He, Li and
291
+ Li, Shuli and
292
+ Qin, Yiming and
293
+ Tan, Xin and
294
+ Shi, Runfeng and
295
+ Tham, Yih Chung and
296
+ Zhu, Jiaye and
297
+ Li, Ye and
298
+ Jin, Ye and
299
+ Cao, Longhao and
300
+ Li, Dawei and
301
+ Wu, Honghan and
302
+ Gu, Hongqiu and
303
+ Li, Guanqiao and
304
+ Groza, Tudor and
305
+ Li, Chunying and
306
+ Zeng, Dian and
307
+ Yu, Weihong and
308
+ Baynam, Gareth and
309
+ Jamuar, Saumya Shekhar and
310
+ Shen, Min and
311
+ Zhang, Shuyang and
312
+ Sheng, Bin and
313
+ Yu, Sheng and
314
+ Wong, Tien Yin},
315
+ journal = {arXiv preprint arXiv:2606.24510},
316
+ year = {2026},
317
+ url = {https://arxiv.org/abs/2606.24510}
318
+ }
319
+ ```