Views
No views yet
1prompt = """You are an intelligent clinical languge model.
2Below is a snippet of patient's discharge summary and a following instruction from healthcare professional.
3Write a response that appropriately completes the instruction.
4The response should provide the accurate answer to the instruction, while being concise.
5
6[Discharge Summary Begin]
7{note}
8[Discharge Summary End]
9
10[Instruction Begin]
11{question}
12[Instruction End]
13"""
14
15from transformers import AutoTokenizer, AutoModelForCausalLM
16tokenizer = AutoTokenizer.from_pretrained("starmpcc/Asclepius-Mistral-7B-v0.3", use_fast=False)
17model = AutoModelForCausalLM.from_pretrained("starmpcc/Asclepius-Mistral-7B-v0.3")
18
19note = "This is a sample note"
20question = "What is the diagnosis?"
21
22model_input = prompt.format(note=note, question=question)
23input_ids = tokenizer(model_input, return_tensors="pt").input_ids
24output = model.generate(input_ids)
25print(tokenizer.decode(output[0]))@article{kweon2023publicly,
title={Publicly Shareable Clinical Large Language Model Built on Synthetic Clinical Notes},
author={Kweon, Sunjun and Kim, Junu and Kim, Jiyoun and Im, Sujeong and Cho, Eunbyeol and Bae, Seongsu and Oh, Jungwoo and Lee, Gyubok and Moon, Jong Hak and You, Seng Chan and others},
journal={arXiv preprint arXiv:2309.00237},
year={2023}
}