File size: 5,013 Bytes
6d35058
 
 
ba24fb8
 
 
 
 
 
 
6d35058
 
ba24fb8
6d35058
 
 
 
 
ba24fb8
6d35058
ba24fb8
 
 
 
 
 
 
6d35058
ba24fb8
6d35058
ba24fb8
f4082cb
892aa8c
6d35058
 
 
 
 
ba24fb8
6d35058
ba24fb8
 
 
6d35058
ba24fb8
6d35058
ba24fb8
 
 
6d35058
 
 
ba24fb8
 
 
6d35058
 
 
ba24fb8
6d35058
 
 
ba24fb8
6d35058
 
 
ba24fb8
 
 
6d35058
ba24fb8
 
 
 
 
 
 
 
 
6d35058
 
 
 
 
ba24fb8
6d35058
 
 
ba24fb8
6d35058
ba24fb8
 
6d35058
 
 
ba24fb8
 
 
 
 
6d35058
ba24fb8
6d35058
ba24fb8
 
6d35058
ba24fb8
6d35058
ba24fb8
 
 
 
 
 
 
 
6d35058
ba24fb8
6d35058
 
 
 
 
ba24fb8
6d35058
 
 
ba24fb8
6d35058
 
 
ba24fb8
 
 
6d35058
 
 
ba24fb8
 
 
 
 
6d35058
ba24fb8
6d35058
 
 
ba24fb8
 
 
 
 
 
 
6d35058
 
 
 
 
ba24fb8
6d35058
 
ba24fb8
6d35058
 
 
ba24fb8
 
 
 
 
 
 
 
6d35058
ba24fb8
6d35058
ba24fb8
6d35058
 
 
892aa8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
base_model: unsloth/deepseek-r1-distill-llama-8b-unsloth-bnb-4bit
library_name: peft
license: mit
datasets:
- FreedomIntelligence/medical-o1-reasoning-SFT
language:
- en
tags:
- medical
---

# Model Card for DeepSeek-R1-Medical-COT

## Model Details

### Model Description

DeepSeek-R1-Medical-COT is a fine-tuned version of the DeepSeek-R1 model, optimized for medical chain-of-thought (COT) reasoning. It is designed to assist in medical-related tasks such as question-answering, reasoning, and decision support. This model is particularly useful for applications requiring structured reasoning in the medical domain.

- **Developed by:** Mohamed Mahmoud
- **Funded by [optional]:** Independent project
- **Shared by:** Mohamed Mahmoud
- **Model type:** Transformer-based Large Language Model (LLM)
- **Language(s) (NLP):** English (en)
- **License:** MIT
- **Finetuned from model:** unsloth/deepseek-r1-distill-llama-8b-unsloth-bnb-4bit

### Model Sources

- **Repository:** [Hugging Face Model Repo](https://huggingface.co/thesnak/DeepSeek-R1-Medical-COT)
  
- **LinkedIn:** [Mohamed Mahmoud](https://www.linkedin.com/in/mohamed-thesnak)

## Uses

### Direct Use

The model can be used directly for medical reasoning tasks, including:

- Answering medical questions
- Assisting in medical decision-making
- Supporting clinical research and literature review

### Downstream Use

- Fine-tuning for specialized medical applications
- Integration into chatbots and virtual assistants for medical advice
- Educational tools for medical students

### Out-of-Scope Use

- This model is not a replacement for professional medical advice.
- Should not be used for clinical decision-making without expert validation.
- May not perform well in languages other than English.

## Bias, Risks, and Limitations

While fine-tuned for medical reasoning, the model may still have biases due to the limitations of its training data. Users should exercise caution and validate critical outputs with medical professionals.

### Recommendations

Users should verify outputs, particularly in sensitive medical contexts. The model is best used as an assistive tool rather than a primary decision-making system.

## How to Get Started with the Model

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_name = "thesnak/DeepSeek-R1-Medical-COT"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")

input_text = "What are the symptoms of pneumonia?"
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

## Training Details

### Training Data

The model was fine-tuned using the **FreedomIntelligence/medical-o1-reasoning-SFT** dataset, which contains medical question-answer pairs designed to improve reasoning capabilities.

### Training Procedure

#### Preprocessing

- Tokenization using LLaMA tokenizer
- Text cleaning and normalization

#### Training Hyperparameters

- **Precision:** bf16 mixed precision
- **Optimizer:** AdamW
- **Batch size:** 16
- **Learning rate:** 2e-5
- **Epochs:** 3

#### Speeds, Sizes, Times

- **Training time:** Approximately 12 hours on a P100 GPU (Kaggle)
- **Model size:** 8B parameters (bnb 4-bit quantized)

#### Training Loss

| Step | Training Loss |
| ---- | ------------- |
| 10   | 1.919000      |
| 20   | 1.461800      |
| 30   | 1.402500      |
| 40   | 1.309000      |
| 50   | 1.344400      |
| 60   | 1.314100      |

## Evaluation

### Testing Data, Factors & Metrics

#### Testing Data

- The model was evaluated on held-out samples from **FreedomIntelligence/medical-o1-reasoning-SFT**.

#### Factors

- Performance was assessed on medical reasoning tasks.

#### Metrics

- **Perplexity:** Measured for general coherence.
- **Accuracy:** Evaluated based on expert-verified responses.
- **BLEU Score:** Used to assess response relevance.

### Results

- **Perplexity:**  
- **Accuracy:**  
- **BLEU Score:**
  
## Model Examination

Further interpretability analyses can be conducted using tools like Captum and SHAP to analyze how the model derives its medical reasoning responses.

## Environmental Impact

- **Hardware Type:** P100 GPU (Kaggle)
- **Hours used:** 2 hours
- **Cloud Provider:** Kaggle
- **Compute Region:** N/A
- **Carbon Emitted:** Estimated at 9.5 kg CO2eq
- **[Kaggle Notebook](https://www.kaggle.com/code/thesnak/fine-tune-deepseek)**
## Technical Specifications

### Compute Infrastructure

#### Hardware

- P100 GPU (16GB VRAM) on Kaggle


## Citation

**BibTeX:**

```bibtex
@misc{mahmoud2025deepseekmedcot,
  title={DeepSeek-R1-Medical-COT},
  author={Mohamed Mahmoud},
  year={2025},
  url={https://huggingface.co/thesnak/DeepSeek-R1-Medical-COT}
}
```

## Model Card Authors

- Mohamed Mahmoud

## Model Card Contact

- [LinkedIn](https://www.linkedin.com/in/mohamed-thesnak)