Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3# Load model and tokenizer
4model = AutoModelForCausalLM.from_pretrained("hazem74/deepseek-soap-summary-v2", trust_remote_code=True)
5tokenizer = AutoTokenizer.from_pretrained("hazem74/deepseek-soap-summary-v2")
6
7# Sample dialogue
8dialogue = """
9Doctor: Hello, how are you feeling today?
10Patient: I've been having some chest pain for the last two days.
11Doctor: Can you describe the pain?
12Patient: It's a sharp pain, mostly on the left side.
13"""
14
15# Format the prompt
16system_message = "You are a medical professional tasked with creating SOAP notes from patient-doctor dialogues."
17user_content = f"""
18# Patient-Doctor Dialogue:
19{dialogue}
20
21# Task:
22Generate a SOAP summary from the above medical dialogue.
23The summary should include Subjective, Objective, Assessment, and Plan sections.
24
25# SOAP Summary:
26"""
27
28messages = [
29 {"role": "system", "content": system_message},
30 {"role": "user", "content": user_content}
31]
32
33# Generate SOAP summary
34prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
35inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
36
37outputs = model.generate(
38 inputs.input_ids,
39 max_new_tokens=512,
40 temperature=0.3,
41 top_p=0.9
42)
43
44soap_summary = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
45print(soap_summary)```
46
47Limitations
48This model assists healthcare professionals but should not replace human judgment. Always review generated summaries for accuracy.