File size: 1,871 Bytes
bc0c13b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

---
language:
- en
tags:
- medical
- healthcare
- SOAP notes
- clinical documentation
license: mit
datasets:
- omi-health/medical-dialogue-to-soap-summary
---

# DeepSeek SOAP Summary Generator

This model is fine-tuned to generate SOAP (Subjective, Objective, Assessment, Plan) summaries from patient-doctor dialogues.

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained("hazem74/qwen-soap-summary-v2", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("hazem74/qwen-soap-summary-v2")

# Sample dialogue
dialogue = """
Doctor: Hello, how are you feeling today?
Patient: I've been having some chest pain for the last two days.
Doctor: Can you describe the pain?
Patient: It's a sharp pain, mostly on the left side.
"""

# Format the prompt
system_message = "You are a medical professional tasked with creating SOAP notes from patient-doctor dialogues."
user_content = f"""
# Patient-Doctor Dialogue:
{dialogue}

# Task:
Generate a SOAP summary from the above medical dialogue.
The summary should include Subjective, Objective, Assessment, and Plan sections.

# SOAP Summary:
"""

messages = [
    {"role": "system", "content": system_message},
    {"role": "user", "content": user_content}
]

# Generate SOAP summary
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

outputs = model.generate(
    inputs.input_ids,
    max_new_tokens=512,
    temperature=0.3,
    top_p=0.9
)

soap_summary = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(soap_summary)```

Limitations
This model assists healthcare professionals but should not replace human judgment. Always review generated summaries for accuracy.