Med_Soap_llama321 is a fine-tuned derivative of meta-llama/Llama-3.2-1B trained to convert medical visit transcripts into structured SOAP-style clinical notes.
Training used LoRA adapters with Tinker (training SDK & cookbook) and the outputs were merged into the base model for standalone use.
Intended use: assistive drafting of structured notes from clinician–patient transcripts. Outputs should be reviewed and edited by qualified clinicians before use in any clinical workflow.
Quick start (🤗 Transformers)
python
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
34MODEL_ID ="johnyquest7/Med_soap_llama321_tinker"56tok = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=True)7model = AutoModelForCausalLM.from_pretrained(8 MODEL_ID,9 torch_dtype=torch.bfloat16 if torch.cuda.is_available()else torch.float32,10 device_map="auto"11)1213# Minimal prompt — the model was trained on transcripts whose first line begins with:14# "Please convert the following medical transcript into a structured medical note."15prompt ="""Please convert the following medical transcript into a structured medical note.
1617Doctor: Hi there, good to see you again. How have you been feeling?
18Patient: I've been more tired and a bit dizzy...
19"""2021inputs = tok([prompt], return_tensors="pt").to(model.device)22with torch.no_grad():23 out = model.generate(24**inputs,25 max_new_tokens=512,26 do_sample=True,27 temperature=0.2,28 top_p=0.95,29 eos_token_id=tok.eos_token_id,30)31print(tok.decode(out[0], skip_special_tokens=True))32
Training summary
Base model: meta-llama/Llama-3.2-1B
Task: supervised fine-tuning on pairs (transcript → structured note)
Formatting: chat-style conversations with a single user turn (transcript) and single assistant turn (note); the user message includes the instruction line:
Please convert the following medical transcript into a structured medical note.
Frameworks: Tinker (trainer/cookbook) + PEFT/LoRA; final weights merged for HF usage.
Typical knobs: LoRA rank 32, max seq length ~8k, linear LR schedule, batch ~16.
Renderer: Tinker recommended renderer for Llama 3.2 (“role_colon” template)
Train objective: Cross-entropy on assistant turns (ALL_ASSISTANT_MESSAGES)
Logging: JSONL metrics (train/eval NLL); optional W&B
Checkpointing: periodic state saves; final merge via peft.merge_and_unload()
Inference prompt tips
Keep the opening instruction line exactly as seen during training (above).
Provide the verbatim transcript (doctor/patient turns) below the instruction.
For longer visits, raise max_new_tokens (e.g., 768–1024).
For more deterministic outputs, lower temperature (0.1–0.3).
Evaluation
During training we tracked negative log-likelihood (NLL) on train and a 5% eval split.
For downstream quality checks, we recommend:
ROUGE-L / BLEU vs. reference notes (style similarity)