# PharmacyGPT: The AI Pharmacist

Zhengliang Liu Co-first authors. School of Computing, University of Georgia
Zihao Wu ††footnotemark:  School of Computing, University of Georgia  Mengxuan
Hu ††footnotemark:  School of Computing, University of Georgia  Bokai Zhao
Department of Epidemiology & Biostatistics, University of Georgia  Lin Zhao
School of Computing, University of Georgia  Tianyi Zhang  Department of
Statistics, University of Georgia  Haixing Dai  School of Computing,
University of Georgia  Xianyan Chen  Department of Statistics, University of
Georgia  Ye Shen  Department of Epidemiology & Biostatistics, University of
Georgia  Sheng Li  School of Data Science, University of Virginia  Brian
Murray  Department of Pharmacy, University of North Carolina Medical Center
Tianming Liu  School of Computing, University of Georgia  Andrea Sikora
Department of Clinical and Administrative Pharmacy, University of Georgia
College of Pharmacy

###### Abstract

In this study, we introduce PharmacyGPT, a novel framework to assess the
capabilities of large language models (LLMs) such as ChatGPT and GPT-4 in
emulating the role of clinical pharmacists. Our methodology encompasses the
utilization of LLMs to generate comprehensible patient clusters, formulate
medication plans, and forecast patient outcomes. We conduct our investigation
using real data acquired from the intensive care unit (ICU) at the University
of North Carolina Chapel Hill (UNC) Hospital. Our analysis offers valuable
insights into the potential applications and limitations of LLMs in the field
of clinical pharmacy, with implications for both patient care and the
development of future AI-driven healthcare solutions. By evaluating the
performance of PharmacyGPT, we aim to contribute to the ongoing discourse
surrounding the integration of artificial intelligence in healthcare settings,
ultimately promoting the responsible and efficacious use of such technologies.

##  1 Introduction

In recent years, the development of large language models (LLMs) has shown
remarkable potential in a multitude of applications across various domains [1,
2, 3, 4]. Despite their impressive generalization capabilities, the
performance of LLMs in specific fields, such as pharmacy, remains under-
investigated and holds untapped potential. In this paper, we present
PharmacyGPT, the first study to apply LLMs, specifically ChatGPT and GPT-4, to
a range of clinically significant problems in the realm of pharmacy.

PharmacyGPT aims to explore the capabilities of LLMs in addressing diverse
problems of significant clinical importance [5], such as patient outcome
studies, AI-based medication prescription generation, and interpretable
clustering analysis of patients. These applications hold significant promise
for improving patient care [6] by empowering a comprehensive suite of AI-
enhanced assistance tools to clinical pharmacy providers.

Furthermore, to enhance the performance of LLMs in the pharmacy domain, we
develop a dynamic prompting approach that leverages the in-context learning
capability [7] of LLMs by constructing dynamic contexts using domain-specific
data, which is beneficial for adapting language models to specialized fields
[8, 9, 10, 11, 12]. This novel method enables the model to acquire contextual
knowledge from semantically similar examples in existing data [7, 13], thereby
improving its performance in specialized applications.

In addition to the dynamic prompting approach, we design an iterative
optimization algorithm that performs automatic evaluation on the generated
prescription results and composes the corresponding instruction prompts to
further optimize the model. This innovative technique allows us to refine
PharmacyGPT without requiring additional training data or fine-tuning the
LLMs, paving the way for efficient adaptation of LLMs in specialized fields.

We compare various approaches to optimally utilize LLMs for a range of
pharmacy tasks and aim to establiash a usecase portfolio to further inspire
future research in this direction.

This work has several key motivations and goals:

  * •

1) To open new dialogues and stimulate discussion surrounding the application
of LLMs in pharmacy.

  * •

2) To point directions for ourselves and others for future improvements in
LLM-based pharmacy applications.

  * •

3) To evaluate the strengths and limitations of ChatGPT and GPT-4 in the
pharmacy domain.

  * •

4) To provide insights for tailored data collection strategies to maximize the
potential of LLMs in pharmacy and other specialized fields.

  * •

5) To present an effective framework and use case collection for applying LLM
to pharmacy.

In conclusion, this paper introduces PharmacyGPT, a groundbreaking work that
applies LLMs to a range of significant clinical problems in pharmacy. By
establishing a foundation for future research and development, PharmacyGPT has
the potential to revolutionize pharmacy practices and enhance the overall
quality of healthcare services while addressing its key motivations and goals,
ultimately contributing to a deeper understanding and more effective use of
LLMs in specialized domains.

##  2 Related Work

###  2.1 Large language models in healthcare

Transformer-based language models such as BERT [14] and the GPT series [15,
16, 7], have revolutionized the field of natural language processing by
outperforming earlier approaches like RNN-based models [17, 2, 1, 18] in a
variety of tasks. Existing transformer-based language models can be broadly
classified into three categories: masked language models (e.g., BERT),
autoregressive models (e.g., GPT-3), and encoder-decoder models (e.g., BART
[19]). The recent development of very large language models (LLM), including
ChatGPT and GPT-4 [3], Bloomz [20], LLAMA [21] and Med-PaLM 2 [22] has gained
momentum. These models are grounded in the transformer architecture and are
built on a much grander scale.

The primary objective of large language models is to accurately learn context-
specific and domain-specific latent feature representations from input text
[14, 3, 23, 24, 25, 26]. For example, the vector representation of the word
"prescription" could vary significantly between the pharmacy domain and
general usage. Smaller language models such as BERT often necessitate
continuous pre-training and supervised fine-tuning on downstream tasks to
achieve satisfactory performance. However, large language models typically
does not require further fine-tuning and model updates while still delivering
competitive performance on diverse downstream applications [27, 25, 28, 29,
30].

Large language models (LLMs) like ChatGPT/GPT-4 have significant potential in
healthcare applications due to their advanced natural language understanding
(NLU) capabilities. The massive amounts of text generated in clinical
practices can be leveraged through LLM-powered tools. LLMs can handle diverse
and complex tasks like clinical triage classification [31], medical question-
answering [32], HIPAA-compliant data anonymization [33], radiology report
summarization [13], clinical information extraction [34] or dementia detection
[35].

In addition, the Reinforcement Learning from Human Feedback (RLHF) [36]
process incorporates human preferences and values into ChatGPT and its
successor, GPT-4, making it particularly suitable for understanding patient-
centered guidelines and human values in healthcare applications.

We aim to present the first study of employing LLMs for a wide range of tasks
and problems of significant interest in pharmacy.

###  2.2 Reasoning with LLMs

Large language models (LLMs) have shown great potential in high-level
reasoning abilities. GPT-3, for instance, has demonstrated common sense
reasoning through in-context learning. Wei et al. [37] found that LLMs can
perform better in arithmetic, deductive, and common sense reasoning when given
carefully prepared sequential prompts, decomposing multi-step problems.

Deductive reasoning: Wu et al. [32] compared the deductive reasoning abilities
of ChatGPT and GPT-4 in the specialized domain of radiology, revealing that
GPT-4 outperforms ChatGPT, with fine-tuned models requiring significant data
to match GPT-4’s performance. This suggests that creating generic reasoning
models based on LLMs for diverse tasks across various domains is viable and
practical.

Ma et al. explored LLMs’ [13] ability to comprehend radiology reports using a
dynamic prompting paradigm. They developed an iterative optimization algorithm
for automatic evaluation and prompt composition, achieving state-of-the-art
performance on MIMIC-CXR and OpenI datasets without additional training data
or LLM fine-tuning.

Abductive reasoning: Jung et al. [38] improved LLMs’ ability to make logical
explanations through maieutic prompting, but this study was limited to
question-answering style problems. Zhong et al. [30] improved from the well-
known ABL framework [39] and proposed the first comprehensive abductive
learning pipeline based on large language models.

Chain-of-thought: Chain-of-thought reasoning (CoT) is a problem-solving
approach that breaks complex problems into smaller, manageable steps,
resembling how humans naturally solve complicated problems [40]. In the
context of large language models (LLMs), CoT aims to improve the model’s
accuracy and coherence by encouraging step-by-step reasoning. A zero-shot
approach asking the LLM to "think step by step" [41] significantly improves
reasoning performance across benchmarks. Providing LLMs with more examples
(few-shot context learning) [37] enhances their performance through in-context
learning. Overall, CoT enables LLMs to effectively tackle complex reasoning
tasks.

Figure 1: Interpretable Clusters for real ICU data Figure 2: Uncovering
underlying neurological disorders of a group of patients Algorithm 1 Iterative
Optimization Algorithm for Patient Data

1:Input: Patient portrait based on demographics and symptoms

2:Initialize: $I$=Iteration times, $Thre_{S}$=Threshold of evaluation score,
$iter$=0

3:Definition: $GPT$ means ChatGPT, $Prompt_{Dy}$ means our dynamic prompt,
$Prompt_{Iter}$ means our iterative prompt, $L$ means evaluate function,
$M_{good}$ and $M_{bad}$ represent prompt merging with good and bad response

4:while $iter<I$ do

5: if $iter=0$ then

6: $output=GPT(Prompt_{Dy})$

7: else

8: $output=GPT(Prompt_{Iter})$

9: end if

10: $score=\frac{1}{N_{s}}\sum\limits_{i=0}^{N_{s}}L(output,Impression_{i})$

11: if $score>Thre_{S}$ then

12: $Prompt_{Iter}=M_{good}(Prompt_{Dy},output)$

13: else

14: $Prompt_{Iter}=M_{bad}(Prompt_{Dy},output)$

15: end if

16: $iter++$

17:end while

##  3 Methods

###  3.1 Data description

This dataset of this research was based on a study cohort of 5000 patients
aged 18 or older who were admitted for at least 24 hours to a medical,
surgical, neurosciences, cardiac, or burn ICU at the University of North
Carolina Health System (UNCHS) between October 2015 and October 2020. Only the
patient’s first ICU admission was included in the analysis. The data was
extracted from the UNCHS EHR system and Carolina Data Warehouse (CDW) by a
trained in-house data analyst.

The dataset contains patient demographics, medication administration record
(MAR) information, and patient outcomes, such as common ICU complications.
Demographics include age, sex, admission diagnosis, ICU type, MRC-ICU score at
24 hours, and APACHE II score [42] at 24 hours. The MRC-ICU [43] is a
validated score summarizing the complexity of prescribed medications in the
ICU. MAR information consists of drug, dose, route, duration, and timing of
administration.

Patient outcomes in the dataset include mortality, hospital length of stay,
delirium occurrence (defined by a positive CAM-ICU score), duration of
mechanical ventilation, duration of vasopressor use, and acute kidney injury
(defined by the presence of renal replacement therapy or a serum creatinine
greater than 1.5 times baseline). Other than textual descriptions of patient
data, for each patient, a binary value of 1 was assigned to indicate they
received a specific drug order, including drug, dose, strength, and
formulation/route. Categorical features for patient outcomes were relabeled as
numeric values, and any unknown or missing entities were counted as absences
from that event.

###  3.2 Creating Interpretable Patient Clusters

Here we describe the process for generating interpretable patient clusters
using LLM embeddings and hierarchical clustering. The following pseudo-code
algorithm outlines the steps:

  1. 1.

Feed patient information, including demographics and symptoms, into GPT-3 to
generate embedding vectors of size 1536.

  2. 2.

Use the generated embeddings as input for hierarchical clustering to create
patient clusters.

Algorithm 2 Interpretable Patient Clustering

1:procedure CreateClusters($patient\\_info$)

2:
$embedding\\_vectors\leftarrow\textit{generate\\_gpt3\\_embeddings}(patient\\_info)$

3:
$patient\\_clusters\leftarrow\textit{apply\\_hierarchical\\_clustering}(embedding\\_vectors)$

4: return $patient\\_clusters$

5:end procedure

6:function generate_gpt3_embeddings($patient\\_info$)

7: $embeddings\leftarrow[]$

8: for each $p$ in $patient\\_info$ do

9: $embedding\leftarrow\textit{GPT-3\\_embedding}(p)$

10: $\textit{append}(embeddings,embedding)$

11: end for

12: return $embeddings$

13:end function

14:function apply_hierarchical_clustering($embedding\\_vectors$)

15:
$clusters\leftarrow\textit{hierarchical\\_clustering}(embedding\\_vectors)$

16: return $clusters$

17:end function

The above algorithm describes the process of generating interpretable patient
clusters using ChatGPT embeddings and hierarchical clustering. In this method,
patient information is first transformed into 1536-dimensional embeddings
using GPT-3. These embeddings are then used as input for a hierarchical
clustering algorithm, which groups patients based on the similarity of their
embeddings. This approach aims to create accurate and interpretable patient
clusters for use in clinical decision-making.

Figure 3: Generating context for ChatGPT and GPT-4 Figure 4: Common
prescriptions by patient cluster

###  3.3 Iterative Optimization

In the iterative optimization process for PharmacyGPT, we aim to enhance the
performance of the model when generating various patient-related outputs, such
as mortality, length of ICU stay, APACHE II score range, or medication plan.
This optimization process is based on an iterative feedback loop, which
adjusts the input prompts provided to the model based on its performance in
previous iterations.

Initially, we input a dynamic prompt containing a patient portrait based on
demographics and symptoms to the ChatGPT model. After each iteration, we
calculate an evaluation score by comparing the model-generated output with a
set of reference outputs. Depending on the evaluation score, we modify the
input prompt for the next iteration. If the score is above a predefined
threshold, we merge the prompt with the generated output in a manner that
encourages the model to produce a similar response in the next iteration.
Otherwise, we modify the prompt to discourage the model from producing the
same type of output.

The iterative process continues until a predetermined number of iterations are
reached. Through this optimization method, PharmacyGPT learns to improve its
predictions and recommendations over time, as it is continually guided by the
evaluation score and feedback from previous iterations. This approach enables
PharmacyGPT to adapt and refine its output based on a better understanding of
the patient’s condition and the desired outcomes.

##  4 Results

###  4.1 Interpretable clustering

Our clustering methodology yielded clusters that closely align with the ICD-10
code categories of patients, indicating a high level of interpretability. This
alignment demonstrates the effectiveness of our approach in generating
meaningful and coherent patient groupings. Furthermore, upon inspection by
expert clinical pharmacists, there was a consensus that the resulting clusters
were reasonable and interpretable.

The group labelled as "Diverse symptoms with neurological impact" is the most
sparsely spread among the clusters, exhibiting a diverse range of symptoms on
the surface. However, our embedding analysis reveals that the majority of
patients in this group share a common underlying condition: neurological
disorders. This observation suggests that despite the presence of various
other symptoms, patients in this group are primarily affected by neurological
issues. Our approach successfully uncovers this underlying similarity,
demonstrating the capability of our clustering method in identifying
meaningful connections between patients with seemingly disparate symptom
presentations.

###  4.2 Predicting patient outcomes

We observed that the GPT-4 model fed with dynamic context and similar samples
achieved the highest accuracy among all tested models. This demonstrates the
potential of GPT-4 when applied with carefully designed context and sample
selection.

However, we also found that the precision and recall scores were not
particularly high for any of the approaches. We suspect that this may be due
to the nature of mortality prediction, which is a binary outcome (either alive
or dead at discharge). Additionally, there is a significant data imbalance
present in our dataset, with alive patients outnumbering deceased patients by
a 9 to 1 ratio. This imbalance could have adversely impacted the performance
of the models, particularly in terms of precision and recall. Future work
could involve addressing this data imbalance issue and exploring other
evaluation metrics better suited for imbalanced datasets to gain a more
comprehensive understanding of the models’ performance.

Hospital Mortality We utilize ChatGPT to predict hospital mortality based on
patient demographics and symptoms. Table 1 results indicate that imbalanced
data significantly reduces precision and F1 scores, as the deceased class in
the test set contains only 46 samples, while ChatGPT tends to make predictions
in a balanced manner. Also, different prompts do not contribute much to
improvement. Specifically, the last three rows attempt to align the diagnosis
categories of the test set with those demonstrated in the prompts: Rand-5
randomly selects five demonstrations from the training set and incorporates
them into the prompt; Freq-5 randomly selects one demonstration from the top
five most frequent diagnosis categories; Bcat-rand-5 randomly chooses five
samples with the same diagnosis category as the tested sample; and Sim-5
selects the five most similar patient information records as demonstrations.
However, even when they share similar diagnoses and symptoms, hospital
mortality can still vary since diagnoses and symptoms are identified on the
first day, and patients may stay in the hospital for weeks, during which
circumstances change.

APACHE II We employ ChatGPT and GPT-4 to predict APACHE II scores based on
patient demographics and symptoms. Table 2 results reveal that GPT-4
significantly enhances accuracy, and similar prompts perform better as the
APACHE II score is calculated on the first day, strongly correlating with
diagnoses and symptoms on that day.

###  4.3 Prescribing medication plans

In our study, we employed GPT-4 to generate medication plans for ICU patients.
However, it is important to recognize the complexity and individual nature of
ICU pharmacy regimens, which require personalized and nuanced decision-making.
As a result, it is essential to involve expert clinical pharmacists in the
evaluation process.

First, expert clinical pharmacists need to review the medication plans
generated by GPT-4 to assess their reasonableness and clinical applicability.
This will help ensure that the AI-generated plans align with current best
practices and account for the specific needs of each patient.

Second, it is crucial to devise evaluation metrics that extend beyond
traditional n-gram-based metrics, such as ROUGE, which may not be sufficient
for capturing the nuances of this new task. Developing tailored evaluation
metrics for assessing the performance of AI-generated medication plans will
enable a more comprehensive understanding of the models’ capabilities and
limitations. This, in turn, will facilitate improvements in the models and
promote the responsible integration of AI in the field of clinical pharmacy.

Overall, the outcome and medication prediction results demonstrate a promising
approach to using large language models for rapidly assessing patient
situations and providing further guidance on medication and treatment plans.

Figure 5: Medication plan generated by GPT-4 v.s. the actual plan Table 1: Mortality prediction Model | Accuracy | Precision | Recall | F1 Score
---|---|---|---|---
rand_5-shot | 0.7549 | 0.3750 | 0.7095 | 0.4898
freq_5-shot | 0.6455 | 0.1667 | 0.6364 | 0.2642
bcat_rand_5-shot | 0.6602 | 0.2051 | 0.7647 | 0.4262
sim_5-shot | 0.6699 | 0.2821 | 0.6471 | 0.3929
Figure 6: Common prescriptions by patient cluster Table 2: APACHE 2 score prediction Model | Accuracy
---|---
rand_5-shot | 0.1818
freq_5-shot | 0.1091
bcat_rand_5-shot | 0.2000
sim_5-shot | 0.1636
GPT-4_rand_5 | 0.3727
GPT-4_sim_5 | 0.4364

##  5 Discussion

###  5.1 Addressing AI anxiety in healthcare

In this discussion section, we address the issue of AI anxiety in healthcare
[44], particularly among physicians and pharmacists who may be concerned about
AI systems replacing their roles [45]. It is crucial to recognize the
potential benefits of AI, such as improved patient care quality and increased
efficiency in clinical practice, while also acknowledging the limitations of
current AI systems, specifically large language models (LLMs) like ChatGPT and
GPT-4 [4, 2].

Our study has demonstrated that LLMs can provide valuable suggestions and
identify patterns in patient data, but they possess limitations that
underscore the continued importance of human expertise in healthcare. One such
limitation is the lack of access to comprehensive patient histories and
records. This constraint prevents LLMs from fully understanding the context of
a patient’s condition, which is crucial for making accurate and relevant
recommendations.

Moreover, LLMs struggle to comprehend complex clinical information or produce
delicate clinical descriptions [46]. These models are primarily trained on
textual data and may not have sufficient exposure to specialized medical
terminology, complex concepts, or rare conditions, which are vital for
effective decision-making in healthcare [46, 47].

Another area where LLMs face challenges (to some degree) is in interpreting
time series data [48, 49] and numerical data [50]. The dynamic nature of
healthcare often requires an understanding of changes in a patient’s condition
over time and the ability to analyze numerical information, such as laboratory
test results and vital signs. LLMs currently lack the sophistication to fully
grasp these aspects of patient care.

The findings of our study suggest that there is no inherent contradiction
between embracing AI technologies and preserving the roles of healthcare
professionals. Instead, LLMs can be seen as a valuable complement to human
expertise, providing support and suggestions while healthcare professionals
retain ultimate responsibility for patient care. By combining the strengths of
AI with the insights and experience of medical professionals, we can work
towards a more efficient and effective healthcare system that benefits
patients, providers, and society as a whole.

###  5.2 Improving LLMs for pharmacy

Firstly, training LLMs on domain-specific patient data [8, 18] is an
established strategy for enhancing their performance in specialized domains.
By exposing the model to a larger amount of pharmacy-related data, it will
acquire a deeper understanding of the domain’s nuances, terminology, and
knowledge. This targeted training can lead to improvements in the model’s
ability to generate relevant, accurate, and contextually appropriate responses
for various pharmacy tasks.

Secondly, refining the model architecture to better align with the specific
tasks and objectives in pharmacy can also lead to improvements. By designing
customized architectures that cater to the unique requirements of pharmacy
applications, LLMs can become more effective in addressing domain-specific
challenges [18]. This may involve the development of task-specific layers,
attention mechanisms, or other architectural components [10, 18] that are
tailored to the needs of pharmacy-related tasks.

Moreover, localizing large language models to adhere to Health Insurance
Portability and Accountability Act (HIPAA) patient guidelines [33] is crucial
for processing sensitive patient data in hospitals. Ensuring that LLMs are
compliant with privacy and security regulations is a vital aspect of their
adoption in clinical settings [51]. One approach to achieve this is to develop
local, on-premises versions of LLMs that can be integrated into hospital
systems, thereby eliminating the need to transmit sensitive data over the
internet. Alternatively, techniques such as federated learning [52] or secure
multi-party computation [53] can be employed to train LLMs on sensitive data
while maintaining patient privacy.

###  5.3 Building AI-friendly datasets in pharmacy

Our results indicate a strong need to create LLM-friendly datasets in
pharmacy.

The foremost approach is to collect more detailed text-based patient
information. This may include extensive documentation of patient histories,
treatment plans, and progress notes, which would provide LLMs with a wealth of
contextual information for generating accurate and relevant responses.
Additionally, incorporating data on patient symptoms, along with standardized
clinical assessment scores such as APACHE II [42], SOFA [54], and MRC-ICU
[43], would offer LLMs a more comprehensive understanding of patient
conditions, enabling them to make better-informed predictions and
recommendations.

Extending the duration of data collection beyond traditional 24-hour or
72-hour windows is another important consideration. By capturing a more
extensive timeline of patient information, LLMs can gain deeper insights into
the progression of diseases and the effectiveness of different treatment
strategies. This longitudinal data would allow LLMs to identify trends, assess
long-term outcomes, and provide more accurate predictions for patient recovery
and risk factors.

Furthermore, standardizing drug descriptions, including dosage numbers and
frequencies, is crucial for creating an LLM-friendly dataset in pharmacy. This
standardization can help eliminate ambiguities and inconsistencies in the
data, ensuring that LLMs can accurately interpret and generate relevant
information about medications. Moreover, the inclusion of drug interactions,
contraindications, and side effects can further enhance the LLM’s ability to
provide safe and effective medication recommendations.

Incorporating diverse data sources, such as electronic health records,
clinical trial results, and relevant scientific literature, can provide LLMs
with a more comprehensive understanding of the pharmacy domain. By integrating
these diverse sources of information, LLMs can develop a more robust knowledge
base, enabling them to generate better-informed responses and recommendations
for various pharmacy tasks.

###  5.4 Define appropriate NLP tasks and metrics for pharmacy

In order to effectively apply large language models (LLMs) to the pharmacy
domain, it is essential to define relevant natural language processing (NLP)
tasks and develop suitable evaluation metrics. Common NLP tasks include
question answering (QA) and summarization [3], while specialized tasks involve
AI-generated prescription plans and outcome predictions. Traditional NLP
evaluation metrics, such as n-gram-based ROUGE scores [55] and METEOR scores
[56], may not be reasonably applied to these specialized tasks, as they
prioritize similarity between generated and reference texts rather than
accuracy, safety, and adherence to clinical guidelines.

To address this challenge, domain experts should collaborate to develop
specialized evaluation metrics that capture the unique aspects of pharmacy-
related tasks. For instance, metrics could assess the correctness of AI-
generated prescriptions or the alignment of predicted outcomes with actual
patient outcomes, considering sensitivity, specificity, and overall accuracy.

Defining appropriate NLP tasks and developing tailored evaluation metrics for
pharmacy applications is crucial for the successful integration of LLMs in
this domain. Collaboration between NLP researchers and pharmacy experts is
essential to ensure that these models can effectively contribute to improved
patient care and clinical practice efficiency.

###  5.5 Developing Multimodal Foundation Models for Pharmacy

As the field of artificial intelligence has evolved, the concept of multimodal
learning, encompassing the ability to process and integrate data from various
sources such as text, images, audio, and structured data, has gained
substantial attention [4]. This approach is of great value in the pharmacy
domain, given the wide variety of data types available, from textual patient
notes to numerical lab results, diagnostic images, and structured demographic
or medication data.

Transformer-based architectures, like those found in large language models
(LLMs) such as GPT-4, are well-suited to handle diverse types of sequence data
and learn intricate patterns within them [18, 4]. These capabilities make them
an excellent foundation for developing multimodal models in healthcare and
pharmacy. Transformers have proven performance in NLP [1] and have
demonstrated success in domains traditionally dominated by convolutional
neural network (CNN) based models, including computer vision [57, 58, 59] and
medical image applications [57, 60, 61, 62, 63, 64, 65, 66]. Additionally,
they have been utilized in other modalities such as modeling human brain
functions [67, 68]. For example, it powers vision foundation models such as
the Segment Anything Model (SAM) [69, 70, 71]. This demonstrates their
flexibility and potential in handling multiple data modalities [4].

The multimodal models for pharmacy would involve creating distinct input
pathways for each type of data, each leveraging the self-attention mechanisms
of transformers. After processing each modality independently, the outputs can
be integrated to generate a comprehensive patient representation. This fusion
can be guided by various strategies and can determine which features from each
modality are most relevant for a given task.

When trained on a diverse dataset of patients, a multimodal foundation model
could potentially generate more accurate and personalized medication plans by
considering the full range of patient data. In this way, the model can provide
an in-depth understanding of the patient’s current health status, medication
needs, and potential risk factors, leading to more effective and tailored
pharmaceutical care.

##  6 Conclusion

In conclusion, our exploration into the application of large language models
in pharmacy, embodied by PharmacyGPT, illuminates promising avenues for future
development. Despite the evident challenges, we believe that leveraging LLMs
can drastically enhance the accuracy, personalization, and efficiency of
medication plan generation. The potential for improved patient outcomes and
streamlined pharmaceutical operations is significant. As we continue to refine
these models, a keen focus on the incorporation of expert knowledge, carefully
designed training datasets, and development of tailored metrics for model
evaluation will be crucial. By continuing to intertwine AI with pharmacy, we
stand at the precipice of a new era of healthcare where AI augments the
crucial human component, leading to comprehensive, high-quality patient care.

## References

  * [1] Lin Zhao, Lu Zhang, Zihao Wu, Yuzhong Chen, Haixing Dai, Xiaowei Yu, Zhengliang Liu, Tuo Zhang, Xintao Hu, Xi Jiang, et al.  When brain-inspired ai meets agi.  Meta-Radiology, page 100005, 2023.
  * [2] Jason Holmes, Zhengliang Liu, Lian Zhang, Yuzhen Ding, Terence T Sio, Lisa A McGee, Jonathan B Ashman, Xiang Li, Tianming Liu, Jiajian Shen, et al.  Evaluating large language models on a highly-specialized topic, radiation oncology physics.  arXiv preprint arXiv:2304.01938, 2023.
  * [3] Yiheng Liu, Tianle Han, Siyuan Ma, Jiayue Zhang, Yuanyuan Yang, Jiaming Tian, Hao He, Antong Li, Mengshen He, Zhengliang Liu, et al.  Summary of chatgpt/gpt-4 research and perspective towards the future of large language models.  arXiv preprint arXiv:2304.01852, 2023.
  * [4] Xiang Li, Lu Zhang, Zihao Wu, Zhengliang Liu, Lin Zhao, Yixuan Yuan, Jun Liu, Gang Li, Dajiang Zhu, Pingkuan Yan, et al.  Artificial general intelligence for medical imaging.  arXiv preprint arXiv:2306.05480, 2023.
  * [5] Centaine L Snoswell, Nazanin Falconer, and Aaron J Snoswell.  Pharmacist vs machine: pharmacy services in the age of large language models, 2023.
  * [6] Yun Zhu, Dan Han, Shaoqing Chen, Feng Zeng, and Cheng Wang.  How can chatgpt benefit pharmacy: A case report on review writing.  2023\.
  * [7] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al.  Language models are few-shot learners.  Advances in neural information processing systems, 33:1877–1901, 2020.
  * [8] Yu Gu, Robert Tinn, Hao Cheng, Michael Lucas, Naoto Usuyama, Xiaodong Liu, Tristan Naumann, Jianfeng Gao, and Hoifung Poon.  Domain-specific language model pretraining for biomedical natural language processing.  ACM Transactions on Computing for Healthcare (HEALTH), 3(1):1–23, 2021.
  * [9] Zhengliang Liu, Aoxiao Zhong, Yiwei Li, Longtao Yang, Chao Ju, Zihao Wu, Chong Ma, Peng Shu, Cheng Chen, Sekeun Kim, et al.  Radiology-gpt: A large language model for radiology.  arXiv preprint arXiv:2306.08666, 2023.
  * [10] Saed Rezayi, Zhengliang Liu, Zihao Wu, Chandra Dhakal, Bao Ge, Chen Zhen, Tianming Liu, and Sheng Li.  Agribert: knowledge-infused agricultural language models for matching food and nutrition.  IJCAI, 2022.
  * [11] Saed Rezayi, Haixing Dai, Zhengliang Liu, Zihao Wu, Akarsh Hebbar, Andrew H Burns, Lin Zhao, Dajiang Zhu, Quanzheng Li, Wei Liu, et al.  Clinicalradiobert: Knowledge-infused few shot learning for clinical notes named entity recognition.  In Machine Learning in Medical Imaging: 13th International Workshop, MLMI 2022, Held in Conjunction with MICCAI 2022, Singapore, September 18, 2022, Proceedings, pages 269–278. Springer, 2022.
  * [12] Homgmin Cai, Wenxiong Liao, Zhengliang Liu, Xiaoke Huang, Yiyang Zhang, Siqi Ding, Sheng Li, Quanzheng Li, Tianming Liu, and Xiang Li.  Coarse-to-fine knowledge graph domain adaptation based on distantly-supervised iterative training.  arXiv preprint arXiv:2211.02849, 2022.
  * [13] Chong Ma, Zihao Wu, Jiaqi Wang, Shaochen Xu, Yaonai Wei, Zhengliang Liu, Lei Guo, Xiaoyan Cai, Shu Zhang, Tuo Zhang, et al.  Impressiongpt: An iterative optimizing framework for radiology report summarization with chatgpt.  arXiv preprint arXiv:2304.08448, 2023.
  * [14] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova.  Bert: Pre-training of deep bidirectional transformers for language understanding.  arXiv preprint arXiv:1810.04805, 2018.
  * [15] Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever, et al.  Improving language understanding by generative pre-training.  2018\.
  * [16] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al.  Language models are unsupervised multitask learners.  OpenAI blog, 1(8):9, 2019.
  * [17] Lizhou Fan, Lingyao Li, Zihui Ma, Sanggyu Lee, Huizi Yu, and Libby Hemphill.  A bibliometric review of large language models research from 2017 to 2023\.  arXiv preprint arXiv:2304.02020, 2023.
  * [18] Zhengliang Liu, Mengshen He, Zuowei Jiang, Zihao Wu, Haixing Dai, Lian Zhang, Siyi Luo, Tianle Han, Xiang Li, Xi Jiang, et al.  Survey on natural language processing in medical image analysis.  Zhong nan da xue xue bao. Yi xue ban= Journal of Central South University. Medical Sciences, 47(8):981–993, 2022.
  * [19] Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer.  Bart: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension.  arXiv preprint arXiv:1910.13461, 2019.
  * [20] Niklas Muennighoff, Thomas Wang, Lintang Sutawika, Adam Roberts, Stella Biderman, Teven Le Scao, M Saiful Bari, Sheng Shen, Zheng-Xin Yong, Hailey Schoelkopf, et al.  Crosslingual generalization through multitask finetuning.  arXiv preprint arXiv:2211.01786, 2022.
  * [21] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al.  Llama: Open and efficient foundation language models.  arXiv preprint arXiv:2302.13971, 2023.
  * [22] Karan Singhal, Shekoofeh Azizi, Tao Tu, S Sara Mahdavi, Jason Wei, Hyung Won Chung, Nathan Scales, Ajay Tanwani, Heather Cole-Lewis, Stephen Pfohl, et al.  Large language models encode clinical knowledge.  arXiv preprint arXiv:2212.13138, 2022.
  * [23] Zhengliang Liu, Xinyu He, Lei Liu, Tianming Liu, and Xiaoming Zhai.  Context matters: A strategy to pre-train language model for science education.  arXiv preprint arXiv:2301.12031, 2023.
  * [24] Mengyue Zhou, Xu Liu, David Liu, Zihao Wu, Zhengliang Liu, Lin Zhao, Dajiang Zhu, Lei Guo, Junwei Han, Tianming Liu, et al.  Fine-grained artificial neurons in audio-transformers for disentangling neural auditory encoding.  In Findings of the Association for Computational Linguistics: ACL 2023, pages 7943–7956, 2023.
  * [25] Hongmin Cai, Xiaoke Huang, Zhengliang Liu, Wenxiong Liao, Haixing Dai, Zihao Wu, Dajiang Zhu, Hui Ren, Quanzheng Li, Tianming Liu, et al.  Exploring multimodal approaches for alzheimer’s disease detection using patient speech transcript and audio data.  arXiv preprint arXiv:2307.02514, 2023.
  * [26] Wenxiong Liao, Zhengliang Liu, Haixing Dai, Zihao Wu, Yiyang Zhang, Xiaoke Huang, Yuzhong Chen, Xi Jiang, Dajiang Zhu, Tianming Liu, et al.  Mask-guided bert for few shot text classification.  arXiv preprint arXiv:2302.10447, 2023.
  * [27] Haixing Dai, Zhengliang Liu, Wenxiong Liao, Xiaoke Huang, Zihao Wu, Lin Zhao, Wei Liu, Ninghao Liu, Sheng Li, Dajiang Zhu, et al.  Chataug: Leveraging chatgpt for text data augmentation.  arXiv preprint arXiv:2302.13007, 2023.
  * [28] Wenxiong Liao, Zhengliang Liu, Haixing Dai, Shaochen Xu, Zihao Wu, Yiyang Zhang, Xiaoke Huang, Dajiang Zhu, Hongmin Cai, Tianming Liu, et al.  Differentiate chatgpt-generated and human-written medical texts.  arXiv preprint arXiv:2304.11567, 2023.
  * [29] Haixing Dai, Yiwei Li, Zhengliang Liu, Lin Zhao, Zihao Wu, Suhang Song, Ye Shen, Dajiang Zhu, Xiang Li, Sheng Li, et al.  Ad-autogpt: An autonomous gpt for alzheimer’s disease infodemiology.  arXiv preprint arXiv:2306.10095, 2023.
  * [30] Tianyang Zhong, Yaonai Wei, Li Yang, Zihao Wu, Zhengliang Liu, Xiaozheng Wei, Wenjun Li, Junjie Yao, Chong Ma, Xiang Li, et al.  Chatabl: Abductive learning via natural language interaction with chatgpt.  arXiv preprint arXiv:2304.11107, 2023.
  * [31] Xinyuan Wang, Make Tao, Runpu Wang, and Likui Zhang.  Reduce the medical burden: An automatic medical triage system using text classification bert based on transformer structure.  In 2021 2nd International Conference on Big Data & Artificial Intelligence & Software Engineering (ICBASE), pages 679–685. IEEE, 2021.
  * [32] Zihao Wu, Lu Zhang, Chao Cao, Xiaowei Yu, Haixing Dai, Chong Ma, Zhengliang Liu, Lin Zhao, Gang Li, Wei Liu, et al.  Exploring the trade-offs: Unified large language models vs local fine-tuned models for highly-specific radiology nli task.  arXiv preprint arXiv:2304.09138, 2023.
  * [33] Zhengliang Liu, Xiaowei Yu, Lu Zhang, Zihao Wu, Chao Cao, Haixing Dai, Lin Zhao, Wei Liu, Dinggang Shen, Quanzheng Li, et al.  Deid-gpt: Zero-shot medical text de-identification by gpt-4.  arXiv preprint arXiv:2303.11032, 2023.
  * [34] Miao Chen, Ganhui Lan, Fang Du, and Victor Lobanov.  Joint learning with pre-trained transformer on named entity recognition and relation extraction tasks for clinical analytics.  In Proceedings of the 3rd Clinical Natural Language Processing Workshop, pages 234–242, 2020.
  * [35] Ploypaphat Saltz, Shih Yin Lin, Sunny Chieh Cheng, and Dong Si.  Dementia detection using transformer-based deep learning and natural language processing models.  In 2021 IEEE 9th International Conference on Healthcare Informatics (ICHI), pages 509–510. IEEE, 2021.
  * [36] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al.  Training language models to follow instructions with human feedback.  arXiv preprint arXiv:2203.02155, 2022.
  * [37] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou.  Chain of thought prompting elicits reasoning in large language models.  arXiv preprint arXiv:2201.11903, 2022.
  * [38] Jaehun Jung, Lianhui Qin, Sean Welleck, Faeze Brahman, Chandra Bhagavatula, Ronan Le Bras, and Yejin Choi.  Maieutic prompting: Logically consistent reasoning with recursive explanations.  arXiv preprint arXiv:2205.11822, 2022.
  * [39] Zhi-Hua Zhou.  Abductive learning: towards bridging machine learning and logical reasoning.  Science China Information Sciences, 62:1–3, 2019.
  * [40] Abulhair Saparov and He He.  Language models are greedy reasoners: A systematic formal analysis of chain-of-thought.  arXiv preprint arXiv:2210.01240, 2022.
  * [41] Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa.  Large language models are zero-shot reasoners.  arXiv preprint arXiv:2205.11916, 2022.
  * [42] Michael Larvin and MichaelJ Mcmahon.  Apache-ii score for assessment and monitoring of acute pancreatitis.  The Lancet, 334(8656):201–205, 1989.
  * [43] Andrea Sikora Newsome, Susan E Smith, William J Olney, Timothy W Jones, Christy C Forehand, Ah Hyun Jun, and Lindsey Coppiano.  Medication regimen complexity is associated with pharmacist interventions and drug-drug interactions: A use of the novel mrc-icu scoring tool.  Journal of the American College of Clinical Pharmacy, 3(1):47–56, 2020.
  * [44] Robert Sparrow and Joshua Hatherley.  High hopes for “deep medicine”? ai, economics, and the future of care.  Hastings Center Report, 50(1):14–17, 2020.
  * [45] Songhee Oh, Jae Heon Kim, Sung-Woo Choi, Hee Jeong Lee, Jungrak Hong, and Soon Hyo Kwon.  Physician confidence in artificial intelligence: an online mobile survey.  Journal of medical Internet research, 21(3):e12422, 2019.
  * [46] Raju Vaishya, Anoop Misra, and Abhishek Vaish.  Chatgpt: Is this version good for healthcare and research?  Diabetes & Metabolic Syndrome: Clinical Research & Reviews, 17(4):102744, 2023.
  * [47] Malik Sallam.  Chatgpt utility in healthcare education, research, and practice: Systematic review on the promising perspectives and valid concerns.  In Healthcare, volume 11, page 887. MDPI, 2023.
  * [48] Christian M Boßelmann, Costin Leu, and Dennis Lal.  Are ai language models such as chatgpt ready to improve the care of individuals with epilepsy?  Epilepsia, 2023.
  * [49] Qianqian Xie, Weiguang Han, Yanzhao Lai, Min Peng, and Jimin Huang.  The wall street neophyte: A zero-shot analysis of chatgpt over multimodal stock movement prediction challenges.  arXiv preprint arXiv:2304.05351, 2023.
  * [50] Simon Frieder, Luca Pinchetti, Ryan-Rhys Griffiths, Tommaso Salvatori, Thomas Lukasiewicz, Philipp Christian Petersen, Alexis Chevalier, and Julius Berner.  Mathematical capabilities of chatgpt.  arXiv preprint arXiv:2301.13867, 2023.
  * [51] Stefano Silvestri and Francesco Gargiulo.  Special issue on big data for ehealth applications, 2022.
  * [52] Dinh C Nguyen, Quoc-Viet Pham, Pubudu N Pathirana, Ming Ding, Aruna Seneviratne, Zihuai Lin, Octavia Dobre, and Won-Joo Hwang.  Federated learning for smart healthcare: A survey.  ACM Computing Surveys (CSUR), 55(3):1–37, 2022.
  * [53] Dong Li, Xiaofeng Liao, Tao Xiang, Jiahui Wu, and Junqing Le.  Privacy-preserving self-serviced medical diagnosis scheme based on secure multi-party computation.  Computers & Security, 90:101701, 2020.
  * [54] Simon Lambden, Pierre Francois Laterre, Mitchell M Levy, and Bruno Francois.  The sofa score—development, utility and challenges of accurate assessment in clinical trials.  Critical Care, 23(1):1–9, 2019.
  * [55] Chin-Yew Lin.  Rouge: A package for automatic evaluation of summaries.  In Text summarization branches out, pages 74–81, 2004.
  * [56] Satanjeev Banerjee and Alon Lavie.  Meteor: An automatic metric for mt evaluation with improved correlation with human judgments.  In Proceedings of the acl workshop on intrinsic and extrinsic evaluation measures for machine translation and/or summarization, pages 65–72, 2005.
  * [57] Jiaqi Wang, Zhengliang Liu, Lin Zhao, Zihao Wu, Chong Ma, Sigang Yu, Haixing Dai, Qiushi Yang, Yiheng Liu, Songyao Zhang, et al.  Review of large vision models and visual prompt engineering.  arXiv preprint arXiv:2307.00855, 2023.
  * [58] Haixing Dai, Lu Zhang, Lin Zhao, Zihao Wu, Zhengliang Liu, David Liu, Xiaowei Yu, Yanjun Lyu, Changying Li, Ninghao Liu, et al.  Hierarchical semantic tree concept whitening for interpretable image classification.  arXiv preprint arXiv:2307.04343, 2023.
  * [59] Xia-An Bi, Ke Chen, Siyu Jiang, Sheng Luo, Wenyan Zhou, Zhaoxu Xing, Luyun Xu, Zhengliang Liu, and Tianming Liu.  Community graph convolution neural network for alzheimer’s disease classification and pathogenetic factors identification.  IEEE Transactions on Neural Networks and Learning Systems, 2023\.
  * [60] Shu Zhang, Enze Shi, Lin Wu, Ruoyang Wang, Sigang Yu, Zhengliang Liu, Shaochen Xu, Tianming Liu, and Shijie Zhao.  Differentiating brain states via multi-clip random fragment strategy-based interactive bidirectional recurrent neural network.  Neural Networks, 2023.
  * [61] Lian Zhang, Jason M Holmes, Zhengliang Liu, Sujay A Vora, Terence T Sio, Carlos E Vargas, Nathan Y Yu, Sameer R Keole, Steven E Schild, Martin Bues, et al.  Beam mask and sliding window-facilitated deep learning-based accurate and efficient dose prediction for pencil beam scanning proton therapy.  arXiv preprint arXiv:2305.18572, 2023.
  * [62] Yuzhen Ding, Hongying Feng, Yunze Yang, Jason Holmes, Zhengliang Liu, David Liu, William W Wong, Nathan Y Yu, Terence T Sio, Steven E Schild, et al.  Deep-learning based fast and accurate 3d ct deformable image registration in lung cancer.  Medical Physics, 2023.
  * [63] Haixing Dai, Qing Li, Lin Zhao, Liming Pan, Cheng Shi, Zhengliang Liu, Zihao Wu, Lu Zhang, Shijie Zhao, Xia Wu, et al.  Graph representation neural architecture search for optimal spatial/temporal functional brain network decomposition.  In International Workshop on Machine Learning in Medical Imaging, pages 279–287. Springer, 2022.
  * [64] Y Ding, Z Liu, H Feng, J Holmes, Y Yang, N Yu, T Sio, S Schild, B Li, and W Liu.  Accurate and efficient deep neural network based deformable image registration method in lung cancer.  In MEDICAL PHYSICS, volume 49, pages E148–E148. WILEY 111 RIVER ST, HOBOKEN 07030-5774, NJ USA, 2022.
  * [65] Ning Qiang, Qinglin Dong, Jie Gao, Jin Li, Shu Zhang, Hongtao Liang, Yifei Sun, Bao Ge, Zhengliang Liu, Zihao Wu, et al.  A deep learning method for autism spectrum disorder identification based on interactions of hierarchical brain networks.  Available at SSRN 4309357.
  * [66] Yiheng Liu, Enjie Ge, Mengshen He, Zhengliang Liu, Shijie Zhao, Xintao Hu, Dajiang Zhu, Tianming Liu, and Bao Ge.  Discovering dynamic functional brain networks via spatial and channel-wise attention.  arXiv preprint arXiv:2205.09576, 2022.
  * [67] Lin Zhao, Zihao Wu, Haixing Dai, Zhengliang Liu, Xintao Hu, Tuo Zhang, Dajiang Zhu, and Tianming Liu.  A generic framework for embedding human brain function with temporally correlated autoencoder.  Medical Image Analysis, page 102892, 2023.
  * [68] Lin Zhao, Zihao Wu, Haixing Dai, Zhengliang Liu, Tuo Zhang, Dajiang Zhu, and Tianming Liu.  Embedding human brain function via transformer.  In International Conference on Medical Image Computing and Computer-Assisted Intervention, pages 366–375. Springer, 2022.
  * [69] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al.  Segment anything.  arXiv preprint arXiv:2304.02643, 2023.
  * [70] Lian Zhang, Zhengliang Liu, Lu Zhang, Zihao Wu, Xiaowei Yu, Jason Holmes, Hongying Feng, Haixing Dai, Xiang Li, Quanzheng Li, et al.  Segment anything model (sam) for radiation oncology.  arXiv preprint arXiv:2306.11730, 2023.
  * [71] Haixing Dai, Chong Ma, Zhengliang Liu, Yiwei Li, Peng Shu, Xiaozheng Wei, Lin Zhao, Zihao Wu, Dajiang Zhu, Wei Liu, et al.  Samaug: Point prompt augmentation for segment anything model.  arXiv preprint arXiv:2307.01187, 2023.