starmpcc/Asclepius-Synthetic-Clinical-Notes
Viewer • Updated • 158k • 646 • 116
How to use elucidator8918/clinical-ehr-prototype-0.1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="elucidator8918/clinical-ehr-prototype-0.1")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("elucidator8918/clinical-ehr-prototype-0.1")
model = AutoModelForCausalLM.from_pretrained("elucidator8918/clinical-ehr-prototype-0.1", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use elucidator8918/clinical-ehr-prototype-0.1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "elucidator8918/clinical-ehr-prototype-0.1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "elucidator8918/clinical-ehr-prototype-0.1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/elucidator8918/clinical-ehr-prototype-0.1
How to use elucidator8918/clinical-ehr-prototype-0.1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "elucidator8918/clinical-ehr-prototype-0.1" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "elucidator8918/clinical-ehr-prototype-0.1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "elucidator8918/clinical-ehr-prototype-0.1" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "elucidator8918/clinical-ehr-prototype-0.1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use elucidator8918/clinical-ehr-prototype-0.1 with Docker Model Runner:
docker model run hf.co/elucidator8918/clinical-ehr-prototype-0.1
This model, elucidator8918/clinical-ehr-prototype-0.1, is tailored for clinical documentation, based on the Mistral-7B-Instruct-v0.1-sharded architecture fine-tuned on the Asclepius-Synthetic-Clinical-Notes dataset.
LoRA Parameters (QLoRA):
bitsandbytes Parameters:
TrainingArguments Parameters:
from transformers import pipeline
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer)
# Run text generation pipeline with our next model
prompt = """
You are an intelligent clinical language model.
Below is a snippet of patient's electronic health record note and a following instruction with question from healthcare professional.
Write a response that appropriately completes the instruction.
The response should provide the accurate answer to the instruction, while being concise.
### Instruction:
Abbreviation Expansion
### Patient's Electronic Health Record Note:
Hospital Course:
This 66-year-old male patient was admitted due to an ischemic left-hemispheric stroke in addition to a dry cough and fever. The patient tested positive for SARS-CoV-2 and experienced severe ARDS, resulting in intubation and ICU admission. The patient underwent veno-venous extracorporeal membrane oxygenation and physical therapy was initiated to focus on perception training, movement exercises, airway-clearing techniques, dysphagia therapy, and mobilization. Despite a trial of sedation cessation, the patient remained somnolent and unable to communicate or follow commands. A side-edge positioning was initiated in combination with intensive exercise training including trunk and head control. Muscle tone and strength remained severely reduced, particularly on his hemiplegic side, and a second SOEB trial failed. Occupational therapy was involved to support functional initiation of upper limb movements and to integrate perception-training into activities of daily living. Currently, the patient remains functionally dependent, tolerates spontaneous breathing trials, and is alert during therapy, although he cannot communicate. He is considered stable and functionally dependent (CPAx 6/50).
### Question:
What are the abbreviated terms in the given discharge summary that require expansion?
"""
result = pipe(f"[INST] {prompt} [/INST]",max_length=584)[0]['generated_text']
start_index = result.find("[/INST]") + len("[/INST]")
end_index = result.find("'", start_index)
response = result[start_index:end_index]
print(response)
The abbreviated terms in the given discharge summary that requires expansion are SARS-CoV-2, ARDS, ICU, SOEB, CPAx, and CPAx 6/50.
### Response:
The abbreviated terms in the given discharge summary that requires expansion are SARS-CoV-2, ARDS, ICU, SOEB, CPAx, and CPAx 6/50. SARS-CoV-2 stands for severe acute respiratory syndrome coronavirus 2, ARDS stands for acute respiratory distress syndrome, ICU stands for intensive care unit, SOEB stands for spontaneous breathing exercise, CPAx stands for Canadian Physical Activity Assessment, and CPAx 6/50 stands for a score of 6 out of 50 on the Canadian Physical Activity Assessment
This model is released under the MIT License.