Instruction-Tuned GPT for Medicine: Applications in Oncology, Neurosurgery and Aeromedical Evacuation
Jong Hang Siong
I founded OTONOCO in Singapore to design and build SaaS and Mobile Apps that are AI-enabled to address complex problems and unmet needs in the industry.
GPT and Prompting Engineering
There's been a lot of articles and blogs and youtube videos made focusing on the chatGPT web user interface that allows specific and often one-off tasks. In this article. In this article, I present my approach of designing REUSABLE prompts to interrogate Large Language Models (LLM) for response that could potentially improve patient care and empower physicians in the field of medicine.
LLM models are becoming a great developer tool to build software applications by allowing the making of API calls to LLMs.?The strategy that I am adopting in developing GPT applications is INSTRUCTION-TUNED LLM.?In this approach, a instruction-tuned prompt consists of 2 parts, one is the instruction to teach LLM such as GPT on what to respond and how to respond given a newly discovered text.?The second part is the input text which is the newly discovered text itself.
The majority of articles on the internet may be more suited for a base LLM. ?In order to develop practical applications, instruction-tuned would be a better option. This article stresses on using instruction-tuned LLMs.?Throughout this article, we are going to find out how we phrase the instruction has a lot of bearing on the outcomes.
The Anatomy of a Reusable Prompt
The Python codes in this article were developed to interrogate OpenAI GPT 3.5.?An OpenAI API key is required to make API calls to GPT.?The instructions for setting up this prerequisite can be found at OpenAI website.
The following Python code snippet shows a simple design of a reusable prompt to perform summarization of text.?Some items of the instruction have been parameterized.?The instruction tells GPT to produce a summary on an input text.?The parameterized variables guide GPT on where to find the input text, which is looking in between triple backticks ```{text}```.?The get_gpt_response function makes an API call to OpenAI GPT and retrieves the content in return.
In the following example, an excerpt from the MD Anderson Manual of Medical Oncology was used as input text and it is assigned to the variable therapeutics_hodgkin_lymphoma.?Instructions have been design for GPT to summarize it to 1 and 5 sentences respectively.
GPT Applications for Oncology
Create Clinical Protocols from Knowledge-Based / Expert System
There is a vast amount of knowledge-based and evidence-based materials made available by healthcare providers, authors and publishers in the field of medicine.?In this example, descriptions of a methodology to diagnose chronic myelogenous leukemia (CML) is used as input text.?Instead of summarizing it, I have created an GPT instruction to create an output that is instruction-oriented so that it can be used as a step-by-step clinical protocol to diagnose this disease.
The backtick in the input text ensure the entire text is a continuing string without paragraph interruptions.
Without changing the content, will paragraph interruptions introduced to the text have any bearing on the quality or meaning to the GPT output?
It turns out separating the text into paragraphs has great impact on the meaning and quality of GPT output.?The following comparison shows continuous text produces a more instructional and action-based output while paragraphed text are more knowledge and information based.
Improve Patient Care - Bridging the Language Gap Between Doctor and Patient
Medical journal articles, textbooks, clinical practice guidelines, protocols are often written in great technical length, breadth and depth.?Not all information are relevant to all readers.?Prompts instructions can be designed to get GPT to extract relevant information for a specified target audience such as a Neurosurgeon, a Family Physician and Patient.
The following variable expert_system contains descriptions of treatments for a patient diagnosed with Stage 3 non-small cell lung carcinoma (NSCLC).?Surgery is an effective way to remove a tumor mass from the lung to prevent the cancer cells from spreading.?However, there are circumstances where a patient is inoperable or surgery is not a viable option.?Location of the tumor, patient’s age and health condition are some of the contributing factors.?In this prompt, I have modified by imposing inoperability rules to patients who are over 50 years old.?An oncologist is likely to administer chemotherapy and radiation therapy in this case.
The mock patient in clinical_findings is an female ethnic Chinese speaking only Chinese.
In the prompt design, I have created an instruction to compel GPT to return the results in sequentially numbered point form.?Each point is separated by a new line character.?For the 4th item in the template, I have written the instruction of “…patient’s month tongue” to determine if GPT is able to return an accurate response without giving GPT any clues what monther tongue is.
Interestingly, GPT is able to relate month tongue with “The patient speaks chinese”.?There is one peculiarity about the output.?GPT did not immediately provide the translation to the patient’s mother tongue (Chinese) but politely tells me that it would do it later by placing the translated text in the JSON object.
To further understand the behaviour of GPT, I swap the 4th instruction with the third, meaning making translation first.?As a results, GPT returns the entire descriptions of the treatment without selecting an appropriate one for the patient.?This is an undesirable output.
To pursue a better outcome, I reverted the instructions to its original version and add a new instruction which is “5 – What is the treatment in the patient’s mother tongue?”.?GPT now produces a better outcome by accurately identify the correct treatment for the patient in Chinese language.
GPT Applications in Neurosurgery
Extract Information for Remote Monitoring Neurosurgical Patient
This segment discusses a potential application of GPT to empower patients after undergoing neurosurgery.??The prompt for this application contains case presentation of the post-operative patient.?In this mock setting, the Neurosurgeon designed an instruction to allow GPT to extract useful or important information to be delivered to different target audiences, namely, the patients and their family physicians.
The case presentation has been described in Python code as follow:
领英推荐
The extract_relevant_info_audience contains a parameterized instruction for different target audience and word limit. The output on the top right corner for Neurosurgeon appears to be more in-depth as expected.?Output for the family physician appears appropriate in terms of depth and breadth.
As for the patient, although the right amount of information is presented, it is in third-person perspective which is not so appropriate.?The output for patient needs to be improved.
The instruction for patient is modified by giving additional instruction to GPT to use second-person narrative as if GPT is the doctor speaking face-to-face to the patient.?As a result, the conversation has taken place as if doctor-patient is in session.?Interestingly, the output is now more counselling in nature.?An improvement definitely by leaps and bounds.
GPT Applications for Aeromedical Evacuation
During the Afghanistan Conflict, Injured servicemen?at Kandahar Patients admitted to the neurosurgical intensive care unit (NICU) are among the most critically ill and unstable. Many are admitted for traumatic brain injury, aneurysmal subarachnoid hemorrhage, spinal cord injury, postoperative craniotomies, stroke, and much more. Imaging and laboratory data are the mainstays to augment clinical decision making in the NICU. NICU faces numerous challenges. The neurologic exam is rendered more difficult by sedation, intubation, and paralytics, leaving the neurosurgeon and his or her team to rely on invasive monitoring data, serial neuroimaging, and intermittently withholding sedation to assess the patient, observation is still an important component of the patient’s examination (Siddiqi, J (2019). Neurosurgical Intensive Care (p. 24). Thieme).
In this article, we shall see how GPT can be useful in empowering Neurosurgeons facing these challenges.?Although the materials used in this article are based on evidence based medicine from authoritative sources, a small amount of fictitious information has been incorporated for the purpose of demonstration of GPT applications.
Acknowlegement
Traumatic Brain Injury
Traumatic?brain injury?(TBI) is an important source of morbidity in the Iraq and Afghanistan wars. Explosion or?blast injury?is the most common cause of war injuries. The contribution of the primary blast wave (primary?blast injury) in?brain injury?is an area of active research. Individuals with?TBI?and posttraumatic stress disorder require treatment of both conditions. Families and communities need to be cognizant of the needs of these returning veterans (https://journals.lww.com/headtraumarehab/Abstract/2006/09000/Military_TBI_During_the_Iraq_and_Afghanistan_Wars.4.aspx).
The Defense and Veterans Brain Injury Center (DVBIC) report nearly 350,000 incident diagnoses of Traumatic brain injury (TBI) TBI in the U.S. military since 2000. ?Consequently, many of the veterans suffered from Posttraumatic Stress Disorder (PTS), depression, with increased risk of suicidal ideation, suicide attempts, and suicide completion. Veterans with a history of TBI are more likely to die from suicide than those without TBI.
The Walter Reed National Military Medical Center
Walter Reed National Military Medical Center (WRNMMC) is a United States military medical center located in Bethesda, Maryland. It is one of the largest and most prominent military medical centers in the nation and has provided medical care for several U.S. presidents since its opening in 1940.
Aeromedical Evacuation Procedure
Servicemen injured in the battle field due to blast penetration to the brain arrives at the base camp at Kandahar between 1 to 5 hours.?Surgery is done immediately to stabilize them.?They are then prepared to be transported on a C-17 Globemaster with pressurized cabin flown at 10,000 ft. ?The reason for relatively low altitude flight is to minimize the risk of depressurization of the brain.?The patient is first transported from Kandahar to Bagram, get checked and put back on the plane. The patient is transported from Bagram on a C-17 Globemaster aircraft to Landstuhl, Germany on an 8 hours flight.
The following diagram illustrates the flight route of transporting the injured serviceman from Kandahar, Afghanistan to Walter Reed:
Patients admitted to the neurosurgical intensive care unit (NICU) are among the most critically ill and unstable. Many are admitted for traumatic brain injury, aneurysmal subarachnoid hemorrhage, spinal cord injury, postoperative craniotomies, stroke, and much more. With the advent of improved laboratory data and advanced imaging techniques, the physical examination has become less emphasized in training. While imaging and laboratory data augment our clinical decision making, the decision to order these tests and their interpretation should be present.?This is crucial especially for patients who have fragments detected in the brain.?Transportation of injured servicemen and servicewomen from Kandahar to Walter Reed National Military Medical Center must fulfill the objective of safety with regard to progressive intracranial hemorrhages and effectiveness for preventing deep vein thrombosis (DVT) of early treatment with venous thromboembolism (VTE) chemoprophylaxis (VTC) related to penetrating brain injuries. The patients must be transported from the Kandahar to Walter-Reed in 36 hours or less. Upon landing at Landstuhl, the following evaluations are to be conducted:
GPT-Generated Flight Manifest for Aeromedical Evacuation
In this article, we’ll look at how we can apply GPT to create a Flight Manifest.?This is a fictitious manifest containing the following items:
Prompt Engineering for Aeromedical Evacuation Manifest
Information from multiple sources have been collected to built the prompt:
A template for the flight manifest is created which consists of GPT instructions and input text.
Specific instructions are given to GPT on how and what information to populate each field.?GPT in turn produces an output in the form of Python dictionary.
In order to better manage this more complex template better, a purpose-built python framework for LLM, Langchain is used. Langchain provides an abstraction by taking away the tasks of producing glue codes to orchestrate the parsing and output from the developers, making it faster to built useful apps.?
In the following code snippet, the variable flight_manifest_template which holds the template design is passed to from_template function.?The expert_system variable that holds the input text is passed to format_messages function to retrieve response from GPT.
Conclusions
The applications presented in this article have demonstrated the great potential of LLM models take on various roles, which in our case, Neurosurgeon, Oncologist, Patient and to assist in transporting injured soldiers to safety from the battlefield.?The ability of GPT to follow instruction in context makes it great candidate for AI application development for the betterment of business and humanity.
Credits
This article has also been inspired by the newly minted courses offered by DeepLearning.ai on Generative AI and GPT.