# documents

url: https://arxiv.org/html/2310.14735v4
title: Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review
scrape_date: 2025-03-17T12:00:37.144743
content_type: markdown
hash: 373962067580e3a98567145500d24f28021537ec7d6fc3006d77999bda4e57f5
content:
  1. [1 Introduction](https://arxiv.org/html/2310.14735v4#S1 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  2. [2 Basics of prompt engineering](https://arxiv.org/html/2310.14735v4#S2 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    1. [2.1 Model introduction: GPT-4](https://arxiv.org/html/2310.14735v4#S2.SS1 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    2. [2.2 Giving instructions](https://arxiv.org/html/2310.14735v4#S2.SS2 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    3. [2.3 Be clear and precise](https://arxiv.org/html/2310.14735v4#S2.SS3 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    4. [2.4 Role-prompting](https://arxiv.org/html/2310.14735v4#S2.SS4 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    5. [2.5 Use of triple quotes to separate](https://arxiv.org/html/2310.14735v4#S2.SS5 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    6. [2.6 Try several times](https://arxiv.org/html/2310.14735v4#S2.SS6 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    7. [2.7 One-shot or few-shot prompting](https://arxiv.org/html/2310.14735v4#S2.SS7 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    8. [2.8 LLM settings: temperature and top-p](https://arxiv.org/html/2310.14735v4#S2.SS8 "In 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  3. [3 Advanced methodologies](https://arxiv.org/html/2310.14735v4#S3 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    1. [3.1 Chain of thought](https://arxiv.org/html/2310.14735v4#S3.SS1 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
      1. [3.1.1 Zero-shot chain of thought](https://arxiv.org/html/2310.14735v4#S3.SS1.SSS1 "In 3.1 Chain of thought ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
      2. [3.1.2 Golden chain of thought](https://arxiv.org/html/2310.14735v4#S3.SS1.SSS2 "In 3.1 Chain of thought ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    2. [3.2 Self-consistency](https://arxiv.org/html/2310.14735v4#S3.SS2 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    3. [3.3 Generated knowledge](https://arxiv.org/html/2310.14735v4#S3.SS3 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    4. [3.4 Least-to-most prompting](https://arxiv.org/html/2310.14735v4#S3.SS4 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    5. [3.5 Tree of thoughts](https://arxiv.org/html/2310.14735v4#S3.SS5 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    6. [3.6 Graph of thoughts](https://arxiv.org/html/2310.14735v4#S3.SS6 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    7. [3.7 Retrieval augmentation](https://arxiv.org/html/2310.14735v4#S3.SS7 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    8. [3.8 Use plugins to polish the prompts](https://arxiv.org/html/2310.14735v4#S3.SS8 "In 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  4. [4 Prospective methodologies](https://arxiv.org/html/2310.14735v4#S4 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    1. [4.1 Better understanding of structures](https://arxiv.org/html/2310.14735v4#S4.SS1 "In 4 Prospective methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    2. [4.2 Agent for AIGC tools](https://arxiv.org/html/2310.14735v4#S4.SS2 "In 4 Prospective methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  5. [5 Assessing the efficacy of prompt methods](https://arxiv.org/html/2310.14735v4#S5 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    1. [5.1 Subjective and objective evaluations](https://arxiv.org/html/2310.14735v4#S5.SS1 "In 5 Assessing the efficacy of prompt methods ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    2. [5.2 Comparing different prompt methods](https://arxiv.org/html/2310.14735v4#S5.SS2 "In 5 Assessing the efficacy of prompt methods ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  6. [6 Applications improved by prompt engineering](https://arxiv.org/html/2310.14735v4#S6 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    1. [6.1 Assessment in teaching and learning](https://arxiv.org/html/2310.14735v4#S6.SS1 "In 6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    2. [6.2 Content creation and editing](https://arxiv.org/html/2310.14735v4#S6.SS2 "In 6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    3. [6.3 Computer programming](https://arxiv.org/html/2310.14735v4#S6.SS3 "In 6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    4. [6.4 Reasoning tasks](https://arxiv.org/html/2310.14735v4#S6.SS4 "In 6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
    5. [6.5 Dataset generation](https://arxiv.org/html/2310.14735v4#S6.SS5 "In 6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  7. [7 Conclusion](https://arxiv.org/html/2310.14735v4#S7 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")
  8. [8 Acknowledgement](https://arxiv.org/html/2310.14735v4#S8 "In Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")



[1]\fnmNicolas \surLangrené [2,1]\fnmShengxin \surZhu

1]\orgnameGuangdong Provincial Key Laboratory of Interdisciplinary Research and Application for Data Science, BNU-HKBU United International College, \orgaddress\cityZhuhai \postcode519087, \countryChina 2]\orgnameResearch Center for Mathematics, Beijing Normal University, \orgaddress\streetNo.18, Jingfeng Road, \cityZhuhai \postcode519087, \stateGuangdong, \countryChina

# Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review

\fnmBanghao \surChen  [q030026007@mail.uic.edu.cn](mailto:q030026007@mail.uic.edu.cn) \fnmZhaofeng \surZhang  [q030018107@mail.uic.edu.cn](mailto:q030018107@mail.uic.edu.cn) [nicolaslangrene@uic.edu.cn](mailto:nicolaslangrene@uic.edu.cn) [Shengxin.Zhu@bnu.edu.cn](mailto:Shengxin.Zhu@bnu.edu.cn) [  [ 

###### Abstract

This paper delves into the pivotal role of prompt engineering in unleashing the capabilities of Large Language Models (LLMs). Prompt engineering is the process of structuring input text for LLMs and is a technique integral to optimizing the efficacy of LLMs. This survey elucidates foundational principles of prompt engineering, such as role-prompting, one-shot, and few-shot prompting, as well as more advanced methodologies such as the chain-of-thought and tree-of-thoughts prompting. The paper sheds light on how external assistance in the form of plugins can assist in this task, and reduce machine hallucination by retrieving external knowledge. We subsequently delineate prospective directions in prompt engineering research, emphasizing the need for a deeper understanding of structures and the role of agents in Artificial Intelligence-Generated Content (AIGC) tools. We discuss how to assess the efficacy of prompt methods from different perspectives and using different methods. Finally, we gather information about the application of prompt engineering in such fields as education and programming, showing its transformative potential. This comprehensive survey aims to serve as a friendly guide for anyone venturing through the big world of LLMs and prompt engineering.

###### keywords: 

Prompt engineering, LLM, GPT-4, OpenAI, AIGC, AI agent 

##  1 Introduction

In recent years, a significant milestone in artificial intelligence research has been the progression of natural language processing capabilities, primarily attributed to large language models (LLMs). Many popular models, rooted in the transformer architecture [[1](https://arxiv.org/html/2310.14735v4#bib.bib1)], undergo training on extensive datasets derived from web-based text. Central to their design is a self-supervised learning objective, which focuses on predicting subsequent words in incomplete sentences. Those models are called Artificial Intelligence-Generated Content (AIGC), and their ability to generate coherent and contextually relevant responses is a result of this training process, where they learn to associate words and phrases with their typical contexts.

LLMs operate by encoding the input text into a high-dimensional vector space, where semantic relationships between words and phrases are preserved. The model then decodes this representation to generate a response, guided by the learned statistical patterns [[2](https://arxiv.org/html/2310.14735v4#bib.bib2)]. The quality of the response can be influenced by various factors, including the prompt provided to the model, the model’s hyperparameters, and the diversity of the training data.

These models, such as GPT-3 [[3](https://arxiv.org/html/2310.14735v4#bib.bib3)], GPT-4 [[4](https://arxiv.org/html/2310.14735v4#bib.bib4)], along with many others (e.g., Google’s BARD [[5](https://arxiv.org/html/2310.14735v4#bib.bib5)], Anthropic’s Claude2 [[6](https://arxiv.org/html/2310.14735v4#bib.bib6)] and Meta’s LLaMA-2 [[7](https://arxiv.org/html/2310.14735v4#bib.bib7)]), have been utilized to revolutionize tasks ranging from information extraction to the creation of engaging content [[8](https://arxiv.org/html/2310.14735v4#bib.bib8)]. Related to AI systems, the application of LLMs in the workplace has the potential to automate routine tasks, such as data analysis [[9](https://arxiv.org/html/2310.14735v4#bib.bib9)] and text generation [[10](https://arxiv.org/html/2310.14735v4#bib.bib10)], thereby freeing up time for employees to focus on more complex and rewarding tasks [[11](https://arxiv.org/html/2310.14735v4#bib.bib11)]. Furthermore, LLMs have the potential to revolutionize the healthcare sector by assisting in the diagnosis and treatment of diseases. Indeed, by analyzing vast amounts of medical literature, these models can provide doctors with insights into rare conditions, suggest potential treatment pathways, and even predict patient outcomes [[12](https://arxiv.org/html/2310.14735v4#bib.bib12)]. In the realm of education, LLMs can serve as advanced tutoring systems, and promote the quality of teaching and learning [[13](https://arxiv.org/html/2310.14735v4#bib.bib13)]. Those AI tools can analyze a student’s response, identify areas of improvement, and provide constructive feedback in a coherent and formal manner.

In real applications, the prompt is the input of the model, and its engineering can result in significant output difference [[14](https://arxiv.org/html/2310.14735v4#bib.bib14)]. Modifying the structure (e.g., altering length, arrangement of instances) and the content (e.g., phrasing, choice of illustrations, directives) can exert a notable influence on the output generated by the model [[15](https://arxiv.org/html/2310.14735v4#bib.bib15)]. Studies show that both the phrasing and the sequence of examples incorporated within a prompt have been observed to exert a substantial influence on the model’s behavior [[15](https://arxiv.org/html/2310.14735v4#bib.bib15), [16](https://arxiv.org/html/2310.14735v4#bib.bib16)].

The discipline of prompt engineering has advanced alongside LLMs. What originated as a fundamental practice of shaping prompts to direct model outputs has matured into a structured research area, replete with its distinct methodologies and established best practices. Prompt engineering refers to the systematic design and optimization of input prompts to guide the responses of LLMs, ensuring accuracy, relevance, and coherence in the generated output. This process is crucial in harnessing the full potential of these models, making them more accessible and applicable across diverse domains. Contemporary prompt engineering encompasses a spectrum of techniques, ranging from foundational approaches such as role-prompting [[17](https://arxiv.org/html/2310.14735v4#bib.bib17)] to more sophisticated methods such as “chain of thought” prompting [[18](https://arxiv.org/html/2310.14735v4#bib.bib18)]. The domain remains dynamic, with emergent research continually unveiling novel techniques and applications in prompt engineering. The importance of prompt engineering is accentuated by its ability to guide model responses, thereby amplifying the versatility and relevance of LLMs in various sectors. Importantly, a well-constructed prompt can counteract challenges such as machine hallucinations, as highlighted in studies by [[19](https://arxiv.org/html/2310.14735v4#bib.bib19)] and [[20](https://arxiv.org/html/2310.14735v4#bib.bib20)]. The influence of prompt engineering extends to numerous disciplines. For instance, it has facilitated the creation of robust feature extractors using LLMs, thereby improving their efficacy in tasks such as defect detection and classification [[21](https://arxiv.org/html/2310.14735v4#bib.bib21)].

In this paper, we present a comprehensive survey on the prompt engineering of LLMs. The structure of the paper is organized as follows: Section [2](https://arxiv.org/html/2310.14735v4#S2 "2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") presents the foundational methods of prompt engineering, showcasing various results. It encompasses both basic and advanced techniques. Section [3](https://arxiv.org/html/2310.14735v4#S3 "3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") further explores advanced methodologies, including the use of external assistance. All the examples are generated on a non-multimodal language generative model, called “default GPT-4”, developed by OpenAI. Section [4](https://arxiv.org/html/2310.14735v4#S4 "4 Prospective methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") discusses potential future direction in prompt engineering. Section [5](https://arxiv.org/html/2310.14735v4#S5 "5 Assessing the efficacy of prompt methods ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") provides insights into prompt evaluation techniques, drawing comparisons between subjective and objective assessment methods. Finally, Section [6](https://arxiv.org/html/2310.14735v4#S6 "6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") focuses on the broader applications of prompt engineering across various domains.

##  2 Basics of prompt engineering

By incorporating just a few key elements, one can craft a basic prompt that enables LLMs to produce high-quality answers. In this section, we discuss some essential components of a well-made prompt.

###  2.1 Model introduction: GPT-4

All of the output in the following sections are generated by GPT-4, developed by OpenAI [[4](https://arxiv.org/html/2310.14735v4#bib.bib4)]. Vast amounts of text data have been used to train GPT-4, whose number of parameters has been estimated to be several orders of magnitude larger than the 175 billion parameters that had been used for the earlier GPT-3 [[3](https://arxiv.org/html/2310.14735v4#bib.bib3)]. The architectural foundation of the model rests on transformers [[1](https://arxiv.org/html/2310.14735v4#bib.bib1)], which essentially are attention mechanisms that assign varying weights to input data based on the context. Similar to GPT-3, GPT-4 was also fine-tuned to follow a broad class of written instructions by reinforcement learning from human feedback (RLHF) [[22](https://arxiv.org/html/2310.14735v4#bib.bib22), [23](https://arxiv.org/html/2310.14735v4#bib.bib23)], which is a technique that uses human preferences as a reward signal to fine-tune models.

When GPT-4 receives an input prompt, the input text will be firstly converted into tokens that the model can interpret and process. These tokens are then managed by transformer layers, which capture their relationships and context. Within these layers, attention mechanisms distribute different weights to tokens based on their relevance and context. After attention processing, the model forms its internal renditions of the input data, known as intermediate representations. These representations are then decoded back into human-readable text [[24](https://arxiv.org/html/2310.14735v4#bib.bib24)].

A significant aspect of this process is the randomness function [[25](https://arxiv.org/html/2310.14735v4#bib.bib25)]. This function is influenced by two primary parameters, temperature and top-k𝑘kitalic_k sampling. The first one, temperature [[26](https://arxiv.org/html/2310.14735v4#bib.bib26)] balances the randomness and determinism in the output. A higher temperature value results in more random outputs, while a lower value makes the output more deterministic. The second one, top-k𝑘kitalic_k sampling [[27](https://arxiv.org/html/2310.14735v4#bib.bib27)], limits the model’s choices to the top k𝑘kitalic_k most probable tokens during each step of output generation. The final stage of this process is the output generation, where the model crafts the final text.

###  2.2 Giving instructions

The method of giving instructions, also considered as re-reading [[28](https://arxiv.org/html/2310.14735v4#bib.bib28)], refers to the heuristics of human reading strategy. It has been observed that the output generated by GPT-4, introduced in Section [2.1](https://arxiv.org/html/2310.14735v4#S2.SS1 "2.1 Model introduction: GPT-4 ‣ 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"), tends to be excessively general when provided with fundamental instructions devoid of any supplementary description [[29](https://arxiv.org/html/2310.14735v4#bib.bib29), [30](https://arxiv.org/html/2310.14735v4#bib.bib30)]. An example prompt is shown in Figure [1](https://arxiv.org/html/2310.14735v4#S2.F1 "Figure 1 ‣ 2.2 Giving instructions ‣ 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"). When the model is prompted with basic instruction, it faces a plethora of options, which makes the result quite broad. Hence, a comprehensive description is imperative to elicit more precise and relevant outputs [[31](https://arxiv.org/html/2310.14735v4#bib.bib31)].

I want to understand some cutting-edge aspects of technology.

Here are some of the key areas:   
1\. Artificial intelligence and machine learning: These technologies are becoming increasingly sophisticated, with advancements in areas such as natural language processing (like the technology you’re interacting with right now), computer vision, and reinforcement learning. Techniques such as transfer learning and federated learning are being used to make machine learning models more efficient and less data-hungry.   
2\. Quantum computing: Quantum computers use the principles of quantum mechanics to process information. They hold the potential to solve certain types of problems much more efficiently than classical computers. Companies like Google, IBM, and many startups are investing heavily in this area.   
3\. 5G and beyond: 5G wireless technology began widespread deployment in 2020 and 2021, bringing faster speeds, lower latency, and the ability to connect more devices simultaneously. Research is also being done on 6G, which is expected to integrate even more deeply with AI and potentially bring about more transformative changes.   
4\. Biotechnology: …   


Model inputModel output

Figure 1: Giving instructions without extra description.

###  2.3 Be clear and precise

The second basic prompt method is “to be clear and precise”. This involves formulating prompts that are unambiguous and specific, which can guide the model toward generating the desired output.

Most LLM architectures are derived from an extensive array of textual data. It can be conceptualized as a combination of insights from a myriad of authors. When presented with a broad or undetailed prompt, its output predominantly exhibits a generic nature, which, while being applicable across a range of contexts, may not be optimal for any specific application. In contrast, a detailed and precise prompt enables the model to generate content that is more aligned with the unique requirements of the given scenario, as it reduces the model’s uncertainty and guides it toward the correct response.

For instance, as shown in Figure [2](https://arxiv.org/html/2310.14735v4#S2.F2 "Figure 2 ‣ 2.3 Be clear and precise ‣ 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"), instead of asking a vague requirement such as “I want to understand the cutting edge of technology.”, a more precise prompt would be “I want to understand the cutting edge of technology, specifically related to artificial intelligence and machine learning…”.

I want to understand the cutting edge of technology, specifically related to artificial intelligence and machine learning. Recently, artificial intelligence has become extremely popular, especially the large language models which have amazed me. Please analyze the possible reasons behind the rapid advancement of this technology from at least three perspectives.

Absolutely, the rise of AI and machine learning, especially with regard to large language models like GPT-4, can be seen as a convergence of several key factors. I’ll analyze this from three perspectives: technological advancements, availability of data, and socio-economic demand. 1\. Technological advancements: The growth of AI and machine learning models has been facilitated by several technological innovations. For starters, we’ve seen incredible improvements in computational power, particularly in Graphics Processing Units (GPUs) and now even more specialized AI chips. These advances have made it … 2\. Availability of data: … 3\. Socio-economic demand: …

Model inputModel output

Figure 2: A clearer and more precise prompt.

###  2.4 Role-prompting

Role-prompting is another fundamental method in prompt engineering. It involves giving the model a specific role to play, such as a helpful assistant or a knowledgeable expert [[32](https://arxiv.org/html/2310.14735v4#bib.bib32)]. This method can be particularly effective in guiding the model’s responses and ensuring that they align with the desired output. For instance, if the model is prompted to act as a historian, it is more likely to provide a detailed and contextually accurate response when asked about a historical event [[33](https://arxiv.org/html/2310.14735v4#bib.bib33)]. Another brief example is shown in Figure [3](https://arxiv.org/html/2310.14735v4#S2.F3 "Figure 3 ‣ 2.4 Role-prompting ‣ 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review").

You are an expert in artificial intelligence specializing in large language models…

Here are five basic methods to quickly get started with large language models: 1\. Experiment with web-based interfaces: … 

A role promptModel output

Figure 3: Role prompting example.

###  2.5 Use of triple quotes to separate

In prompt engineering, the use of triple quotes is a technique used to separate different parts of a prompt or to encapsulate multi-line strings. This technique is particularly useful when dealing with complex prompts that include multiple components or when the prompt itself contains quotes, which makes the model understand one’s instructions better [[34](https://arxiv.org/html/2310.14735v4#bib.bib34)].

###  2.6 Try several times

Due to the non-deterministic nature of LLMs, it is often beneficial to try several times when generating responses. This technique, often referred to as “resampling”, involves running the model multiple times with the same prompt and selecting the best output. This approach can help overcome the inherent variability in the model’s responses and increase the chances of obtaining a high-quality output [[26](https://arxiv.org/html/2310.14735v4#bib.bib26)].

###  2.7 One-shot or few-shot prompting

One-shot and few-shot prompting are two important techniques in prompt engineering. One-shot prompting refers to the method where the model is given a single example to learn from, while few-shot [[35](https://arxiv.org/html/2310.14735v4#bib.bib35)] prompting provides the model with multiple examples [[36](https://arxiv.org/html/2310.14735v4#bib.bib36)]. The choice between one-shot and few-shot prompting often depends on the complexity of the task and the capability of the model. For instance, for simple tasks or highly capable models, one-shot prompting might be sufficient. An example is shown in Figure [4](https://arxiv.org/html/2310.14735v4#S2.F4 "Figure 4 ‣ 2.7 One-shot or few-shot prompting ‣ 2 Basics of prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"). However, for more complex tasks or less capable models, few-shot prompting can provide additional context and guidance, thereby improving the model’s performance.

Standard Prompt

Q: Yes or no: would a pear sink in water?

A: Yes, a pear would typically float in water, not sink. The reason for this is that pears, like many fruits, are composed primarily of water and have a density that is less than that of water. Objects that are less dense than water will float when placed in water. ×\boldsymbol{\times}bold_×

One-shot Prompt

Q: Yes or no: is it common to see frost during some college commencements?   
A: The answer is yes. Q: Yes or no: would a pear sink in water?

A: The answer is No. \pdfrenderStrokeColor=green,TextRenderingMode=2✓

Figure 4: Comparison of standard prompt and one-shot prompt.

Model inputModel outputModel inputModel output

However, as stated in [[37](https://arxiv.org/html/2310.14735v4#bib.bib37)], “examples don’t always help”. [[37](https://arxiv.org/html/2310.14735v4#bib.bib37)] investigated the intricacies of how large generative language models, such as GPT-3, respond to prompts. One of the significant findings from this paper is that zero-shot prompts can, in certain scenarios, outperform few-shot prompts. This suggests that the role of few-shot examples might not be as much about teaching the model a new task (meta-learning) but rather guiding it to recall a task it has already learned. This insight is crucial as it challenges the conventional wisdom that more examples always lead to better performance [[3](https://arxiv.org/html/2310.14735v4#bib.bib3)]. In the context of one-shot or few-shot prompting, it is essential to understand that while examples can guide the model, they do not always enhance its performance. Sometimes, a well-crafted zero-shot prompt can be more effective than providing multiple examples [[38](https://arxiv.org/html/2310.14735v4#bib.bib38)].

###  2.8 LLM settings: temperature and top-p

The settings of LLMs, such as the temperature and top-p𝑝pitalic_p, play a crucial role in the generation of responses. The temperature parameter controls the randomness of the generated output: a lower temperature leads to more deterministic outputs [[39](https://arxiv.org/html/2310.14735v4#bib.bib39), [40](https://arxiv.org/html/2310.14735v4#bib.bib40)]. The top-p𝑝pitalic_p parameter, on the other hand, controls the nucleus sampling [[26](https://arxiv.org/html/2310.14735v4#bib.bib26)], which is a method to add randomness to the model’s output [[41](https://arxiv.org/html/2310.14735v4#bib.bib41)]. Adjusting these parameters can significantly affect the quality and diversity of the model’s responses, making them essential tools in prompt engineering. However, it has been noted that certain models, exemplified by ChatGPT, do not permit the configuration of these hyperparameters, barring instances where the Application Programming Interface (API) is employed.

##  3 Advanced methodologies

The foundational methods from the previous section can help us produce satisfactory outputs. However, experiments indicate that when using LLMs for complex tasks such as analysis or reasoning, the accuracy of the model’s outputs still has room for improvement. In this section, we will further introduce advanced techniques in prompt engineering to guide the model in generating more specific, accurate, and high-quality content.

###  3.1 Chain of thought

The concept of “Chain of Thought” (CoT) prompting [[18](https://arxiv.org/html/2310.14735v4#bib.bib18)] in LLMs is a relatively new development in the field of AI, and it has been shown to significantly improve the accuracy of LLMs on various logical reasoning tasks [[42](https://arxiv.org/html/2310.14735v4#bib.bib42), [43](https://arxiv.org/html/2310.14735v4#bib.bib43), [44](https://arxiv.org/html/2310.14735v4#bib.bib44)]. CoT prompting involves providing intermediate reasoning steps to guide the model’s responses, which can be facilitated through simple prompts such as “Let’s think step by step” or through a series of manual demonstrations, each composed of a question and a reasoning chain that leads to an answer [[45](https://arxiv.org/html/2310.14735v4#bib.bib45), [46](https://arxiv.org/html/2310.14735v4#bib.bib46)]. It also provides a clear structure for the model’s reasoning process, making it easier for users to understand how the model arrived at its conclusions.

[[47](https://arxiv.org/html/2310.14735v4#bib.bib47)] illustrates the application of CoT prompting to medical reasoning, showing that it can effectively elicit valid intermediate reasoning steps from LLMs. [[48](https://arxiv.org/html/2310.14735v4#bib.bib48)] introduces the concept of Self-Education via Chain-of-Thought Reasoning (SECToR), and argues that, in the spirit of reinforcement learning, LLMs can successfully teach themselves new skills by chain-of-thought reasoning. In another study, [[49](https://arxiv.org/html/2310.14735v4#bib.bib49)] used CoT prompting to train verifiers to solve math word problems, demonstrating the technique’s potential in educational applications. [[50](https://arxiv.org/html/2310.14735v4#bib.bib50)] proposed a multimodal version of CoT, called Multimodal-CoT, to handle more complex, multimodal tasks beyond simple text-based tasks, such as visual tasks, further expanding the potential applications of CoT.

####  3.1.1 Zero-shot chain of thought

The concept of “Zero-Shot Chain of Thought” (Zero-shot-CoT) prompting is an advanced iteration of the CoT prompting mechanism, where the “zero-shot” aspect implies that the model is capable of performing some reasoning without having seen any examples of the task during training.

In their research, [[51](https://arxiv.org/html/2310.14735v4#bib.bib51)] discovered that the augmentation of queries with the phrase “Let’s think step by step” facilitated the generation of a sequential reasoning chain by LLMs. This reasoning chain subsequently proved instrumental in deriving more precise answers. This technique is based on the idea that the model, much like a human, can benefit from having more detailed and logical steps to process the prompt and generate a response.

For instance, the standard prompt is illustrated in Figure [5](https://arxiv.org/html/2310.14735v4#S3.F5 "Figure 5 ‣ 3.1.1 Zero-shot chain of thought ‣ 3.1 Chain of thought ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"), while the appended phrase, “Let’s think step by step”, is depicted in Figure [6](https://arxiv.org/html/2310.14735v4#S3.F6 "Figure 6 ‣ 3.1.1 Zero-shot chain of thought ‣ 3.1 Chain of thought ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"). Observations indicate that the incorporation of “Let’s think step by step” enhances the logical coherence and comprehensiveness of the model’s response.

Imagine an infinitely wide entrance, which is more likely to pass through it, a military tank or a car?

Given an “infinitely wide entrance”, both a military tank and a car can pass through it without any constraints due to width. Therefore, neither is more likely than the other based on width alone. Both can pass through with equal likelihood. However, if other factors such as ground conditions, accessibility, purpose, or authorization come into play, the likelihood might change. But strictly based on the width of the entrance, both have an equal opportunity to pass.

Model inputModel output

Figure 5: Standard prompt.

Imagine an infinitely wide entrance, which is more likely to pass through it, a military tank or a car? Let’s think step by step.

Given an infinitely wide entrance, both a military tank and a car could pass through without any issues related to the width. However, there are still several factors that could influence which is more likely to pass through: 1\. Ground surface: tanks are designed to handle rough terrains that cars may struggle with. If the ground leading to and from the entrance is too rugged or steep for a car, the tank would be more likely to pass through. 2\. Weight restrictions: if the entrance has a load limit due to the materials used in its construction, the car, being lighter, could be more likely to pass through. The average car weighs around 1.5 tons, while a military tank can weigh anywhere from 60 to 70 tons. 3\. Height clearance: if the entrance is infinitely wide but not infinitely tall, the height of the vehicle matters. The average height of a car is around 1.5 meters, while tanks can be around 2.4 meters. If the entrance is shorter than around 2.4 meters, a car would be more likely to pass through. 4\. Regulations and permissions: … In conclusion, without specific information about the conditions at the entrance, we would assume that a car is more likely to pass through, simply because cars are more common, more likely to meet potential height and weight restrictions and face fewer regulatory barriers.

Model inputModel output

Figure 6: Adding “Let’s think step by step”.

####  3.1.2 Golden chain of thought

[[52](https://arxiv.org/html/2310.14735v4#bib.bib52)] introduced the “golden chain of thought”, providing an innovative approach to generating responses to instruction-based queries. This methodology leverages a set of “ground-truth chain-of-thought” solutions incorporated within the prompt, considerably simplifying the task for the model as it circumvents the necessity for independent CoT generation. Concurrently, a novel benchmark comprising detective puzzles has been designed, to assess the abductive reasoning capacities of LLMs, which is also considered an evaluation of the golden CoT. Finally, according to [[52](https://arxiv.org/html/2310.14735v4#bib.bib52)]’s experiment, in the context of the golden CoT, GPT-4 exhibits commendable performance, boasting an 83% solve rate in contrast to the 38% solve rate of the standard CoT.

However, the characteristics of the Golden CoT requiring the “ground-truth chain-of-thought solutions” as an integral part of the prompt also signifies that the Golden CoT’s contribution to solving such problems is limited, despite its high solve rate of 83%.

###  3.2 Self-consistency

In the assessment of INSTRUCTGPT [[53](https://arxiv.org/html/2310.14735v4#bib.bib53)] and GPT-3 [[3](https://arxiv.org/html/2310.14735v4#bib.bib3)] on a new synthetic QA dataset called PRONTOQA, for Proof and Ontology-Generated Question-Answering [[54](https://arxiv.org/html/2310.14735v4#bib.bib54), [55](https://arxiv.org/html/2310.14735v4#bib.bib55)], it was observed that although the most extensive model exhibited capability in reasoning tasks, it encountered challenges in proof planning and the selection of the appropriate proof step amidst multiple options, which caused accuracy uncertainties [[54](https://arxiv.org/html/2310.14735v4#bib.bib54)]. Self-consistency in LLMs is an advanced prompting technique that aims to ensure the model’s responses are consistent with each other [[56](https://arxiv.org/html/2310.14735v4#bib.bib56), [18](https://arxiv.org/html/2310.14735v4#bib.bib18)], which greatly increases the odds of obtaining highly accurate results. The principle behind it is that if a model is asked to answer a series of related questions, the answers should not contradict each other.

The self-consistency method contains three steps. Firstly, prompt a language model using CoT prompting, then replace the “greedy decode” (1-Best) [[25](https://arxiv.org/html/2310.14735v4#bib.bib25), [57](https://arxiv.org/html/2310.14735v4#bib.bib57)] in CoT prompting by sampling from the language model’s decoder to generate a diverse set of reasoning paths, and finally, marginalize out the reasoning paths and aggregate by choosing the most consistent answer in the final answer set.

It is noteworthy that self-consistency can be harmoniously integrated with most sampling algorithms, including but not limited to, temperature sampling [[39](https://arxiv.org/html/2310.14735v4#bib.bib39), [40](https://arxiv.org/html/2310.14735v4#bib.bib40)], top-k𝑘kitalic_k sampling [[58](https://arxiv.org/html/2310.14735v4#bib.bib58), [59](https://arxiv.org/html/2310.14735v4#bib.bib59), [25](https://arxiv.org/html/2310.14735v4#bib.bib25)], and nucleus sampling [[26](https://arxiv.org/html/2310.14735v4#bib.bib26)]. Nevertheless, such an operation may necessitate the invocation of the model’s Application Programming Interface (API) to fine-tune these hyperparameters. In light of this, an alternative approach could be to allow the model to generate results employing diverse reasoning paths, and then generate a diverse set of candidate reasoning paths. The response demonstrating the highest degree of consistency across the various reasoning trajectories is then more inclined to represent the accurate solution [[60](https://arxiv.org/html/2310.14735v4#bib.bib60)].

Studies have shown that self-consistency enhances outcomes in arithmetic, commonsense, and symbolic reasoning tasks [[61](https://arxiv.org/html/2310.14735v4#bib.bib61), [2](https://arxiv.org/html/2310.14735v4#bib.bib2)]. Furthermore, in practice, self-consistency can be combined with other techniques to further enhance the model’s performance. For example, a study found that combining self-consistency with a discriminator-guided multi-step reasoning approach significantly improved the model’s reasoning capabilities [[62](https://arxiv.org/html/2310.14735v4#bib.bib62)].

###  3.3 Generated knowledge

The “generated knowledge” [[63](https://arxiv.org/html/2310.14735v4#bib.bib63)] approach in prompt engineering is a technique that leverages the ability of LLMs to generate potentially useful information about a given question or prompt before generating a final response. This method is particularly effective in tasks that require commonsense reasoning, as it allows the model to generate and utilize additional context that may not be explicitly present in the initial prompt.

As exemplified in Figure [5](https://arxiv.org/html/2310.14735v4#S3.F5 "Figure 5 ‣ 3.1.1 Zero-shot chain of thought ‣ 3.1 Chain of thought ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"), when posing the query to the model, “Imagine an infinitely wide entrance, which is more likely to pass through it, a military tank or a car?”, standard prompts predominantly yield responses that neglect to factor in the “entrance height”. Conversely, as delineated in Figure [7](https://arxiv.org/html/2310.14735v4#S3.F7 "Figure 7 ‣ 3.3 Generated knowledge ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") and Figure [8](https://arxiv.org/html/2310.14735v4#S3.F8 "Figure 8 ‣ 3.3 Generated knowledge ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review"), prompting the model to first generate pertinent information and subsequently utilizing generated information in the query leads to outputs with augmented logical coherence and comprehensiveness. Notably, this approach stimulates the model to account for salient factors such as “entrance height”.

Generate two key analyses related to detailed size data on military tanks and cars, and then generate three key influencing factors regarding whether an object can pass through an infinitely wide entrance.

Detailed size analysis: military tanks vs. cars 1\. Dimensions and weight: \- Military tanks: typically, main battle tanks (like the M1 Abrams or T-90) have widths ranging from 10 to 13 feet, lengths from 25 to 35 feet (including the main gun), and weights from 60 to 70 tons. \- Cars: most consumer cars have a width of about 6 to 8 feet, a length of 12 to 20 feet, and weigh between 1 to 3 tons. Some large SUVs and trucks can exceed these figures but are still substantially smaller and lighter than tanks. 2\. Maneuverability & design: \- Military tanks: tanks are designed to traverse rough terrains and have tracks that distribute weight and prevent the vehicle from getting easily stuck in muddy or uneven ground. However, their sheer weight and size limit their maneuverability in urban or congested settings. \- Cars: designed for paved roads, cars are generally more agile and can navigate tight spaces more efficiently than tanks. Their design emphasizes aerodynamics and comfort, unlike tanks that prioritize armor and firepower.   
Three key influencing factors on whether an object can pass through an infinitely wide entrance: 1\. Height of the object: the height is critical. An infinitely wide entrance does not give information about its height. If the object is taller than the entrance, it won’t pass through. 2\. Structural integrity: depending on the material and design of an object, squeezing or forcing it through an entrance could compromise its structural integrity. For instance, certain tanks have reactive armor or sensitive equipment that may be damaged if scraped or bumped forcefully. 3\. Ground clearance and maneuverability: …

Model inputModel output

Figure 7: Generating knowledge (Step1).

“““ Detailed size analysis: military tanks vs. cars 1\. Dimensions and weight: \- Military tanks: typically, main battle tanks (like the M1 Abrams or T-90) have widths ranging from 10 to 13 feet, lengths from 25 to 35 feet (including the main gun), and weights from 60 to 70 tons. \- Cars: most consumer cars have a width of about 6 to 8 feet, a length of 12 to 20 feet, and weigh between 1 to 3 tons. Some large SUVs and trucks can exceed these figures but are still substantially smaller and lighter than tanks. 2\. Maneuverability & design… ”””   
Use the above information to answer the following question: Imagine an infinitely wide entrance, which is more likely to pass through it, a military tank or a car? 

Given the information provided about the dimensions, design, and the factors influencing whether an object can pass through an infinitely wide entrance, we can infer the following: 1\. Height of the object: the height is not specified for either tanks or cars. However, given that tanks are built for rough terrains and often have a turret and other equipment on top, they generally have a taller profile compared to most cars. If the entrance had a restrictive height, cars would generally have an advantage here. 2\. Structural integrity: … 3\. Ground clearance and maneuverability:   
… Conclusion: If the entrance height is not restrictive and the surface is rough, a military tank would be more likely to pass through it without issues. On the other hand, if the entrance is low-height or has tight squeezes that could compromise the structural integrity of larger, robust vehicles, a car might be at an advantage. However, given no height constraints and only the factor of width (since it is “infinitely wide”), both a military tank and a car would easily pass through it. In such a scenario, the distinguishing factor would be the terrain of the entrance. If it is rough or uneven, the tank has the advantage. If it is smooth, both would pass with relative ease.

Model inputModel output

Figure 8: Combining the generated knowledge with the question (Step2).

###  3.4 Least-to-most prompting

The concept of “least to most prompting” [[64](https://arxiv.org/html/2310.14735v4#bib.bib64)] is an advanced method that involves starting with a minimal prompt and gradually increasing its complexity to elicit more sophisticated responses from the language model. The foundational premise of this approach is the decomposition of intricate problems into a succession of more rudimentary subproblems, which are then sequentially addressed. The resolution of each subproblem is expedited by leveraging solutions derived from antecedent subproblems.

Upon rigorous experimentation in domains including symbolic manipulation, compositional generalization, and mathematical reasoning, findings from [[64](https://arxiv.org/html/2310.14735v4#bib.bib64)] substantiate that the least-to-most prompting paradigm exhibits the capacity to generalize across challenges of greater complexity than those initially presented in the prompts. They found that LLMs seem to respond effectively to this method, demonstrating its potential for enhancing the reasoning capabilities of these models.

###  3.5 Tree of thoughts

The “tree of thoughts” (ToT) prompting technique is an advanced method that employs a structured approach to guide LLMs in their reasoning and response generation processes. Unlike traditional prompting methods that rely on a linear sequence of instructions, the ToT method organizes prompts in a hierarchical manner, akin to a tree structure, allowing for deliberate problem-solving [[65](https://arxiv.org/html/2310.14735v4#bib.bib65)]. For instance, when tasked with solving a complex mathematical problem, a traditional prompt might directly ask LLMs for the solution. In contrast, using the ToT method, the initial prompt might first ask the model to outline the steps required to solve the problem. Subsequent prompts would then delve deeper into each step, guiding the model through a systematic problem-solving process.

[[65](https://arxiv.org/html/2310.14735v4#bib.bib65)] demonstrates that this formulation is more versatile and can handle challenging tasks where standard prompts might fall short. Another research by [[66](https://arxiv.org/html/2310.14735v4#bib.bib66)] further emphasizes the potential of this technique in enhancing the performance of LLMs by structuring their thought processes.

[[5](https://arxiv.org/html/2310.14735v4#bib.bib5)] introduces the “tree-of-thought prompting”, an approach that assimilates the foundational principles of the ToT frameworks and transforms them into a streamlined prompting methodology. This technique enables LLMs to assess intermediate cognitive constructs within a singular prompt. An exemplar ToT prompt is delineated in Figure [9](https://arxiv.org/html/2310.14735v4#S3.F9 "Figure 9 ‣ 3.5 Tree of thoughts ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") [[5](https://arxiv.org/html/2310.14735v4#bib.bib5)].

Imagine three different experts answering this question.   
All experts will write down 1 step of their thinking,   
then share it with the group.   
Then all experts will go on to the next step, etc.   
If any expert realizes they’re wrong at any point then they leave.   
The question is…

Tree of thoughts prompting

Figure 9: A sample ToT prompt.

###  3.6 Graph of thoughts

Unlike the “chain of thoughts” or “tree of thoughts” paradigms, the “graph of thoughts” (GoT) framework [[67](https://arxiv.org/html/2310.14735v4#bib.bib67)] offers a more intricate method of representing the information generated by LLMs. The core concept behind GoT is to model this information as an arbitrary graph. In this graph, individual units of information, termed “LLM thoughts”, are represented as vertices. The edges of the graph, on the other hand, depict the dependencies between these vertices. This unique representation allows for the combination of arbitrary LLM thoughts, thereby creating a synergistic effect in the model’s outputs.

In the context of addressing intricate challenges, LLMs utilizing the GoT framework might initially produce several autonomous thoughts or solutions. These individual insights can subsequently be interlinked based on their pertinence and interdependencies, culminating in a detailed graph. This constructed graph permits diverse traversal methods, ensuring the final solution is both precise and comprehensive, encompassing various dimensions of the challenge.

The efficacy of the GoT framework is anchored in its adaptability and the profound insights it can yield, particularly for intricate issues necessitating multifaceted resolutions. Nonetheless, it is imperative to recognize that while GoT facilitates a systematic approach to problem-solving, it also necessitates a profound comprehension of the subject matter and meticulous prompt design to realize optimal outcomes [[68](https://arxiv.org/html/2310.14735v4#bib.bib68)].

###  3.7 Retrieval augmentation

Another direction of prompt engineering is to aim to reduce hallucinations. When using AIGC tools such as GPT-4, it is common to face a problem called “hallucinations”, which refer to the presence of unreal or inaccurate information in the model’s generated output [[69](https://arxiv.org/html/2310.14735v4#bib.bib69), [19](https://arxiv.org/html/2310.14735v4#bib.bib19)]. While these outputs may be grammatically correct, they can be inconsistent with facts or lack real-world data support. Hallucinations arise because the model may not have found sufficient evidence in its training data to support its responses, or it may overly generalize certain patterns when attempting to generate fluent and coherent output [[70](https://arxiv.org/html/2310.14735v4#bib.bib70)].

An approach to reduce hallucinations and enhance the effectiveness of prompts is the so-called retrieval augmentation technique, which aims at incorporating up-to-date external knowledge into the model’s input [[71](https://arxiv.org/html/2310.14735v4#bib.bib71), [72](https://arxiv.org/html/2310.14735v4#bib.bib72)]. It is emerging as an AI framework for retrieving facts from external sources. [[73](https://arxiv.org/html/2310.14735v4#bib.bib73)] examines the augmentation of context retrieval through the incorporation of external information. It proposes a sophisticated operation: the direct concatenation of pertinent information obtained from an external source to the prompt, which is subsequently treated as foundational knowledge for input into the expansive language model. Additionally, the paper introduces auto-regressive techniques for both retrieval and decoding, facilitating a more nuanced approach to information retrieval and fusion. This research demonstrates that in-context retrieval-augmented language models [[73](https://arxiv.org/html/2310.14735v4#bib.bib73)], when constructed upon readily available general-purpose retrievers, yield significant LLM enhancements across a variety of model dimensions and diverse corpora. In another research, [[74](https://arxiv.org/html/2310.14735v4#bib.bib74)] showed that GPT-3 can reduce hallucinations by studying various components of architectures such as Retrieval Augmented Generation (RAG) [[75](https://arxiv.org/html/2310.14735v4#bib.bib75)], Fusion-inDecoder (FiD) [[76](https://arxiv.org/html/2310.14735v4#bib.bib76)], Seq2seq [[77](https://arxiv.org/html/2310.14735v4#bib.bib77), [78](https://arxiv.org/html/2310.14735v4#bib.bib78), [79](https://arxiv.org/html/2310.14735v4#bib.bib79)] and others. [[80](https://arxiv.org/html/2310.14735v4#bib.bib80)] developed Chain-of-Verification (CoVe) to reduce the hallucinations, which introduces that when equipped with tool-use such as retrieval augmentation in the verification execution step, would likely bring further gains.

###  3.8 Use plugins to polish the prompts

After introducing the detailed techniques and methods of prompt engineering, we now explore the use of some external prompt engineering assistants that have been developed recently and exhibit promising potential. Unlike the methods introduced previously, these instruments can help us to polish the prompt directly. They are adept at analyzing user inputs and subsequently producing pertinent outputs within a context that is defined by itself, thereby amplifying the efficacy of prompts. Some of the plugins provided by OpenAI are good examples of such tools [[81](https://arxiv.org/html/2310.14735v4#bib.bib81)].

In certain implementations, the definition of a plugin is incorporated into the prompt, potentially altering the output [[82](https://arxiv.org/html/2310.14735v4#bib.bib82)]. Such integration may impact the manner in which LLMs interpret and react to the prompts, illustrating a connection between prompt engineering and plugins. Furthermore, the laborious nature of intricate prompt engineering may be mitigated by plugins, which enable the model to more proficiently comprehend or address user inquiries without necessitating excessively detailed prompts. Consequently, plugins bolster the efficacy of prompt engineering while promoting enhanced user-centric efficiency. These tools, akin to packages, can be seamlessly integrated into Python and invoked directly [[83](https://arxiv.org/html/2310.14735v4#bib.bib83), [84](https://arxiv.org/html/2310.14735v4#bib.bib84)]. Such plugins augment the efficacy of prompts by furnishing responses that are both coherent and contextually pertinent. For instance, the “Prompt Enhancer” pluging [[85](https://arxiv.org/html/2310.14735v4#bib.bib85)], developed by AISEO [[86](https://arxiv.org/html/2310.14735v4#bib.bib86)], can be invoked by starting the prompt with the word “AISEO” to let the AISEO prompt generator automatically enhance the LLM prompt provided. Similarly, another plugin called “Prompt Perfect”, can be used by starting the prompt with ‘perfect’ to automatically enhance the prompt, aiming for the “perfect” prompt for the task at hand [[87](https://arxiv.org/html/2310.14735v4#bib.bib87), [88](https://arxiv.org/html/2310.14735v4#bib.bib88)].

##  4 Prospective methodologies

Several key developments on the horizon promise to substantially advance prompt engineering capabilities. In the following section, some of the most significant trajectories would be analyzed that are likely to shape the future of prompt engineering. By anticipating where prompt engineering is headed, developments in this field can be proactively steered toward broadly beneficial outcomes.

###  4.1 Better understanding of structures

One significant trajectory about the future of prompt engineering that emerges is the importance of better understanding the underlying structures of AI models. This understanding is crucial to effectively guide these models through prompts and to generate outputs that are more closely aligned with user intent.

At the heart of most AI models, including GPT-4, are complex mechanisms designed to understand and generate human language. The interplay of these mechanisms forms the “structure” of these models. Understanding this structure involves unraveling the many layers of neural networks, the various attention mechanisms at work, and the role of individual nodes and weights in the decision-making process of these models [[89](https://arxiv.org/html/2310.14735v4#bib.bib89)]. Deepening our understanding of these structures could lead to substantial improvements in prompt engineering. The misunderstanding of the model may cause a lack of reproducibility [[90](https://arxiv.org/html/2310.14735v4#bib.bib90)]. By understanding how specific components of the model’s structure influence its outputs, we could design prompts that more effectively exploit these components.

Furthermore, a comprehensive grasp of these structures could shed light on the shortcomings of certain prompts and guide their enhancement. Frequently, the underlying causes for a prompt’s inability to yield the anticipated output are intricately linked to the model’s architecture. For example, [[16](https://arxiv.org/html/2310.14735v4#bib.bib16)] found evidence of limitations in previous prompt models and questioned how much these methods truly understood the model.

Exploration of AI model architectures remains a vibrant research domain, with numerous endeavors aimed at comprehending these sophisticated frameworks. A notable instance is DeepMind’s “Causal Transformer” model [[91](https://arxiv.org/html/2310.14735v4#bib.bib91)], designed to explicitly delineate causal relationships within data. This represents a stride towards a more profound understanding of AI model architectures, with the potential to help us design more efficient prompts.

Furthermore, a more comprehensive grasp of AI model architectures would also yield advancements in explainable AI. Beyond better prompt engineering, this would also foster greater trust in AI systems and promote their integration across diverse industries [[92](https://arxiv.org/html/2310.14735v4#bib.bib92)]. For example, while AI is transforming the financial sector, encompassing areas such as customer service, fraud detection, risk management, credit assessments, and high-frequency trading, several challenges, particularly those related to transparency, are emerging alongside these advancements [[93](https://arxiv.org/html/2310.14735v4#bib.bib93), [94](https://arxiv.org/html/2310.14735v4#bib.bib94)]. Another example is medicine, where AI’s transformative potential faces similar challenges [[95](https://arxiv.org/html/2310.14735v4#bib.bib95), [96](https://arxiv.org/html/2310.14735v4#bib.bib96)].

In conclusion, the trajectory toward a better understanding of AI model structures promises to bring significant advancements in prompt engineering. As we research deeper into these intricate systems, we should be able to craft more effective prompts, understand the reasons behind prompt failures, and enhance the explainability of AI systems. This path holds the potential for transforming how we interact with and utilize AI systems, underscoring its importance in the future of prompt engineering.

###  4.2 Agent for AIGC tools

The concept of AI agents has emerged as a potential trajectory in AI research [[97](https://arxiv.org/html/2310.14735v4#bib.bib97)]. In this brief section, we explore the relationship between agents and prompt engineering and project how agents might influence the future trajectory of AI-generated content (AIGC) tools. By definition, an AI agent comprises large models, memory, active planning, and tool use. AI agents are capable of remembering and understanding a vast array of information, actively planning and strategizing, and effectively using various tools to generate optimal solutions within complex problem spaces [[98](https://arxiv.org/html/2310.14735v4#bib.bib98)].

The evolution of AI agents can be delineated into five distinct phases: models, prompt templates, chains, agents, and multi-agents. Each phase carries its specific implications for prompt engineering. Foundational models, exemplified by architectures such as GPT-4, underpin the realm of prompt engineering.

In particular, prompt templates offer an effective way of applying prompt engineering in practice [[18](https://arxiv.org/html/2310.14735v4#bib.bib18)]. By using these templates, we can create standardized prompts to guide large models, making the generated output more aligned with the desired outcome. The usage of prompt templates is a crucial step towards enabling AI agents to better understand and execute user instructions.

AI agents amalgamate these methodologies and tools into an adaptive framework. Possessing the capability to autonomously modulate their behaviors and strategies, they strive to optimize both efficiency and precision in task execution. A salient challenge for prompt engineering emerges: devising and instituting prompts that adeptly steer AI agents toward self-regulation [[16](https://arxiv.org/html/2310.14735v4#bib.bib16)].

In conclusion, the introduction of agent-based paradigms heralds a novel trajectory for the evolution of AIGC tools. This shift necessitates a reevaluation of established practices in prompt engineering and ushers in fresh challenges associated with the design, implementation, and refinement of prompts.

##  5 Assessing the efficacy of prompt methods

There are many different ways to evaluate the quality of the output. To assess the efficacy of current prompt methods in AIGC tools, evaluation methods can generally be divided into subjective and objective categories.

###  5.1 Subjective and objective evaluations

Subjective evaluations primarily rely on human evaluators to assess the quality of the generated content. Human evaluators can read the text generated by LLMs and score it for quality. Subjective evaluations typically include aspects such as fluency, accuracy, novelty, and relevance [[26](https://arxiv.org/html/2310.14735v4#bib.bib26)]. However, these evaluation methods are, by definition, subjective and can be prone to inconsistencies.

Objective evaluations, also known as automatic evaluation methods, use machine learning algorithms to score the quality of text generated by LLMs. Objective evaluations employ automated metrics, such as BiLingual Evaluation Understudy (BLEU) [[99](https://arxiv.org/html/2310.14735v4#bib.bib99)], which assigns a score to system-generated outputs, offering a convenient and rapid way to compare various systems and monitor their advancements. Other evaluations such as Recall-Oriented Understudy for Gisting Evaluation (ROUGE) [[100](https://arxiv.org/html/2310.14735v4#bib.bib100)], and Metric for Evaluation of Translation with Explicit ORdering (METEOR) [[101](https://arxiv.org/html/2310.14735v4#bib.bib101)], assess the similarity between the generated text and reference text. More recent evaluation methods, such as BERTScore [[102](https://arxiv.org/html/2310.14735v4#bib.bib102)], aim to assess at a higher semantic level. However, these automated metrics often fail to fully capture the assessment results of human evaluators and therefore must be used with caution [[103](https://arxiv.org/html/2310.14735v4#bib.bib103)].

Subjective evaluation and objective evaluation methods each have their own advantages and disadvantages. Subjective evaluation tends to be more reliable than objective evaluation, but it is also more expensive and time-consuming. Objective evaluation is less expensive and quicker than subjective evaluation. For instance, despite numerous pieces of research highlighting the limited correlation between BLEU and alternative metrics based on human assessments, their popularity has remained unaltered [[104](https://arxiv.org/html/2310.14735v4#bib.bib104), [105](https://arxiv.org/html/2310.14735v4#bib.bib105)]. Ultimately, the best way to evaluate the quality of LLM output depends on the specific application [[106](https://arxiv.org/html/2310.14735v4#bib.bib106)]. If quality is the most important factor, then using human evaluators is the better choice. If cost and time are the most important factors, then using automatic evaluation methods is better.

###  5.2 Comparing different prompt methods

In the field of prompt engineering, previous work has mostly focused on designing and optimizing specific prompting methods, but evaluating and comparing different prompting approaches in a systematic manner remains limited. There are some models that are increasingly used to grade the output of other models, which aim to ‘check’ the ability of other models [[107](https://arxiv.org/html/2310.14735v4#bib.bib107), [108](https://arxiv.org/html/2310.14735v4#bib.bib108)]. For instance, LLM-Eval [[109](https://arxiv.org/html/2310.14735v4#bib.bib109)] was developed to measure the open-domain conversations with LLMs. This method tries to evaluate the performance of LLMs on various benchmark datasets [[110](https://arxiv.org/html/2310.14735v4#bib.bib110), [111](https://arxiv.org/html/2310.14735v4#bib.bib111)] and demonstrate their efficiency. Other studies experiment mainly on certain models or tasks and employ disparate evaluation metrics, restricting comparability across methods [[112](https://arxiv.org/html/2310.14735v4#bib.bib112), [113](https://arxiv.org/html/2310.14735v4#bib.bib113)]. Nevertheless, recent research proposed a general evaluation framework called InstructEval [[114](https://arxiv.org/html/2310.14735v4#bib.bib114)] that enables a comprehensive assessment of prompting techniques across multiple models and tasks. The InstructEval study reached the following conclusions: in few-shot settings, omitting prompts or using generic task-agnostic prompts tends to outperform other methods, with prompts having little impact on performance; in zero-shot settings, expert-written task-specific prompts can significantly boost performance, with automated prompts not outperforming simple baselines; the performance of automated prompt generation methods is inconsistent, varying across different models and task types, displaying a lack of generalization. InstructEval provides important references for prompt engineering and demonstrates the need for more universal and reliable evaluation paradigms to design optimal prompts.

##  6 Applications improved by prompt engineering

The output enhancements provided by prompt engineering techniques make LLMs better applicable to real-world applications. This section briefly discusses applications of prompt engineering in fields such as teaching, programming, and others.

![Refer to caption](extracted/5676274/rubric_for_POA.png) Figure 10: Guideline of courses generated by GPT-4

###  6.1 Assessment in teaching and learning

The study [[115](https://arxiv.org/html/2310.14735v4#bib.bib115)] investigates the application of machine learning methods in young student education. In such a context, prompt engineering can facilitate the creation of personalized learning environments. By offering tailored prompts, LLMs can adapt to an individual’s learning pace and style. Such an approach can allow for personalized assessments and educational content, paving the way for a more individual-centric teaching model. Recent advancements in prompt engineering suggest that AI tools can also cater to students with specific learning needs, thus fostering inclusivity in education [[116](https://arxiv.org/html/2310.14735v4#bib.bib116)]. As a simple example, it is possible for professors to provide rubrics or guidelines for a future course with the assistance of AI. As Figure [10](https://arxiv.org/html/2310.14735v4#S6.F10 "Figure 10 ‣ 6 Applications improved by prompt engineering ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review") shows, when GPT-4 was required to provide a rubric about a course, with a suitable prompt, it was able to respond with a specific result that may satisfy the requirement.

The advancements in prompt engineering also bring better potential for automated grading in education. With the help of sophisticated prompts, LLMs can provide preliminary assessments, reducing the workload for educators while providing instant feedback to students [[117](https://arxiv.org/html/2310.14735v4#bib.bib117)]. Similarly, these models, when coupled with well-designed prompts, can analyze a vast amount of assessment data, thus providing valuable insights into learning patterns and informing educators about areas that require attention or improvement [[118](https://arxiv.org/html/2310.14735v4#bib.bib118), [119](https://arxiv.org/html/2310.14735v4#bib.bib119)].

###  6.2 Content creation and editing

With controllable improved input, LLMs have primarily been used in creative works, such as content creation. Pathways Language Model (PaLM) [[57](https://arxiv.org/html/2310.14735v4#bib.bib57)] and prompting approach have been used to facilitate cross-lingual short story generation [[10](https://arxiv.org/html/2310.14735v4#bib.bib10)]. The Recursive Reprompting and Revision framework (Re3superscriptRe3\mathrm{Re}^{3}roman_Re start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT) [[120](https://arxiv.org/html/2310.14735v4#bib.bib120)] employs zero-shot prompting [[51](https://arxiv.org/html/2310.14735v4#bib.bib51)] with GPT-3 to craft a foundational plan including elements such as settings, characters, and outlines. Subsequently, it adopts a recursive technique, dynamically prompting GPT-3 to produce extended story continuations. For another example, Detailed Outline Control (DOC) [[121](https://arxiv.org/html/2310.14735v4#bib.bib121)] aims at preserving plot coherence across extensive texts generated with the assistance of GPT-3. Unlike Re3superscriptRe3\mathrm{Re}^{3}roman_Re start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT, DOC employs a detailed outliner and detailed controller for implementation. The detailed outliner initially dissects the overarching outline into subsections through a breadth-first method, where candidate generations for these subsections are generated, filtered, and subsequently ranked. This process is similar to the method of chain-of-though (in Section [3.1](https://arxiv.org/html/2310.14735v4#S3.SS1 "3.1 Chain of thought ‣ 3 Advanced methodologies ‣ Unleashing the potential of prompt engineering in Large Language Models: a comprehensive review")). Throughout this generation process, an OPT-based Future Discriminators for Generation (FUDGE) [[122](https://arxiv.org/html/2310.14735v4#bib.bib122)] detailed controller plays a crucial role in maintaining relevance.

###  6.3 Computer programming

Prompt engineering can help LLMs perform better at outputting programming codes. By using a self-debugging prompting approach [[46](https://arxiv.org/html/2310.14735v4#bib.bib46)], which contains simple feedback, unit-test, and code explanation prompts module, the text-to-SQL [[123](https://arxiv.org/html/2310.14735v4#bib.bib123)] model is able to provide a solution it can state as correct unless the maximum number of attempts has been reached. Another example, Multi-Turn Programming Benchmark (MTPB) [[124](https://arxiv.org/html/2310.14735v4#bib.bib124)], was constructed to implement a program by breaking it into multi-step natural language prompts.

Another approach is provided in [[125](https://arxiv.org/html/2310.14735v4#bib.bib125)], which introduced the Repo-Level Prompt Generator (RLPG) to dynamically retrieve relevant repository context and construct a prompt for a given task, especially on code auto-completion task. The most suitable prompt is selected by a prompt proposal classifier and combined with the default context to generate the final output.

###  6.4 Reasoning tasks

AIGC tools have shown promising performance in reasoning tasks. Several previous researches found that few-shot prompting can enhance the performance in generating accurate reasoning steps for word-based math problems in the GSM8K dataset [[49](https://arxiv.org/html/2310.14735v4#bib.bib49), [57](https://arxiv.org/html/2310.14735v4#bib.bib57), [44](https://arxiv.org/html/2310.14735v4#bib.bib44), [56](https://arxiv.org/html/2310.14735v4#bib.bib56)]. The strategy of including the reasoning traces in such as few-shot prompts [[35](https://arxiv.org/html/2310.14735v4#bib.bib35)], self-talk [[126](https://arxiv.org/html/2310.14735v4#bib.bib126)] and chain-of-thought [[18](https://arxiv.org/html/2310.14735v4#bib.bib18)], was shown to encourage the model to generate verbalized reasoning steps. [[127](https://arxiv.org/html/2310.14735v4#bib.bib127)] conducted experiments by involving prompting strategies, various fine-tuning techniques, and re-ranking methods to assess their impact on enhancing the performance of a base LLM. They found that a customized prompt significantly improved the model’s ability with fine-tuning, and demonstrated a significant advantage by generating substantially fewer errors in reasoning. In another research, [[51](https://arxiv.org/html/2310.14735v4#bib.bib51)] observed that solely using zero-shot CoT prompting leads to a significant enhancement in the performance of GPT-3 and PaLM when compared to the conventional zero-shot and few-shot prompting methods. This improvement is particularly noticeable when evaluating these models on the MultiArith [[128](https://arxiv.org/html/2310.14735v4#bib.bib128)] and GSM8K [[49](https://arxiv.org/html/2310.14735v4#bib.bib49)] datasets. [[129](https://arxiv.org/html/2310.14735v4#bib.bib129)] also introduced a novel prompting approach called Diverse Verifier on Reasoning Step (DIVERSE). This approach involves using a diverse set of prompts for each question and incorporates a trained verifier with an awareness of reasoning steps. The primary aim of DIVERSE is to enhance the performance of GPT-3 on various reasoning benchmarks, including GSM8K and others. All these works show that in the application of reasoning tasks, properly customized prompts can obtain better results from the model.

###  6.5 Dataset generation

LLMs possess the capability of in-context learning, enabling them to be effectively prompted to generate synthetic datasets for training smaller, domain-specific models. [[130](https://arxiv.org/html/2310.14735v4#bib.bib130)] put forth three distinct prompting approaches for training data generation using GPT-3: unlabeled data annotation, training data generation, and assisted training data generation. Besides, [[131](https://arxiv.org/html/2310.14735v4#bib.bib131)] is designed for the generation of supplementary synthetic data for classification tasks. GPT-3 is utilized in conjunction with a prompt that includes real examples from an existing dataset, along with a task specification. The goal is to jointly create synthetic examples and pseudo-labels using this combination of inputs.

##  7 Conclusion

In this paper, we present a comprehensive overview of prompt engineering techniques and their instrumental role in refining Large Language Models (LLMs). We detail both foundational and advanced methodologies in prompt engineering, illustrating their efficacy in directing LLMs toward targeted outputs. We also analyze retrieval augmentation and plugins, which can further augment prompt engineering. We discuss broader applications of prompt engineering, highlighting its potential in sectors such as education and programming. We finally cast a forward-looking gaze on the future avenues of prompt engineering, underscoring the need for a deeper understanding of LLM architectures and the significance of agent-based paradigms. In summary, prompt engineering has emerged as a critical technique for guiding and optimizing LLMs. As the ubiquity of prompt engineering develops, we hope that this paper can lay the groundwork for further research.

##  8 Acknowledgement

This work was funded by the Natural Science Foundation of China (12271047); Guangdong Provincial Key Laboratory of Interdisciplinary Research and Application for Data Science, BNU-HKBU United International College (2022B1212010006); UIC research grant (R0400001-22; UICR0400008-21; UICR0700041-22; R72021114); Guangdong College Enhancement and Innovation Program (2021ZDZX1046).

## References

  * \bibcommenthead
  * Vaswani et al. [2017] Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez AN, et al.  Attention is all you need.  In: Proceedings of the 31st International Conference on Neural Information Processing Systems. NIPS’17; 2017. p. 6000–6010. 
  * Bender et al. [2021] Bender EM, Gebru T, McMillan-Major A, Shmitchell S.  On the dangers of stochastic parrots: can language models be too big?  In: Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency; 2021. p. 610–623. 
  * Brown et al. [2020] Brown TB, Mann B, Ryder N, Subbiah M, Kaplan J, Dhariwal P, et al.  language models Are Few-Shot Learners.  In: Proceedings of the 34th International Conference on Neural Information Processing Systems. NIPS’20; 2020. . 
  * OpenAI [2023] OpenAI.  GPT-4 Technical Report; 2023.  ArXiv:2303.08774. 
  * Hulbert [2023] Hulbert D.: Tree of knowledge: ToK aka Tree of Knowledge dataset for Large Language Models LLM.  Accessed: 2023-8-15.  figshare <https://github.com/dave1010/tree-of-thought-prompting>. 
  * Anthropic [2023] Anthropic.: Claude2.  Accessed: 2023-7-11.  figshare <https://www.anthropic.com>. 
  * Touvron et al. [2023] Touvron H, Martin L, Stone K, Albert P, Almahairi A, Babaei Y, et al.  Llama 2: open foundation and fine-tuned chat models; 2023.  ArXiv:2307.09288. 
  * Sarkhel et al. [2023] Sarkhel R, Huang B, Lockard C, Shiralkar P.  Self-training for label-efficient information extraction from semi-structured web-pages.  Proceedings of the VLDB Endowment. 2023;16(11):3098–3110. 
  * Cheng et al. [2023] Cheng L, Li X, Bing L.  Is GPT-4 a good data analyst?; 2023.  ArXiv:2305.15038. 
  * Razumovskaia et al. [2022] Razumovskaia E, Maynez J, Louis A, Lapata M, Narayan S.  Little red riding hood goes around the globe: crosslingual story planning and generation with large language models; 2022.  ArXiv:2212.10471. 
  * Manning et al. [2022] Manning S, Mishkin P, Hadfield G, Eloundou T, Eisner E.  A research agenda for assessing the economic impacts of code generation models; 2022. 
  * Choudhury et al. [2020] Choudhury A, Asan O, et al.  Role of artificial intelligence in patient safety outcomes: systematic literature review.  JMIR medical informatics. 2020;8(7):e18599. 
  * Baidoo-Anu and Ansah [2023] Baidoo-Anu D, Ansah LO.  Education in the era of generative artificial intelligence (AI): understanding the potential benefits of ChatGPT in promoting teaching and learning.  Journal of AI. 2023;7(1):52–62. 
  * Kaddour et al. [2023] Kaddour J, Harris J, Mozes M, Bradley H, Raileanu R, McHardy R.  Challenges and applications of large language models; 2023.  ArXiv:2307.10169. 
  * Lu et al. [2022] Lu Y, Bartolo M, Moore A, Riedel S, Stenetorp P.  Fantastically ordered prompts and where to find them: overcoming few-shot prompt order sensitivity.  In: Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics; 2022. p. 8086–8098. 
  * Webson and Pavlick [2022] Webson A, Pavlick E.  Do prompt-based models really understand the meaning of their prompts?  In: Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies; 2022. p. 2300–2344. 
  * Shanahan et al. [2023] Shanahan M, McDonell K, Reynolds L.  Role-play with large language models; 2023.  ArXiv:2305.16367. 
  * Wei et al. [2022] Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, et al.  Chain-of-thought prompting elicits reasoning in large language models.  In: Advances in Neural Information Processing Systems. vol. 35; 2022. p. 24824–24837. 
  * Maynez et al. [2020] Maynez J, Narayan S, Bohnet B, McDonald R.  On faithfulness and factuality in abstractive summarization.  In: Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics; 2020. p. 1906–1919. 
  * Bubeck et al. [2023] Bubeck S, Chandrasekaran V, Eldan R, Gehrke J, Horvitz E, Kamar E, et al.  Sparks of artificial general intelligence: early experiments with GPT-4; 2023.  ArXiv:2303.12712. 
  * Yong et al. [2022] Yong G, Jeon K, Gil D, Lee G.  Prompt engineering for zero‐shot and few‐shot defect detection and classification using a visual‐language pretrained model.  Computer-Aided Civil and Infrastructure Engineering. 2022;38(11):1536–1554. 
  * Christiano et al. [2017] Christiano PF, Leike J, Brown T, Martic M, Legg S, Amodei D.  Deep reinforcement learning from human preferences.  Advances in neural information processing systems. 2017;30. 
  * Stiennon et al. [2020] Stiennon N, Ouyang L, Wu J, Ziegler D, Lowe R, Voss C, et al.  Learning to summarize with human feedback.  Advances in Neural Information Processing Systems. 2020;33:3008–3021. 
  * Radford et al. [2018] Radford A, Narasimhan K, Salimans T, Sutskever I, et al.  Improving language understanding by generative pre-training; 2018.  Https://openai.com/research/language-unsupervised. 
  * Radford et al. [2019] Radford A, Wu J, Child R, Luan D, Amodei D, Sutskever I, et al.: Language models are unsupervised multitask learners.  Assessed: 2019-02-07.  figshare <https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf>. 
  * Holtzman et al. [2020] Holtzman A, Buys J, Du L, Forbes M, Choi Y.  The curious case of neural text degeneration.  In: International Conference on Learning Representations; 2020. . 
  * Welleck et al. [2019] Welleck S, Kulikov I, Roller S, Dinan E, Cho K, Weston J.  Neural text generation with unlikelihood training; 2019.  ArXiv:1908.04319. 
  * Xu et al. [2023] Xu X, Tao C, Shen T, Xu C, Xu H, Long G, et al.  Re-reading improves reasoning in language models; 2023.  ArXiv:2309.06275. 
  * YanSong and JingLi Tencent [2018] YanSong S, JingLi Tencent A.  Joint learning embeddings for Chinese words and their components via ladder structured networks.  In: Proceedings of the Twenty-Seventh International Joint Conference on Artifificial Intelligence (IJCAI-18); 2018. p. 4375–4381. 
  * Luo et al. [2019] Luo L, Ao X, Song Y, Li J, Yang X, He Q, et al.  Unsupervised neural aspect extraction with sememes.  In: IJCAI; 2019. p. 5123–5129. 
  * Yang et al. [2019] Yang M, Qu Q, Tu W, Shen Y, Zhao Z, Chen X.  Exploring human-like reading strategy for abstractive text summarization.  In: Proceedings of the AAAI conference on artificial intelligence. vol. 33; 2019. p. 7362–7369. 
  * Zhang et al. [2023] Zhang Z, Gao J, Dhaliwal RS, Jia-Jun Li T.  VISAR: a human-AI argumentative writing assistant with visual programming and rapid draft prototyping; 2023.  ArXiv:2304.07810. 
  * Buren [2023] Buren DV.  Guided scenarios with simulated expert personae: a remarkable strategy to perform cognitive work; 2023.  ArXiv:2306.03104. 
  * OpenAI [2023] OpenAI.: Tactic: use delimiters to clearly indicate distinct parts of the input.  Accessed: 2023-09-01.  figshare <https://platform.openai.com/docs/guides/gpt-best-practices/tactic-use-delimiters-to-clearly-indicate-distinct-parts-of-the-input>. 
  * Logan IV et al. [2022] Logan IV R, Balažević I, Wallace E, Petroni F, Singh S, Riedel S.  Cutting down on prompts and parameters: simple few-shot learning with language models.  In: Findings of the Association for Computational Linguistics: ACL 2022; 2022. p. 2824–2835. 
  * Shyr et al. [2023] Shyr C, Hu Y, Harris PA, Xu H.  Identifying and extracting rare disease phenotypes with Large language models; 2023.  ArXiv:2306.12656. 
  * Reynolds and McDonell [2021] Reynolds L, McDonell K.  Prompt programming for large language models: beyond the few-shot paradigm.  In: Extended Abstracts of the 2021 CHI Conference on Human Factors in Computing Systems; 2021. p. 1–7. 
  * Liu et al. [2020] Liu J, Gardner M, Cohen SB, Lapata M.  Multi-step inference for reasoning over paragraphs; 2020.  ArXiv:2004.02995. 
  * Ackley et al. [1985] Ackley DH, Hinton GE, Sejnowski TJ.  A learning algorithm for Boltzmann machines.  Cognitive Science. 1985;9(1):147–169. 
  * Ficler and Goldberg [2017] Ficler J, Goldberg Y.  Controlling linguistic style aspects in neural language generation.  In: Proceedings of the Workshop on Stylistic Variation; 2017. p. 94–104. 
  * Xu et al. [2023] Xu C, Guo D, Duan N, McAuley J.  RIGA at SemEval-2023 Task 2: NER enhanced with GPT-3.  In: Proceedings of the 17th International Workshop on Semantic Evaluation (SemEval-2023); 2023. p. 331–339. 
  * Wu et al. [2023] Wu S, Shen EM, Badrinath C, Ma J, Lakkaraju H.  Analyzing chain-of-thought prompting in Large language models via gradient-based feature Attributions; 2023.  ArXiv:2307.13339. 
  * Zhang et al. [2023] Zhang Z, Zhang A, Li M, Smola A.  Automatic chain of thought prompting in Large language models.  In: Eleventh International Conference on Learning Representations; 2023. . 
  * Lewkowycz et al. [2022] Lewkowycz A, Andreassen A, Dohan D, Dyer E, Michalewski H, Ramasesh V, et al.  Solving quantitative reasoning problems with language models.  Advances in Neural Information Processing Systems. 2022;35:3843–3857. 
  * Zhou et al. [2022] Zhou H, Nova A, Larochelle H, Courville A, Neyshabur B, Sedghi H.  Teaching Algorithmic Reasoning via In-context Learning; 2022.  ArXiv:2211.09066. 
  * Lee et al. [2023] Lee N, Sreenivasan K, Lee JD, Lee K, Papailiopoulos D.  Teaching arithmetic to small transformers; 2023.  ArXiv:2307.03381. 
  * Wei et al. [2022] Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, et al.  Large language models perform diagnostic reasoning.  In: Eleventh International Conference on Learning Representations; 2022. . 
  * Zhang and Parkes [2023] Zhang H, Parkes DC.  Chain-of-thought reasoning is a policy improvement operator; 2023.  ArXiv:2309.08589. 
  * Cobbe et al. [2021] Cobbe K, Kosaraju V, Bavarian M, Chen M, Jun H, Kaiser L, et al.  Training verifiers to solve math word problems; 2021.  ArXiv:2110.14168. 
  * Huang et al. [2023] Huang S, Dong L, Wang W, Hao Y, Singhal S, Ma S, et al.  Language is not all you need: aligning perception with language models; 2023.  ArXiv:2302.14045. 
  * Kojima et al. [2022] Kojima T, Gu SS, Reid M, Matsuo Y, Iwasawa Y.  Large language models are zero-shot reasoners.  Advances in Neural Information Processing Systems. 2022;35:22199–22213. 
  * Del and Fishel [2023] Del M, Fishel M.  True detective: a deep abductive reasoning benchmark undoable for GPT-3 and challenging for GPT-4.  In: Proceedings of the 12th Joint Conference on Lexical and Computational Semantics (*SEM 2023); 2023. . 
  * Ouyang et al. [2022] Ouyang L, Wu J, Jiang X, Almeida D, Wainwright C, Mishkin P, et al.  Training language models to follow instructions with human feedback.  Advances in Neural Information Processing Systems. 2022;35:27730–27744. 
  * Saparov and He [2022] Saparov A, He H.  Language models are greedy reasoners: a systematic formal analysis of chain-of-thought; 2022.  ArXiv:2210.01240. 
  * Tafjord et al. [2021] Tafjord O, Dalvi B, Clark P.  ProofWriter: generating implications, proofs, and abductive statements over natural language.  In: Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021; 2021. p. 3621–3634. 
  * Wang et al. [2023] Wang X, Wei J, Schuurmans D, Le QV, Chi EH, Narang S, et al.  Self-consistency improves chain of thought reasoning in language models.  In: Eleventh International Conference on Learning Representations; 2023. . 
  * Chowdhery et al. [2022] Chowdhery A, Narang S, Devlin J, Bosma M, Mishra G, Roberts A, et al.  Palm: scaling language modeling with pathways; 2022.  ArXiv:2204.02311. 
  * Fan et al. [2018] Fan A, Lewis M, Dauphin Y.  Hierarchical neural story generation.  In: Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers); 2018. p. 889–898. 
  * Holtzman et al. [2018] Holtzman A, Buys J, Forbes M, Bosselut A, Golub D, Choi Y.  Learning to write with cooperative discriminators.  In: Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers); 2018. p. 1638–1649. 
  * Huang et al. [2022] Huang J, Gu SS, Hou L, Wu Y, Wang X, Yu H, et al.  Large language models can self-improve; 2022.  ArXiv:2210.11610. 
  * Shum et al. [2023] Shum K, Diao S, Zhang T.  Automatic prompt augmentation and selection with chain-of-thought from labeled data; 2023.  ArXiv:2302.12822. 
  * Khalifa et al. [2023] Khalifa M, Logeswaran L, Lee M, Lee H, Wang L.  Discriminator-guided multi-step reasoning with language models; 2023.  ArXiv:2305.14934. 
  * Liu et al. [2022] Liu J, Liu A, Lu X, Welleck S, West P, Le Bras R, et al.  Generated knowledge prompting for commonsense reasoning.  In: Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers); 2022. p. 3154–3169. 
  * Zhou et al. [2023] Zhou D, Schärli N, Hou L, Wei J, Scales N, Wang X, et al.  Least-to-most prompting enables complex reasoning in Large language models.  In: Eleventh International Conference on Learning Representations; 2023. . 
  * Yao et al. [2023] Yao S, Yu D, Zhao J, Shafran I, Griffiths TL, Cao Y, et al.  Tree of thoughts: deliberate problem solving with large language models; 2023.  ArXiv:2305.10601. 
  * Long [2023] Long J.  Large language model guided tree-of-thought; 2023.  ArXiv:2305.08291. 
  * Besta et al. [2023] Besta M, Blach N, Kubicek A, Gerstenberger R, Gianinazzi L, Gajda J, et al.  Graph of thoughts: solving elaborate problems with large language models; 2023.  ArXiv:2308.09687. 
  * Wang et al. [2023] Wang L, Ma C, Feng X, Zhang Z, Yang H, Zhang J, et al.  A survey on large language model based autonomous agents; 2023.  ArXiv:2308.11432. 
  * Lee et al. [2018] Lee K, Firat O, Agarwal A, Fannjiang C, Sussillo D.  Hallucinations in neural machine translation; 2018. 
  * Ji et al. [2023] Ji Z, Lee N, Frieske R, Yu T, Su D, Xu Y, et al.  Survey of hallucination in natural language generation.  ACM Computing Surveys. 2023;55(12):1–38. 
  * Lazaridou et al. [2022] Lazaridou A, Gribovskaya E, Stokowiec W, Grigorev N.  Internet-augmented language models through few-shot prompting for open-domain question answering; 2022.  ArXiv:2203.05115. 
  * Jiang et al. [2023] Jiang Z, Xu FF, Gao L, Sun Z, Liu Q, Dwivedi-Yu J, et al.  Active retrieval augmented generation; 2023.  ArXiv:2305.06983. 
  * Ram et al. [2023] Ram O, Levine Y, Dalmedigos I, Muhlgay D, Shashua A, Leyton-Brown K, et al.  In-context retrieval-augmented language models; 2023.  ArXiv:2302.00083. 
  * Shuster et al. [2021] Shuster K, Poff S, Chen M, Kiela D, Weston J.  Retrieval augmentation reduces hallucination in conversation; 2021.  ArXiv:2104.07567. 
  * Lewis et al. [2020] Lewis P, Perez E, Piktus A, Petroni F, Karpukhin V, Goyal N, et al.  Retrieval-augmented generation for knowledge-intensive nlp tasks.  Advances in Neural Information Processing Systems. 2020;33:9459–9474. 
  * Izacard and Grave [2020] Izacard G, Grave E.  Leveraging passage retrieval with generative models for open domain question answering; 2020.  ArXiv:2007.01282. 
  * Lewis et al. [2020] Lewis M, Liu Y, Goyal N, Ghazvininejad M, Mohamed A, Levy O, et al.  BART: denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension.  In: Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics; 2020. p. 7871–7880. 
  * Raffel et al. [2020] Raffel C, Shazeer N, Roberts A, Lee K, Narang S, Matena M, et al.  Exploring the limits of transfer learning with a unified text-to-text transformer.  Journal of Machine Learning Research. 2020;21(1):5485–5551. 
  * Roller et al. [2021] Roller S, Dinan E, Goyal N, Ju D, Williamson M, Liu Y, et al.  Recipes for building an open-domain chatbot.  In: Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume; 2021. p. 300–325. 
  * Dhuliawala et al. [2023] Dhuliawala S, Komeili M, Xu J, Raileanu R, Li X, Celikyilmaz A, et al.  Chain-of-verification reduces hallucination in large language models; 2023.  ArXiv:2309.11495. 
  * OpenAI [2023] OpenAI.: ChatGPT plugins.  Accessed: 2023-10-15.  figshare <https://openai.com/blog/chatgpt-plugins>. 
  * Bisson [2023] Bisson S.: Microsoft build 2023: Microsoft extends its copilots with open standard plugins.  Accessed: 2023-05-25.  figshare <https://www.techrepublic.com/article/microsoft-extends-copilot-with-open-standard-plugins/>. 
  * Ng [2023] Ng A.: ChatGPT prompt engineering for developers.  Accessed: 2023-07-18.  figshare <https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/>. 
  * Roller et al. [2021] Roller S, Dinan E, Goyal N, Ju D, Williamson M, Liu Y, et al.  Recipes for building an open-domain chatbot.  In: Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume; 2021. p. 300–325. 
  * whatplugin [2023] whatplugin.: Prompt enhancer & ChatGPT plugins for AI development tools like prompt enhancer.  Accessed: 2023-09-14.  figshare <https://www.whatplugin.ai/plugins/prompt-enhancer>. 
  * [86] : AISEO.  Accessed: 2023-8-15.  figshare <https://aiseo.ai/>. 
  * for Search Engines [2023] for Search Engines C.: Prompt perfect plugin for ChatGPT.  Accessed: 2023-10-15.  figshare <https://chatonai.org/prompt-perfect-chatgpt-plugin>. 
  * Prompt Perfect [2023] Prompt Perfect.: Terms of service.  Accessed: 2023-09-20.  figshare <https://promptperfect.xyz/static/terms.html>. 
  * Linardatos et al. [2020] Linardatos P, Papastefanopoulos V, Kotsiantis S.  Explainable AI: a review of machine learning interpretability methods.  Entropy. 2020;23(1):18. 
  * Recht et al. [2011] Recht B, Re C, Wright S, Niu F.  Hogwild!: a lock-free approach to parallelizing stochastic gradient descent.  In: Advances in neural information processing systems. vol. 24; 2011. . 
  * Melnychuk et al. [2022] Melnychuk V, Frauen D, Feuerriegel S.  Causal transformer for estimating counterfactual outcomes.  In: International Conference on Machine Learning; 2022. p. 15293–15329. 
  * Novakovsky et al. [2023] Novakovsky G, Dexter N, Libbrecht MW, Wasserman WW, Mostafavi S.  Obtaining genetics insights from deep learning via explainable artificial intelligence.  Nature Reviews Genetics. 2023;24(2):125–137. 
  * Bertucci et al. [2022] Bertucci L, Brière M, Fliche O, Mikael J, Szpruch L.  Deep learning in finance: from implementation to regulation; 2022.  SSRN:4080171. 
  * Maple et al. [2023] Maple C, Szpruch L, Epiphaniou G, Staykova K, Singh S, Penwarden W, et al.  The AI revolution: opportunities and challenges for the finance sector; 2023.  ArXiv:2308.16538. 
  * Amann et al. [2020] Amann J, Blasimme A, Vayena E, Frey D, Madai VI.  Explainability for artificial intelligence in healthcare: a multidisciplinary perspective.  BMC Medical Informatics and Decision Making. 2020;20(1):1–9. 
  * Rajpurkar et al. [2022] Rajpurkar P, Chen E, Banerjee O, Topol EJ.  AI in health and medicine.  Nature Medicine. 2022;28(1):31–38. 
  * Öztürk [2021] Öztürk D.  What does artificial intelligence mean for organizations? A systematic review of organization studies research and a way forward.  The Impact of Artificial Intelligence on Governance, Economics and Finance, Volume I. 2021;p. 265–289. 
  * Seeamber and Badea [2023] Seeamber R, Badea C.  If our aim is to build morality into an artificial agent, how might we begin to go about doing so?  IEEE Intelligent Systems. 2023;. 
  * Papineni et al. [2002] Papineni K, Roukos S, Ward T, Zhu WJ.  BLEU: a method for automatic evaluation of machine translation.  In: Proceedings of the 40th Annual Meeting on Association for Computational Linguistics; 2002. p. 311–318. 
  * Chin-Yew [2004] Chin-Yew L.  ROUGE: a package for automatic evaluation of summaries.  In: Text Summarization Branches Out; 2004. p. 74–81. 
  * Banerjee and Lavie [2005] Banerjee S, Lavie A.  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; 2005. p. 65–72. 
  * Zhang et al. [2020] Zhang T, Kishore V, Wu F, Weinberger KQ, Artzi Y.  BERTScore: evaluating text generation with BERT.  In: International Conference on Learning Representations; 2020. . 
  * Sai et al. [2022] Sai AB, Mohankumar AK, Khapra MM.  A survey of evaluation metrics used for NLG systems.  ACM Computing Surveys (CSUR). 2022;55(2):1–39. 
  * Ananthakrishnan et al. [2007] Ananthakrishnan R, Bhattacharyya P, Sasikumar M, Shah RM.  Some issues in automatic evaluation of english-hindi mt: more blues for bleu.  Icon. 2007;64. 
  * Callison-Burch et al. [2006] Callison-Burch C, Osborne M, Koehn P.  Re-evaluating the role of BLEU in machine translation research.  In: 11th Conference of the European Chapter of the Association for Computational Linguistics; 2006. p. 249–256. 
  * Stent et al. [2005] Stent A, Marge M, Singhai M.  Evaluating evaluation methods for generation in the presence of variation.  In: International Conference on Intelligent Text Processing and Computational Linguistics. Springer; 2005. p. 341–351. 
  * Jain et al. [2023] Jain N, Saifullah K, Wen Y, Kirchenbauer J, Shu M, Saha A, et al.  Bring your own data! Self-supervised evaluation for large language models; 2023.  ArXiv:2306.13651. 
  * Wang et al. [2023] Wang Y, Yu Z, Zeng Z, Yang L, Wang C, Chen H, et al.  PandaLM: an automatic evaluation benchmark for LLM instruction tuning optimization; 2023.  ArXiv:2306.05087. 
  * Lin and Chen [2023] Lin YT, Chen YN.  LLM-eval: unified multi-dimensional automatic evaluation for open-domain conversations with large language models; 2023.  ArXiv:2305.13711. 
  * Kiela et al. [2021] Kiela D, Bartolo M, Nie Y, Kaushik D, Geiger A, Wu Z, et al.  Dynabench: rethinking benchmarking in NLP; 2021.  ArXiv:2104.14337. 
  * Dehghani et al. [2021] Dehghani M, Tay Y, Gritsenko AA, Zhao Z, Houlsby N, Diaz F, et al.  The benchmark lottery; 2021.  ArXiv:2107.07002. 
  * Deng et al. [2022] Deng M, Wang J, Hsieh CP, Wang Y, Guo H, Shu T, et al.  RLPrompt: optimizing discrete text prompts with reinforcement learning.  In: Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing; 2022. p. 3369–3391. 
  * Zhou et al. [2022] Zhou Y, Muresanu AI, Han Z, Paster K, Pitis S, Chan H, et al.  Large language models are human-level prompt engineers.  In: Eleventh International Conference on Learning Representations; 2022. . 
  * Ajith et al. [2023] Ajith A, Pan C, Xia M, Deshpande A, Narasimhan K.  InstructEval: systematic evaluation of instruction selection methods; 2023.  ArXiv:2307.00259. 
  * Tang et al. [2023] Tang J, Zhou X, Wan X, Daley M, Bai Z.  ML4STEM professional development program: enriching K-12 STEM teaching with machine learning.  International Journal of Artificial Intelligence in Education. 2023;33(1):185–224. 
  * Xie et al. [2020] Xie Q, Dai Z, Hovy E, Luong MT, Le QV.  Unsupervised data augmentation for consistency training.  In: Advances in neural information processing systems. vol. 33; 2020. p. 6256–6268. 
  * Ariely et al. [2023] Ariely M, Nazaretsky T, Alexandron G.  Machine learning and Hebrew NLP for automated assessment of open-ended questions in biology.  International Journal of Artificial Intelligence in Education. 2023;33(1):1–34. 
  * Nilsson and Tuvstedt [2023] Nilsson F, Tuvstedt J.  GPT-4 as an automatic grader: the accuracy of grades set by GPT-4 on introductory programming assignments [Bachelor Thesis].  KTH Royal Institute of Technology; 2023. 
  * Schneider et al. [2023] Schneider J, Richner R, Riser M.  Towards trustworthy autograding of short, multi-lingual, multi-type answers.  International Journal of Artificial Intelligence in Education. 2023;33(1):88–118. 
  * Yang et al. [2022] Yang K, Peng N, Tian Y, Klein D.  Re3: generating longer stories with recursive reprompting and revision; 2022.  ArXiv:2210.06774. 
  * Yang et al. [2022] Yang K, Klein D, Peng N, Tian Y.  Doc: improving long story coherence with detailed outline control; 2022.  ArXiv:2212.10077. 
  * Yang and Klein [2021] Yang K, Klein D.  FUDGE: controlled text generation with future discriminators; 2021.  ArXiv:2104.05218. 
  * Elgohary et al. [2020] Elgohary A, Hosseini S, Awadallah AH.  Speak to your parser: interactive text-to-SQL with natural language feedback.  In: Annual Meeting of the Association for Computational Linguistics; 2020. . 
  * Nijkamp et al. [2022] Nijkamp E, Pang B, Hayashi H, Tu L, Wang H, Zhou Y, et al.  Codegen: an open large language model for code with multi-turn program synthesis; 2022.  ArXiv:2203.13474. 
  * Shrivastava et al. [2023] Shrivastava D, Larochelle H, Tarlow D.  Repository-level prompt generation for large language models of code.  In: International Conference on Machine Learning; 2023. p. 31693–31715. 
  * Shwartz et al. [2020] Shwartz V, West P, Bras RL, Bhagavatula C, Choi Y.  Unsupervised commonsense question answering with self-talk; 2020.  ArXiv:2004.05483. 
  * Uesato et al. [2022] Uesato J, Kushman N, Kumar R, Song F, Siegel N, Wang L, et al.  Solving math word problems with process-and outcome-based feedback; 2022.  ArXiv:2211.14275. 
  * Roy and Roth [2015] Roy S, Roth D.  Solving general arithmetic word problems.  In: Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing; 2015. p. 1743–1752. 
  * Li et al. [2023] Li Y, Lin Z, Zhang S, Fu Q, Chen B, Lou JG, et al.  Making language models better reasoners with step-aware Verifier.  In: Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Toronto, Canada: Association for Computational Linguistics; 2023. p. 5315–5333.  Available from: <https://aclanthology.org/2023.acl-long.291>. 
  * Ding et al. [2022] Ding B, Qin C, Liu L, Bing L, Joty S, Li B.  Is GPT-3 a good data annotator?; 2022.  ArXiv:2212.10450. 
  * Yoo et al. [2021] Yoo KM, Park D, Kang J, Lee SW, Park W.  GPT3Mix: leveraging large-scale language models for text augmentation.  In: Findings of the Association for Computational Linguistics: EMNLP 2021; 2021. p. 2225–2239. 





url: https://www.jmir.org/2024/1/e60501/
scrape_date: 2025-03-17T12:00:37.219273
content_type: markdown
hash: 4b74e53d1fcded94216015b4f480fd36c09573eac294513b73148c6fb50f9187
title:
Journal of Medical Internet Research - Prompt Engineering Paradigms for Medical Applications: Scoping Review

content:
Skip to Main Content  Skip to Footer 

[![JMIR Publications](https://asset.jmir.pub/resources/images/logos/JMIR_logo.png)](https://jmirpublications.com)

Select options  Articles  Help 

  * [ Career Center ](https://careers.jmir.org/)
  * [Login](javascript:;)
  * Register



  * [ Journal of Medical Internet Research ](/)

    * [Journal of Medical Internet Research 9502 articles ](/)
    * [JMIR Research Protocols 4498 articles ](https://www.researchprotocols.org)
    * [JMIR Formative Research 3332 articles ](https://formative.jmir.org)
    * [JMIR mHealth and uHealth 2764 articles ](https://mhealth.jmir.org)
    * [Online Journal of Public Health Informatics 1723 articles ](https://ojphi.jmir.org)
    * [JMIR Public Health and Surveillance 1713 articles ](https://publichealth.jmir.org)
    * [JMIR Medical Informatics 1474 articles ](https://medinform.jmir.org)
    * [JMIR Mental Health 1119 articles ](https://mental.jmir.org)
    * [JMIR Human Factors 881 articles ](https://humanfactors.jmir.org)
    * [JMIR Serious Games 673 articles ](https://games.jmir.org)
    * [JMIR Medical Education 597 articles ](https://mededu.jmir.org)
    * [Iproceedings 510 articles ](https://www.iproc.org)
    * [JMIR Aging 477 articles ](https://aging.jmir.org)
    * [JMIRx Med 468 articles ](https://xmed.jmir.org)
    * [Interactive Journal of Medical Research 467 articles ](https://www.i-jmr.org)
    * [JMIR Pediatrics and Parenting 443 articles ](https://pediatrics.jmir.org)
    * [JMIR Cancer 434 articles ](https://cancer.jmir.org)
    * [JMIR Dermatology 319 articles ](https://derma.jmir.org)
    * [JMIR Diabetes 278 articles ](https://diabetes.jmir.org)
    * [JMIR Rehabilitation and Assistive Technologies 275 articles ](https://rehab.jmir.org)
    * [JMIR Cardio 213 articles ](https://cardio.jmir.org)
    * [JMIR Infodemiology 169 articles ](https://infodemiology.jmir.org)
    * [JMIR AI 135 articles ](https://ai.jmir.org)
    * [JMIR Perioperative Medicine 124 articles ](https://periop.jmir.org)
    * [JMIR Nursing 120 articles ](https://nursing.jmir.org)
    * [Journal of Participatory Medicine 107 articles ](https://jopm.jmir.org)
    * [JMIR Biomedical Engineering 96 articles ](https://biomedeng.jmir.org)
    * [JMIR Bioinformatics and Biotechnology 54 articles ](https://bioinform.jmir.org)
    * [Asian/Pacific Island Nursing Journal 31 articles ](https://apinj.jmir.org)
    * [JMIR Neurotechnology 27 articles ](https://neuro.jmir.org)
    * [Medicine 2.0 26 articles ](https://www.medicine20.com)
    * [JMIRx Bio 26 articles ](https://xbio.jmir.org)
    * [JMIR XR and Spatial Computing (JMXR) 25 articles ](https://xr.jmir.org)
    * [JMIR Data ](https://data.jmir.org)
    * [JMIR Challenges ](https://challenges.jmir.org)
    * [JMIR Preprints ](https://preprints.jmir.org)
  * Journal Information 
    * [ Focus and Scope ](/about-journal/focus-and-scope)
    * [ Editorial Board ](/about-journal/editorial-board)
    * [ Author Information ](/author-information/instructions-for-authors)
    * [ Resource Center ](/resource-centre/author-hub)
    * [ Article Processing Fees ](/about-journal/article-processing-fees)
    * [ Publishing Policies ](/publishing-policies/section-policies)
    * [ Get Involved ](/get-involved/new-journal-editor-in-chief-proposals)
    * [ Top Articles ](/top-articles/overview)
    * [ Institutional Partners ](/fees/institutional-partners)
    * [ Indexing and Impact Factor ](/about-journal/indexing-and-impact-factor)
  * Browse Journal 
    * Year:  Select...  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025 

    * [ Latest Announcements ](/announcements)
    * [ Authors ](/search/authors)
    * [ Themes ](/themes)
    * [ Issues ](/issues)
    * [ Blog ](https://blog.jmir.org/)
  * [Submit Article](/author)



  * [ Journal of Medical Internet Research ](/)

    * [Journal of Medical Internet Research 9502 articles ](/)
    * [JMIR Research Protocols 4498 articles ](https://www.researchprotocols.org)
    * [JMIR Formative Research 3332 articles ](https://formative.jmir.org)
    * [JMIR mHealth and uHealth 2764 articles ](https://mhealth.jmir.org)
    * [Online Journal of Public Health Informatics 1723 articles ](https://ojphi.jmir.org)
    * [JMIR Public Health and Surveillance 1713 articles ](https://publichealth.jmir.org)
    * [JMIR Medical Informatics 1474 articles ](https://medinform.jmir.org)
    * [JMIR Mental Health 1119 articles ](https://mental.jmir.org)
    * [JMIR Human Factors 881 articles ](https://humanfactors.jmir.org)
    * [JMIR Serious Games 673 articles ](https://games.jmir.org)
    * [JMIR Medical Education 597 articles ](https://mededu.jmir.org)
    * [Iproceedings 510 articles ](https://www.iproc.org)
    * [JMIR Aging 477 articles ](https://aging.jmir.org)
    * [JMIRx Med 468 articles ](https://xmed.jmir.org)
    * [Interactive Journal of Medical Research 467 articles ](https://www.i-jmr.org)
    * [JMIR Pediatrics and Parenting 443 articles ](https://pediatrics.jmir.org)
    * [JMIR Cancer 434 articles ](https://cancer.jmir.org)
    * [JMIR Dermatology 319 articles ](https://derma.jmir.org)
    * [JMIR Diabetes 278 articles ](https://diabetes.jmir.org)
    * [JMIR Rehabilitation and Assistive Technologies 275 articles ](https://rehab.jmir.org)
    * [JMIR Cardio 213 articles ](https://cardio.jmir.org)
    * [JMIR Infodemiology 169 articles ](https://infodemiology.jmir.org)
    * [JMIR AI 135 articles ](https://ai.jmir.org)
    * [JMIR Perioperative Medicine 124 articles ](https://periop.jmir.org)
    * [JMIR Nursing 120 articles ](https://nursing.jmir.org)
    * [Journal of Participatory Medicine 107 articles ](https://jopm.jmir.org)
    * [JMIR Biomedical Engineering 96 articles ](https://biomedeng.jmir.org)
    * [JMIR Bioinformatics and Biotechnology 54 articles ](https://bioinform.jmir.org)
    * [Asian/Pacific Island Nursing Journal 31 articles ](https://apinj.jmir.org)
    * [JMIR Neurotechnology 27 articles ](https://neuro.jmir.org)
    * [Medicine 2.0 26 articles ](https://www.medicine20.com)
    * [JMIRx Bio 26 articles ](https://xbio.jmir.org)
    * [JMIR XR and Spatial Computing (JMXR) 25 articles ](https://xr.jmir.org)
    * [JMIR Data ](https://data.jmir.org)
    * [JMIR Challenges ](https://challenges.jmir.org)
    * [JMIR Preprints ](https://preprints.jmir.org)



##  This paper is in the following e-collection/theme issue:

[ Digital Health Reviews (1438) ](/themes/18)[ Artificial Intelligence (1602) ](/themes/797)[ Generative Language Models Including ChatGPT (413) ](/themes/1437)[ AI Language Models in Health Care (85) ](/themes/1552)[ Natural Language Processing (764) ](/themes/171)[ Artificial Intelligence, Machine Learning, and Natural Language Processing for Public Health (41) ](/themes/1418)[ Theme Issue: ChatGPT and Generative Language Models in Medical Education (92) ](/themes/1302)

Published on 10.09.2024  in [ Vol 26 (2024)](/2024/1)

Preprints (earlier versions) of this paper are available at <https://preprints.jmir.org/preprint/60501>, first published May 14, 2024. 

![Prompt Engineering Paradigms for Medical Applications: Scoping Review](https://asset.jmir.pub/placeholder.svg)

# Prompt Engineering Paradigms for Medical Applications: Scoping Review

##  Prompt Engineering Paradigms for Medical Applications: Scoping Review 

Authors of this article: 

[ Jamil Zaghir1, 2 ](/search?term=Jamil%20Zaghir&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0002-8209-6098) ; [ Marco Naguib3 ](/search?term=Marco%20Naguib&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0009-0003-2950-8852) ; [ Mina Bjelogrlic1, 2 ](/search?term=Mina%20Bjelogrlic&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0002-6922-3283) ; [ Aurélie Névéol3 ](/search?term=Aur%C3%A9lie%20N%C3%A9v%C3%A9ol&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0002-1846-9144) ; [ Xavier Tannier4 ](/search?term=Xavier%20Tannier&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0002-2452-8868) ; [ Christian Lovis1, 2 ](/search?term=Christian%20Lovis&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0002-2681-8076)

[ Article ](/2024/1/e60501/)[ Authors ](/2024/1/e60501/authors)[ Cited by (7) ](/2024/1/e60501/citations)[ Tweetations (1) ](/2024/1/e60501/tweetations)[ Metrics ](/2024/1/e60501/metrics)[ Author Video ](/2024/1/e60501/author-video)




#### Review

  * [Jamil Zaghir1,2*, MSc](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Jamil+Zaghir)[ ](https://orcid.org/0000-0002-8209-6098 "ORCID");
  * [Marco Naguib3*, MSc](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Marco+Naguib)[ ](https://orcid.org/0009-0003-2950-8852 "ORCID");
  * [Mina Bjelogrlic1,2, PhD](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Mina+Bjelogrlic)[ ](https://orcid.org/0000-0002-6922-3283 "ORCID");
  * [Aurelie Neveol3, PhD](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Aurélie+Névéol)[ ](https://orcid.org/0000-0002-1846-9144 "ORCID");
  * [Xavier Tannier4, PhD](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Xavier+Tannier)[ ](https://orcid.org/0000-0002-2452-8868 "ORCID");
  * [Christian Lovis1,2, MPH, MD](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Christian+Lovis)[ ](https://orcid.org/0000-0002-2681-8076 "ORCID")



1Division of Medical Information Sciences, Geneva University Hospitals, Geneva, Switzerland

2Department of Radiology and Medical Informatics, University of Geneva, Geneva, Switzerland

3Universite Paris-Saclay, CNRS, Laboratoire Interdisciplinaire des Sciences du Numerique, Orsay, France

4Sorbonne Universite, INSERM, Universite Sorbonne Paris-Nord, Laboratoire d'Informatique Medicale et d'Ingenierie des Connaissances en eSante, LIMICS, Paris, France

*these authors contributed equally

### Corresponding Author:

Jamil Zaghir, MSc

Department of Radiology and Medical Informatics

University of Geneva

Chemin des Mines, 9

Geneva, 1202

Switzerland

Phone: 41 022 379 08 18

Email: [Jamil.Zaghir@unige.ch](mailto:Jamil.Zaghir@unige.ch)

  


### Abstract

Background: Prompt engineering, focusing on crafting effective prompts to large language models (LLMs), has garnered attention for its capabilities at harnessing the potential of LLMs. This is even more crucial in the medical domain due to its specialized terminology and language technicity. Clinical natural language processing applications must navigate complex language and ensure privacy compliance. Prompt engineering offers a novel approach by designing tailored prompts to guide models in exploiting clinically relevant information from complex medical texts. Despite its promise, the efficacy of prompt engineering in the medical domain remains to be fully explored.  


Objective: The aim of the study is to review research efforts and technical approaches in prompt engineering for medical applications as well as provide an overview of opportunities and challenges for clinical practice.  


Methods: Databases indexing the fields of medicine, computer science, and medical informatics were queried in order to identify relevant published papers. Since prompt engineering is an emerging field, preprint databases were also considered. Multiple data were extracted, such as the prompt paradigm, the involved LLMs, the languages of the study, the domain of the topic, the baselines, and several learning, design, and architecture strategies specific to prompt engineering. We include studies that apply prompt engineering-based methods to the medical domain, published between 2022 and 2024, and covering multiple prompt paradigms such as prompt learning (PL), prompt tuning (PT), and prompt design (PD).  


Results: We included 114 recent prompt engineering studies. Among the 3 prompt paradigms, we have observed that PD is the most prevalent (78 papers). In 12 papers, PD, PL, and PT terms were used interchangeably. While ChatGPT is the most commonly used LLM, we have identified 7 studies using this LLM on a sensitive clinical data set. Chain-of-thought, present in 17 studies, emerges as the most frequent PD technique. While PL and PT papers typically provide a baseline for evaluating prompt-based approaches, 61% (48/78) of the PD studies do not report any nonprompt-related baseline. Finally, we individually examine each of the key prompt engineering-specific information reported across papers and find that many studies neglect to explicitly mention them, posing a challenge for advancing prompt engineering research.  


Conclusions: In addition to reporting on trends and the scientific landscape of prompt engineering, we provide reporting guidelines for future studies to help advance research in the medical field. We also disclose tables and figures summarizing medical prompt engineering papers available and hope that future contributions will leverage these existing works to better advance the field.  


**J Med Internet Res 2024;26:e60501**  
  
[doi:10.2196/60501](https://doi.org/10.2196/60501)  
  


### Keywords

[prompt engineering](/search?type=keyword&term=prompt engineering&precise=true); [prompt design](/search?type=keyword&term=prompt design&precise=true); [prompt learning](/search?type=keyword&term=prompt learning&precise=true); [prompt tuning](/search?type=keyword&term=prompt tuning&precise=true); [large language models](/search?type=keyword&term=large language models&precise=true); [LLMs](/search?type=keyword&term=LLMs&precise=true); [scoping review](/search?type=keyword&term=scoping review&precise=true); [clinical natural language processing](/search?type=keyword&term=clinical natural language processing&precise=true); [natural language processing](/search?type=keyword&term=natural language processing&precise=true); [NLP](/search?type=keyword&term=NLP&precise=true); [medical texts](/search?type=keyword&term=medical texts&precise=true); [medical application](/search?type=keyword&term=medical application&precise=true); [medical applications](/search?type=keyword&term=medical applications&precise=true); [clinical practice](/search?type=keyword&term=clinical practice&precise=true); [privacy](/search?type=keyword&term=privacy&precise=true); [medicine](/search?type=keyword&term=medicine&precise=true); [computer science](/search?type=keyword&term=computer science&precise=true); [medical informatics](/search?type=keyword&term=medical informatics&precise=true)

  
  


### Introduction

In recent years, the development of large language models (LLMs) such as GPT-3 has disrupted the field of natural language processing (NLP). LLMs have demonstrated capabilities in processing and generating human-like text, with applications ranging from text generation and translation to question answering and summarization [1]. However, harnessing the full potential of LLMs requires careful consideration of how input prompts are formulated and optimized [2].

Input prompts denote a set of instructions provided to the LLM to execute a task. Prompt engineering, a term coined to describe the strategic design and optimization of prompts for LLMs, has emerged as a crucial aspect of leveraging these models. By crafting prompts that effectively convey tasks or queries, researchers and practitioners can guide LLMs to improve the accuracy and pertinence of responses. The literature defines prompt engineering in various ways: it can be regarded as a prompt structuring process that enhances the efficiency of an LLM to achieve a specific objective [3] or as the mechanism through which LLMs are programmed by prompts [4]. Prompt engineering encompasses a plethora of techniques, often separated into distinct categories such as output customization and prompt improvement [4]. Existing prompt paradigms are presented in more detail in the Methods section.

In the realm of medical NLP, significant advancements have been made, such as the release of LLMs specialized in medical language and the availability of public medical data sets, including in languages other than English [5]. The unique intricacies of medical language, characterized by its terminological precision, context sensitivity, and domain-specific nuances, demand a dedicated focus and exploration of NLP in health care research. Despite these imperatives, to our knowledge, there is currently no systematic review analyzing prompt engineering applied to the medical domain.

The aim of this scoping review is to shed light on prompt engineering, as it is developed and used in the medical field, by systematically analyzing the literature in the field. Specifically, we examine the definitions, methodologies, techniques, and outcomes of prompt engineering across various NLP tasks. Methodological strengths, weaknesses, and limitations of the current wave of experimentation are discussed. Finally, we provide guidelines for comprehensive reporting of prompt engineering-related studies to improve clarity and facilitate further research in the field. We aspire to furnish insights that will inform both researchers and users about the pivotal role of prompt engineering in optimizing the efficacy of LLMs. By gaining a thorough understanding of the current landscape of prompt engineering research, we can pinpoint areas warranting further investigation and development, thereby propelling the field of medical NLP forward.

  


### Methods

#### Study Design

Our scoping review was conducted following the PRISMA-ScR (Preferred Reporting Items for Systematic Reviews and Meta-Analyses extension for Scoping Reviews) guidelines for scoping reviews (available in Multimedia Appendix 1). In this review, we use terminology to denote emerging technical concepts that lack consensus definitions. We propose the following definitions based on previous use in the literature:

  * LLM: Object that models language and can be used to generate text by receiving large-scale language modeling pretraining (Luccioni and Rogers [6] define an arbitrary threshold at 1 billion tokens of training data). An LLM can be adapted to downstream tasks through transfer learning approaches such as fine-tuning or prompt-based techniques. Following the study of Thirunavukarasu et al [7] of models for the medical field, we include Bidirectional Encoder Representations From Transformers (BERT)-based and GPT-based models in this definition, although Zhao et al [8] place BERT models in a separate category.
  * Fine-tuning: Approach in which the weights of the pretrained LLM are retrained on new samples. The additional data can be labeled and designed to adapt the LLM to a new downstream task.
  * Prompt design (PD) [1,2]: Manually building a prompt (named manual prompt or hard prompt), tailored to guide the LLM toward resolving the task by simply predicting the most probable continuity of the prompt. The prompt is usually a set of task-specific instructions, occasionally featuring a few demonstrations of the task.
  * Prompt learning (PL) [3]: Manually building a prompt and passing it to an LLM, trained via the masked language modeling (MLM) objective, to predict masked tokens. The prompt often features masked tokens, over which the LLM makes predictions. Those are then projected as predictions for a new downstream task. This approach is also referred to as prompt-based learning.
  * Prompt tuning (PT) [9]: Refers to the LLM prompting where part or all the prompt is a trainable vectorial representation (known as continuous prompt or soft prompt) that is optimized with respect to the annotated instances.



Figure 1 illustrates the 4 approaches described above.

[![](https://asset.jmir.pub/assets/3ee6de95b96edd2d25eb18ef10612b7d.png)](https://asset.jmir.pub/assets/3ee6de95b96edd2d25eb18ef10612b7d.png "Figure 1. Illustration of traditional fine-tuning and the 3 prompt-based paradigms \(the fire logo represents trainable parameters, and the flake logo illustrates frozen parameters\). LLM: large language model.")**Figure 1.** Illustration of traditional fine-tuning and the 3 prompt-based paradigms (the fire logo represents trainable parameters, and the flake logo illustrates frozen parameters). LLM: large language model. 

#### Inclusion and Exclusion Criteria

Studies were included if they met the following criteria: focus on prompt engineering, involvement of at least 1 LLM, relevance to the medical field (biomedical or clinical), pertaining to text-based generation (excluding vision-related prompts), and not focusing on prompting for academic writing purposes. Furthermore, as most of the first studies about prompt engineering emerged in 2022 [2], we added the following constraint: the publication date should be later than 2021.

#### Screening Process

The initial set of papers retrieved from the searches underwent screening based on titles, abstracts, and keywords. The search strategy is described in Multimedia Appendix 2. Screening was performed by 2 reviewers (JZ and MN), working in a double-blind process. Interannotator agreement was calculated, with conflicts resolved through discussion.

#### Data Synthesis

We extracted information on prompt paradigms (PD, PL, and PT), involved LLMs, data sets used, studied language, domain (biomedical or clinical), medical subfield (if any), mentioned prompt engineering techniques, computational complexity, baselines, relative performances, and key findings. Additionally, we extracted journal information and noted instances of PD or PL or PT terminology misuse. Details are available in Multimedia Appendix 3. Finally, we compile a list of recommendations based on the positive or negative trends we identify from the selected papers.

  


### Results

#### Screening Results

The systematic search across sources yielded 398 papers. Following the removal of duplicates, 251 papers underwent screening based on title, abstract, and keywords, leading to the exclusion of 94 studies. During this first screening step, 33 conflicts were identified and resolved among the annotators, resulting in an interannotator agreement of 86.8% (n=218). Subsequently, 157 studies remained, and full-text copies were retrieved and thoroughly screened. This process culminated in the inclusion of a total of 114 papers in this scoping review. The detailed process of study selection is shown in Figure 2. Among the selected papers, 13 are from clinical venues, 33 are from medical informatics sources, 31 are from computer science publications, and 4 are from other sources. Notably, 33 of them are preprints.

[![](https://asset.jmir.pub/assets/60784bc57812dc3ef1bb23d38e75c9d1.png)](https://asset.jmir.pub/assets/60784bc57812dc3ef1bb23d38e75c9d1.png "Figure 2. PRISMA \(Preferred Reporting Items for Systematic Reviews and Meta-Analyses\) flow diagram for the review process.")**Figure 2.** PRISMA (Preferred Reporting Items for Systematic Reviews and Meta-Analyses) flow diagram for the review process. 

#### Prompt Paradigms and Medical Subfields

Table 1 depicts the number of papers identified within each prompt paradigm along with their associated medical subfields. Some papers may simultaneously involve several (up to 2 in this review) prompt paradigms. Notably, PD emerged as the predominant category, with a total of 78 papers. These papers spanned across various medical fields, with a greater emphasis on clinical (including specialties) rather than biomedical disciplines. The screening yields 29 PL papers and 19 PT papers, with both paradigms maintaining a balanced distribution between biomedical and clinical domains. However, it is noteworthy that unlike PL and PT, PD encompassed a much broader spectrum of clinical specialties, with a particular interest in psychiatry.

**Table 1.** Paper distribution by prompt category and medical subfield, with corresponding references.Prompt paradigm and domain of the topic| References  
---|---  
**Prompt design (78)**  
  
|  Biomedical (17)| [10-26]  
  
| Medical licensing examination (12)| [27-38]  
  
| Clinical (general) (15)| [39-53]  
  
| Psychiatry (10)| [28,54-62]  
  
| Oncology (5)| [63-67]  
  
| Cardiology (4)| [68-71]  
  
| Ophthalmology (3)| [72-74]  
  
| Neurology (3)| [69,75,76]  
  
| Orthopedics (2)| [77,78]  
  
| Clinical trials (2)| [79,80]  
  
| Intensive care (2)| [69,81]  
  
| Geriatrics (2)| [75,76]  
  
| Radiology (2)| [31,82]  
  
| Nuclear medicine (1)| [29]  
  
| Hepatology (1)| [83]  
  
| Endocrinology (1)| [84]  
  
| Plastic surgery (1)| [85]  
  
| Gastroenterology (1)| [32]  
  
| Genetics (1)| [86]  
  
| Nursing (1)| [87]  
**Prompt learning (29)**  
  
|  Biomedical (13)| [88-100]  
  
| Clinical (general) (15)| [41,47,101-113]  
  
| Psychiatry (1)| [114]  
**Prompt tuning (19)**  
  
|  Biomedical (9)| [16,20,26,90,91,95,98,115,116]  
  
| Clinical (general) (6)| [101,105,110,117-119]  
  
| Oncology (2)| [120,121]  
  
| Psychiatry (1)| [122]  
  
| Medical insurance (1)| [123]  
  
#### Terminology Use

In our review, the consistency of terminology use around prompt engineering was investigated, particularly concerning its 3 paradigms: PD, PL, and PT. Across the papers, we meticulously tracked instances where the terminology was applied differently to the definitions used in the literature and described in the introduction. Notably, PL was used to refer to PD 4 times [12,13,67,86] and PT once [119], while PT was used 5 times to describe PL [88,96,97,99,114] and twice for PD [23,43]. Terminology inconsistencies were identified in only 12 studies. Consequently, while there remains some degree of inconsistency, a significant majority of 102 papers adhered to the definitions identified as commonly used terminology.

#### Language of Study

Considering the latest developments in NLP research encompassing languages beyond English [124], reporting the language of study is crucial. Several papers do not explicitly state the language of study. In some cases, the language can be inferred from prompt illustrations or examples. In the least informative cases, only the data set of the study is disclosed, indirectly hinting at the language.

Table 2 illustrates the language distribution among the selected papers, noting whether languages are explicitly mentioned, implicitly inferred from prompt illustrations, or simply not stated but implied from the used data set. The language used in 2 papers [60,68] remains unknown.

**Table 2.** Frequency distribution of papers across various languages. The table also depicts the frequency distribution across venues for papers studying English (N=114).Language and type of venue| Stateda, n (%)| Inferredb, n (%)| Not statedc, n (%)| Total, n (%)  
---|---|---|---|---  
**English**  
  
|  All| 37 (32.5)| 48 (42.1)| 11 (9.6)| 96 (84.2)  
  
| Medical informatics| 16 (14)| 9 (7.9)| 2 (1.8)| 27 (23.7)  
  
| Computer science| 8 (7)| 18 (15.8)| 1 (0.9)| 27 (23.7)  
  
| Preprint| 9 (7.9)| 12 (10.5)| 5 (4.4)| 26 (22.8)  
  
| Clinical| 1 (0.9)| 8 (7)| 3 (2.6)| 12 (10.5)  
  
| Other| 3 (2.6)| 1 (0.9)| 0 (0)| 4 (3.5)  
**Chinese**  
  
|  All| 18 (15.8)| 0 (0)| 0 (0)| 18 (15.8)  
**French**  
  
|  All| 3 (2.6)| 0 (0)| 0 (0)| 3 (2.6)  
**Dutch**  
  
|  All| 3 (2.6)| 0 (0)| 0 (0)| 3 (2.6)  
**Japanese**  
  
|  All| 2 (1.8)| 0 (0)| 0 (0)| 2 (1.8)  
**Portuguese**  
  
|  All| 2 (1.8)| 0 (0)| 0 (0)| 2 (1.8)  
**Italian**  
  
|  All| 2 (1.8)| 0 (0)| 0 (0)| 2 (1.8)  
**Spanish**  
  
|  All| 2 (1.8)| 0 (0)| 0 (0)| 2 (1.8)  
**Korean**  
  
|  All| 0 (0)| 0 (0)| 1 (0.9)| 1 (0.9)  
**Basque**  
  
|  All| 1 (0.9)| 0 (0)| 0 (0)| 1 (0.9)  
**German**  
  
|  All| 1 (0.9)| 0 (0)| 0 (0)| 1 (0.9)  
**Swedish**  
  
|  All| 1 (0.9)| 0 (0)| 0 (0)| 1 (0.9)  
**Polish**  
  
|  All| 1 (0.9)| 0 (0)| 0 (0)| 1 (0.9)  
**Vietnamese**  
  
|  All| 1 (0.9)| 0 (0)| 0 (0)| 1 (0.9)  
**Unknown**  
  
|  All| 0 (0)| 0 (0)| 2 (1.8)| 2 (1.8)  
  
aStated in the paper.

bInferred from prompt figures and examples.

cInferred from the data set.

Notably, English dominates with 84.2% (n=96) of the selected papers, followed by Chinese at 15.7% (n=18). Then, the other languages are relatively rare, often appearing in studies featuring multiple languages. It is worth mentioning that languages besides English are usually explicitly stated, with the exception of a paper studying Korean [63]. In total, the language had to be inferred from prompt figures and examples in 48 papers, all in English.

#### Choice of LLMs

Given the diverse array of LLMs available, spanning general or medical, open-source or proprietary, and monolingual or multilingual models, alongside various architectural configurations (encoder, decoder, or both), our study investigates LLM selection across prompt paradigms.

Figure 3 outlines prevalent LLMs categorized by prompt paradigms, though it is not exhaustive and only includes commonly encountered architectures. For example, while encoder-decoder models are absent in PT in Figure 3, there are a few instances where they are used [95,110].

ChatGPT's popularity in PD is unsurprising, given its accessibility. Models from Google, PaLM, and Bard (subsequently rebranded Gemini), all falling under closed models, are also prominent. Among open-source instruct-based LLMs, fewer are used, notably those based on LLaMA-2 with 7 occurrences.

In PL, encoder models, those following the BERT architecture, dominate, covering both general and specialized variants. There are occasional uses of decoder models like GPT-2 in PL-based tasks [103,105]. PT involves all model types, with a preference toward encoders. Further details on the models used are available in Multimedia Appendix 3.

[![](https://asset.jmir.pub/assets/521feddb5eee02c7e6a41310ef0c044d.png)](https://asset.jmir.pub/assets/521feddb5eee02c7e6a41310ef0c044d.png "Figure 3. Involved large language models in the prompt engineering studies, covering all prompt paradigms. The number of studies that fit in a node is shown in parentheses. BERT: Bidirectional Encoder Representations From Transformers; RoBERTa: Robustly Optimized BERT Pre-training Approach; T5: Text-to-Text Transfer Transformer.")**Figure 3.** Involved large language models in the prompt engineering studies, covering all prompt paradigms. The number of studies that fit in a node is shown in parentheses. BERT: Bidirectional Encoder Representations From Transformers; RoBERTa: Robustly Optimized BERT Pre-training Approach; T5: Text-to-Text Transfer Transformer. 

#### Topic Domain and NLP Task Trends

Figure 4 [16,20,26,41,47,88-123] illustrates the target tasks used in the PL and PT papers. PL-focused papers predominantly address classification-based tasks such as text classification, named entity recognition, and relation extraction, with text classification being particularly prominent. This aligns with the nature of PL, which centers around an MLM objective. Among other tasks, a study based on text generation [111] makes use of PL to predict masked tokens from partial patient records, aiming to generate synthetic electronic health records. Conversely, PT papers tend to exhibit a slightly broader range of tasks.

Figure 5 [10-87] presents the same analysis for PD-based papers. Unlike PL and PT, a prominent trend observed is that several studies focus on real-world board examinations. Notably, these studies predominantly center around tasks involving answering multiple-choice questions (MCQs). It is worth noting that although MCQs might be cast as a classification task, in practice, it is cast as a generation task using causal LLMs. It is interesting to note that none of the selected PD papers propose the task of entity linking, despite the clear opportunity of leveraging LLMs' in-context learning ability for medical entity linking.

[![](https://asset.jmir.pub/assets/4d26f0c1156239baef60c53d5fb0208f.png)](https://asset.jmir.pub/assets/4d26f0c1156239baef60c53d5fb0208f.png "Figure 4. Overview of selected prompt learning and prompt tuning papers, showcasing natural language processing tasks alongside their topic domain \(it includes tasks, such as text simplification, where none of the selected papers specifically focused on these tasks\). Numbers within square brackets are reference citations.")**Figure 4.** Overview of selected prompt learning and prompt tuning papers, showcasing natural language processing tasks alongside their topic domain (it includes tasks, such as text simplification, where none of the selected papers specifically focused on these tasks). Numbers within square brackets are reference citations. [![](https://asset.jmir.pub/assets/1d719517b4aafb49f9bf2e793652427b.png)](https://asset.jmir.pub/assets/1d719517b4aafb49f9bf2e793652427b.png "Figure 5. Overview of selected prompt design papers, showcasing natural language processing tasks alongside their topic domain. Numbers within square brackets are reference citations.")**Figure 5.** Overview of selected prompt design papers, showcasing natural language processing tasks alongside their topic domain. Numbers within square brackets are reference citations. 

#### Prompt Engineering Techniques

We extensively investigated the used prompt techniques: among PD papers, 49 studies used zero-shot prompting, 23 used few-shot prompting, and 10 used one-shot prompting. Few shot tends to outperform in MCQs, but its advantage over zero shot is inconsistent in other NLP tasks. We propose a comprehensive summary of the existing techniques in Table 3.

As shown in Table 3, chain-of-thought (CoT) prompting [2] stands as the most common technique, followed by the persona pattern. In medical MCQs, various attempts with CoT can lead to different reasoning pathways and answers. Hence, to improve accuracy, 2 studies [19,20] used self-consistency, a method involving using multiple CoT prompts and selecting the most frequently occurring answer through voting.

Flipped interaction was used for simulation tasks, such as doctor-patient engagement [60] or to provide clinical training to medical students [81]. Emotion enhancement was applied in mental health contexts [58,60], allowing the LLM to produce emotional statements.

More innovative prompt engineering techniques include k-nearest neighbor few-shot prompting [19] and pseudoclassification prompting [78]. The former uses the k-nearest neighbor algorithm to select the k-closest examples in a large annotated data set based on the input before using them in the prompt, and the latter presents to the LLMs all possible labels, asking the model to respond with a binary output for each provided label. Despite its potential, tree-of-thoughts pattern use was limited, with only 1 instance found among the papers [77].

**Table 3.** Most recurrent prompt techniques found, with the corresponding description, template, and references.Prompt techniques| Description| Prompt template examples| Count papers| References  
---|---|---|---|---  
Chain-of-thought (CoT)| Asking the large language model (LLM) to provide the reasoning before answering.| 

  * Basic CoT: "<Prompt>. Think step by step."  

  * Another example of CoT: "Solve this math problem. E.g.: You have 3 apples and buy 2 more, how many apples do you have? Solution: Start with 3 apples. Buy 2 more apples. Total apples is 3 + 2 = 5. New problem: You have 5 oranges and give away 2, how many oranges do you have left?"  


| 17| [11,19,20,27,29,32,33,35,39, 51,58,67,75,77,82,83,85]  
Persona (role-defining)| Assigning the LLM a particular role to accomplish a task related to that role.| 

  * "Act as X (e.g. Act as a Physician, Act as a Psychiatrist, etc)."  


| 10| [32,49,55,56,59-61,82,84,85]  
Ensemble prompting| Using multiple independent prompts to answer the same question. The final output is decided by majority vote.| 

  * "Prompt1, Output1, Prompt2, Output2, […], Promptk, Outputk" Final output: Vote  


| 4| [19,20,39,52]  
Scene-defining| Simulating a scene related to the addressed task.| 

  * "you are in a hospital, in front of a patient ..."  


| 3| [18,49,61]  
Prompt-chaining| Separating a task into multiple subtasks, each resolved with a prompt.| 

  * "Prompt1->Output1, Output1+Prompt2 ->Output2, [...] Outputk-1+Promptk-> Outputk"  


| 3| [37,80,84]  
Flipped interaction| Making the LLM take the lead (eg, asking questions) and the user interacting with it passively.| 

  * "I would like you to ask me questions to achieve X. You should ask questions until <condition/goal> is met."  


| 2| [60,81]  
Emotion enhancement| Making the LLM more or less expressing human-like emotions.| 

  * "You can have emotional fluctuations during the conversation."  


| 2| [58,60]  
Prompt refinement| Using the LLM to refine the prompt such as translating the prompt or rephrasing it.| 

  * "Please translate in English / rephrase this prompt: <P>."  


| 2| [37,48]  
Retrieval-augmented generation| Combining an information retrieval component with a generative LLM. Snippets extracted from documents are fed into the system along with the input prompt to generate an enriched output.| 

  * "<List of relevant Snippets> <Input Prompt>"  


| 2| [18,54]  
Self-consistency (CoT ensembling)| Ensemble prompting each prompt using CoT. Ideal if a problem has many possible reasoning paths.| 

  * "CoT_Pr1, Output1, CoT_Pr2, Output2, ..., CoT_Prk, Outputk" Final output: Vote  


| 2| [19,20]  
  
#### Emerging Trends

Figure 6 illustrates a chronological polar pie chart of selected papers and their citation connections, identifying five highly cited papers: (1) Agrawal et al [40] demonstrate GPT-3's clinical task performance, especially in named entity recognition and relation extraction through thorough PD. (2) Kung et al [36] evaluate ChatGPT's (GPT-3.5) ability for the United States Medical Licensing Examination, shortly after the public release of ChatGPT. (3) Singhal et al [20] introduce MultiMedQA and HealthSearchQA benchmarks. The paper also presents instruction PT for domain alignment, a novel paradigm that entails learning a soft prompt prior to the LLM general instruction, which is usually written as a hard prompt. Using this approach on FlanPaLM led to the development of Med-PaLM, improving question answering over FlanPaLM. (4) Nori et al [27] evaluate GPT-4 on the United States Medical Licensing Examination and MultiMedQA, surpassing previous state-of-the-art results, including GPT-3.5 and Med-PaLM. (5) Luo et al [26] release BioGPT, a fine-tuned variant of GPT-2 for biomedical tasks, achieving state-of-the-art results on 6 biomedical NLP tasks with suffix-based PT.

[![](https://asset.jmir.pub/assets/51244d80b621413e04ba36377b0a52f2.png)](https://asset.jmir.pub/assets/51244d80b621413e04ba36377b0a52f2.png "Figure 6. A chronological chart showing the selected papers across the 3 prompt-based paradigms. Papers are classified by different colors according to the venues in which they were published. Different shapes illustrate whether the LLM is fine-tuned, frozen, or both. Solid or striped color indicates whether authors used a nonprompt baseline \(including humans\) for evaluation. Arrows connecting 2 papers denote direct citations. The nodes in the border of PD, PL, or PT are studies proposing the 2 involved prompt engineering paradigms. Numbers within square brackets are reference citations. LLM: large language model; PD: prompt design; PL: prompt learning; PT: prompt tuning.")**Figure 6.** A chronological chart showing the selected papers across the 3 prompt-based paradigms. Papers are classified by different colors according to the venues in which they were published. Different shapes illustrate whether the LLM is fine-tuned, frozen, or both. Solid or striped color indicates whether authors used a nonprompt baseline (including humans) for evaluation. Arrows connecting 2 papers denote direct citations. The nodes in the border of PD, PL, or PT are studies proposing the 2 involved prompt engineering paradigms. Numbers within square brackets are reference citations. LLM: large language model; PD: prompt design; PL: prompt learning; PT: prompt tuning. 

#### Trends in PD

As shown in Figure 6, the PD paradigm presents multiple trends: all papers disseminated in clinical-based venues, and 27 of 33 (82%) of the encountered preprints adhere to this paradigm. Furthermore, we observed a significant focus on work involving frozen LLMs within the PD domain. This trend is likely due to the frequent use of ChatGPT in 74 instances, as depicted in Figure 3, despite OpenAI offering fine-tuning capabilities for the model. It is worth mentioning that 46 of 78 (59%) PD papers do not include any baseline, including human comparison. This gap will be further explored in a subsequent section.

#### Trends in PL and PT

Among PL and PT papers, computer science and medical informatics are the most prevalent venues. Although PL has drawn attention to the idea of adapting the MLM objective to downstream tasks without needing to further update the LLM weights, many studies still opt to fine-tune their LLMs, with a nonnegligible amount of them evaluating in few-shot settings [89,92,93,112]. Unlike PD, PL and PT usually include a baseline, with it often being a traditional fine-tuning version of the evaluated model [92,93,95] to compare it against novel prompt-based paradigms. These studies came to a common conclusion, being that PL is a promising alternative to traditional fine-tuning in few-shot scenarios.

There are 2 ways for conducting PL: one involves filling in the blanks within a text, known as cloze prompts, while the other consists in predicting masked tokens at the end of the sequence, referred to as prefix prompts. A distinct advantage of the latter approach is its compatibility with autoregressive models, as they exclusively predict the appended masks. Among the 29 PL papers, 21 (72%) of them propose cloze prompts, while 15 (52%) use prefix prompting. The involved NLP tasks are well-distributed across these 2 prompt patterns. Another crucial component of PL is the verbalizer. As PL revolves around predicting masked tokens, classification-based tasks require mapping manually selected relevant tokens to each class (manual verbalizer). Alternatively, some studies propose a soft verbalizer, akin to soft prompts, which automatically determines the most relevant token embedding for each label through training. Of the 29 PL papers selected, 16 (55%) studies explicitly mention the use of a manual verbalizer, while 2 explored both verbalizers to assess performance [101,110]. Only 1 exclusively used a soft verbalizer [89]. Another study does not use any verbalizer, as it focuses on generating synthetic data by filling the blanks [111]. Notably, 8 (28%) studies did not report any mention regarding the verbalizer methodology.

Hard prompts, which are related to PD and PL, involve manually crafted prompts. Regarding PT, optimal prompts are attainable through soft prompting (ie, prompts that are trained on a training data set), yet, determining the appropriate soft prompt length remains obscure. In total, 5 of 19 (26%) PT studies tried various soft prompt lengths and reported their corresponding performances [26,105,118,119,122]. While there is no definitive optimal prompt length, a trend emerges: optimal soft prompt length typically exceeds 10 tokens. Surprisingly, 8 (42%) papers omit reporting the soft prompt length. Regarding the placement of soft prompts in relation to the input and the mask, consensus is lacking. A total of 5 (26%) papers prepend the soft prompt at the input's outset, while 4 (21%) append it as a suffix. One paper uses both strategies in a single prompt template [95]. Some innovative methods involve inserting a single soft prompt for each entity that needs to be identified in entity-linking tasks or using token-wise soft prompts, where each token in the textual input is accompanied by a distinct soft prompt. The position of soft prompts remains unreported in 5 (26%) studies. Finally, according to the 6 (32%) studies that used mixed prompts [90,91,95,101,105,110] (a combination of hard and soft prompts), it has consistently been reported that mixed prompts lead to a better performance than hard prompts alone.

#### Baseline Comparison

Only 62 of the screened papers reported comparisons to established baselines. These include traditional deep learning approaches (eg, fine-tuning approach), classical machine learning algorithms (eg, logistic regression), naive systems (eg, majority class), or human annotation. The remaining papers solely explored prompt-related solutions, without including baseline comparisons. Tables 4-6 traces the presence of a nonprompt baseline among different prompt categories (Table 4), papers sources (Table 5), and NLP tasks addressed (Table 6).

**Table 4.** Baseline reports among prompt categories (N=114)a.Prompt category| No baseline, n (%)| Higher, n (%)| Similar, n (%)| Lower, n (%)| Total, n (%)  
---|---|---|---|---|---  
Prompt design| 48 (42.1)| 13 (11.4)| 4 (3.5)| 13 (11.4)| 78 (68.4)  
Prompt learning| 5 (4.4)| 19 (16.7)| 3 (2.6)| 2 (1.8)| 29 (25.4)  
Prompt tuning| 3 (2.6)| 11 (9.6)| 2 (1.8)| 3 (2.6)| 19 (16.7)  
  
aHigher or lower indicates that the performance of the proposed prompt-based approach is higher or lower than the baseline.

**Table 5.** Baseline reports among venues (N=114)a.Type of venue| No baseline, n (%)| Higher, n (%)| Similar, n (%)| Lower, n (%)| Total, n (%)  
---|---|---|---|---|---  
Medical informatics| 13 (11.4)| 16 (14)| 2 (1.8)| 2 (1.8)| 33 (28.9)  
Computer science| 7 (6.1)| 12 (10.5)| 3 (2.6)| 9 (7.9)| 31 (27.2)  
Preprint| 21 (18.4)| 6 (5.3)| 1 (0.9)| 5 (4.4)| 33 (28.9)  
Clinical| 13 (11.4)| 0 (0)| 0 (0)| 0 (0)| 13 (11.4)  
Other| 1 (0.9)| 2 (1.8)| 0 (0)| 1 (0.9)| 4 (3.5)  
  
aHigher or lower indicates that the performance of the proposed prompt-based approach is higher or lower than the baseline.

**Table 6.** Baseline reports among addressed NLPa tasks (N=114)b.NLP task| No baseline, n (%)| Higher, n (%)| Similar, n (%)| Lower, n (%)| Total, n (%)  
---|---|---|---|---|---  
Text classification| 13 (11.4)| 18 (15.8)| 4 (3.5)| 11 (9.6)| 46 (40.4)  
Question answering| 13 (11.4)| 3 (2.6)| 1 (0.9)| 2 (1.8)| 19 (16.7)  
Relation extraction| 3 (2.6)| 10 (8.8)| 0 (0)| 3 (2.6)| 16 (14)  
Information extraction| 10 (8.8)| 3 (2.6)| 0 (0)| 2 (1.8)| 15 (13.2)  
Multiple-choice question| 10 (8.8)| 3 (2.6)| 1 (0.9)| 1 (0.9)| 15 (13.2)  
Named entity recognition| 4 (3.5)| 5 (4.4)| 1 (0.9)| 5 (4.4)| 15 (13.2)  
Text summarization| 7 (6.1)| 3 (2.6)| 0 (0)| 1 (0.9)| 11 (9.6)  
Reasoning| 5 (4.4)| 3 (2.6)| 0 (0)| 1 (0.9)| 9 (7.9)  
Generation| 5 (4.4)| 2 (1.8)| 0 (0)| 1 (0.9)| 8 (7)  
Entity linking| 0 (0)| 3 (2.6)| 0 (0)| 0 (0)| 3 (2.6)  
Coreference resolution| 1 (0.9)| 1 (0.9)| 0 (0)| 1 (0.9)| 3 (2.6)  
Decision support| 2 (1.8)| 0 (0)| 0 (0)| 1 (0.9)| 3 (2.6)  
Conversational| 3 (2.6)| 0 (0)| 0 (0)| 0 (0)| 3 (2.6)  
Text simplification| 1 (0.9)| 0 (0)| 0 (0)| 1 (0.9)| 2 (1.8)  
  
aNLP: natural language processing.

bHigher or lower indicates that the performance of the proposed prompt-based approach is higher or lower than the baseline.

Nonprompt-related baselines are often featured in studies focused on PL and PT but not PD. Additionally, PL and PT have a tendency to perform better than their respective reported baselines, PD tends to report less conclusive results. More specifically, among the 22 papers using either PL or PT with an identical fine-tuned model as a baseline, 17 indicate superior performance with the prompt-based approach, 3 observed comparable performance, and 2 studies noted inferior performance.

Significantly, papers from computer science venues tend to include more state-of-the-art baselines than those from medical informatics and clinical venues. Specifically, all 13 papers reviewed from clinical venues did not use any nonprompt baselines. Furthermore, there appears to be no consistent link between the type of NLP tasks and the omission of baselines, indicating that the decision to include baselines is more influenced by the evaluation methodology than by feasibility.

#### Prompt Optimization

Numerous studies in the literature highlight the few-shot learning capabilities of LLMs, often referred to as "few-shot prompting," wherein they demonstrate proficiency in executing tasks with minimal demonstrations provided, typically through text prompts. However, it is crucial to acknowledge that the annotation cost associated with such frameworks might extend beyond the few annotated demonstrations within the prompt. Many studies claiming to explore few-shot or zero-shot learning through prompt engineering rely on extensive annotated validation data sets to refine PD and formulation. This is, for example, the case in the paper that popularized the term "few-shot learning" [1]. Among the 45 analyzed papers concentrating on few-shot or zero-shot learning, 5 explicitly detail the optimization of prompt formulation using extensive validation data sets. Conversely, 18 of these papers either do not engage in prompt optimization or test various prompts and document all results. Notably, 22 papers present results using only 1 prompt choice, without clarifying whether this choice was made thanks to additional validation data sets.

  


### Discussion

#### Summary of the Findings

This scoping review aimed to map the current landscape of medical prompt engineering, identifying key themes, gaps, and trends within the existing literature. The primary findings of this study reveal a greater prevalence of PD over PL and PT, with ChatGPT dominating the PD domain. Additionally, many studies omit nonprompt-based baselines, do not specify the language of study, or exhibit a lack of consensus in PL (prefix vs cloze prompt) and PT settings (soft prompt lengths and positions). English is notably dominant as the language of study. These findings suggest that while the field is emerging, there is a pressing need for improved research practices.

#### Costs, Infrastructure, and LLMs in Clinical Settings

Prompt engineering techniques enable competitive performance in scenarios with limited or no resources as well as in environments with low-cost computing infrastructure. As hospital data and infrastructure are often found in this scenario, these approaches hold great promise in the clinical field. Figure 6 shows the absence of PL- and PT-related works in clinical journals. This trend may stem from the widespread accessibility of ChatGPT, favoring PD-focused investigations. Despite efforts like OpenPrompt [125] to facilitate PL and PT works, the programming barrier likely deters clinical practitioners. Surprisingly, 7 papers use ChatGPT with sensitive clinical data. Despite the recent availability of ChatGPT Enterprise in GPT-4 for secure data handling, it is apparent that most of these studies have not used this feature since they used GPT-3.5. Limited use of local LLMs, especially LLaMA-based, suggests a need for their increased adoption in future clinical PD studies. The lack of local LLMs may be due to clinicians' limited computational infrastructure.

#### Prompt Engineering Techniques Effectiveness in Medical Research

In documented prompt engineering techniques, the effectiveness of few-shot prompting compared to zero shot varies by task and scenario. However, CoT shows superior reasoning performance, compelling LLMs to present reasoning pathways and consistently outperforming zero-shot and few-shot methods across PD studies. Its ensemble-based variant, self-consistency, consistently outperforms CoT. Despite the persona pattern's frequent use, there is a lack of ablation studies on its impact on medical task performance, with only 1 paper reporting negligible improvement [61]. Prompt engineering is an emerging field of study that still needs to prove its efficacy. However, almost half of the papers focused only on prompt engineering and failed to report any nonprompt-related baseline performance, despite the availability of such baselines for the addressed NLP tasks. On the whole, the results are far from being systematically in favor of LLM-based methods, greatly attenuating the impression of a technological breakthrough that is generally commented on. Selecting a baseline remains a necessary step toward understanding the actual impact of prompt engineering.

#### Bender Rule

Regarding the languages, while Table 2 shows the dominance of English in medical literature, many papers studying English fail to explicitly mention the language of study. This oversight is more prevalent in computer science and clinical venues, whereas medical informatics exhibits a more favorable trend, as validated by a chi-square test yielding a _P_ value of .02 (Table S1 in Multimedia Appendix 2). Notably, languages such as Chinese are consistently mentioned across the 18 selected papers. However, the Bender rule, namely "always name the language(s) you are working on," seems to be well respected for languages other than English. This finding has already been documented for NLP research in general [126].

#### Fine-Tuning Versus Prompt-Based Approaches

While traditional LLM fine-tuning remains a viable method for various NLP tasks, PL and PT are competitive alternatives to fine-tuning, particularly in resource-constrained and low computational scenarios. PL, leveraging predefined prompts to guide model behavior, offers an efficient approach in low-to-no resource environments. Conversely, PT emerges as a viable solution in low computational scenarios, as it requires substantially fewer trainable parameters compared to traditional fine-tuning approaches. Since both prompt-based approaches do not require the LLM to be further trained, they are less prone to catastrophic forgetting [127].

#### Recommendations for Future Medical Prompt-Based Studies

For future research in prompt engineering, we propose several recommendations aimed at improving research quality, reporting, and reproducibility. From this review, we identified several trends such as the computational advantages or the lack of evaluations on baselines with a lack of ablation studies to evaluate the performance of the prompting strategies. Some studies do not clearly mention the prompt engineering choices they made. For instance, in PL, choices range from using cloze to prefix prompting and from using manual to soft verbalizer. Similarly, PT is characterized by configurations of soft prompts, such as the length and the positions. To clarify these distinctions and enhance methodological transparency and reproducibility in future research, we have developed reporting guidelines available in Textbox 1. Adhering to these reporting guidelines will contribute to advancing prompt engineering methodologies and their practical applications in the medical field.

**Textbox 1.** Detailed reporting guidelines for future prompt engineering studies.

**General reporting recommendations**

  * For sensitive data, local large language models (LLMs) should be preferred to the ones that use an application programming interface or a web service.
  * The language of the study used should be explicitly stated.
  * The mention of whether the LLM undergoes fine-tuning should be made explicit.
  * The prompt optimization process and results should be documented to ensure transparency, whether it is through different tested manual prompts or through a validation data set.
  * The terms "few-shot," "one-shot," and "zero-shot" should not be used in settings where the prompts have been optimized on annotated examples.
  * Experiments should include baseline comparisons or at least mention existing results, particularly when data sets originate from previous medical challenges or benchmarks.



**Specific to prompt learning and prompt tuning**

  * Concepts (such as prompt learning and prompt tuning) should be defined and used consistently with the consensus.
  * In prompt learning experiments, the verbalizer used (soft and hard) should be explicitly specified, or a clear justification should be provided if the verbalizer is omitted. Additionally, whether the prompt template follows the cloze or the prefix format should be mentioned.
  * In prompt tuning experiments, authors should provide details on soft prompt positions, length, and any variations tested, such as incorporating hard or mixed prompts, as part of the ablation study.



#### Limitations

A limitation was the large number of papers retrieved during the initial search, which was addressed by limiting the search scope to titles, abstracts, and keywords. Furthermore, since some studies may perform prompt engineering techniques without mentioning any of the 4 prompt-related expressions used in the queries, they might be missed by our searches.

#### Conclusions

Medical prompt engineering is an emerging field with significant potential for enhancing clinical applications, particularly in resource-constrained environments. Despite the promising capabilities demonstrated, there is a pressing need for standardized research practices and comprehensive reporting to ensure methodological transparency and reproducibility. Consistent evaluation against nonprompt-based baselines, prompt optimization documentation, and prompt settings reporting will be crucial for advancing the field. We hope that a better adherence to the recommended guidelines, in Textbox 1, will improve our understanding of prompt engineering and enhance the capabilities of LLMs in health care.

#### Acknowledgments

JZ is financed by the NCCR Evolving Language, a National Centre of Competence in Research, funded by the Swiss National Science Foundation (grant **#** 51NF40_180888).

#### Authors' Contributions

JZ and MN performed the screening and data extraction of the papers and synthesized the findings. AN and XT supervised MN. MB and CL supervised JZ. JZ and MN wrote the manuscript with support from MB, AN, XT, and CL. All authors contributed to the analysis of the results. CL conceived the original idea.

#### Conflicts of Interest

CL is the editor-in-chief of _JMIR Medical Informatics_. All other authors have no conflict of interest to declare.

Multimedia Appendix 1

PRISMA-ScR (Preferred Reporting Items for Systematic Reviews and Meta-Analyses extension for Scoping Reviews) checklist.

[PDF File (Adobe PDF File), 515 KB](https://jmir.org/api/download?alt_name=jmir_v26i1e60501_app1.pdf&filename=c7468ebd4d7b538602b41a75d60b03bb.pdf)

* * *

Multimedia Appendix 2

Search strategy and statistical analysis.

[DOCX File , 20 KB](https://jmir.org/api/download?alt_name=jmir_v26i1e60501_app2.docx&filename=15ee3b9900844ca56489b7e8a8722253.docx)

* * *

Multimedia Appendix 3

Reading notes and details of the reviewed papers.

[XLSX File (Microsoft Excel File), 52 KB](https://jmir.org/api/download?alt_name=jmir_v26i1e60501_app3.xlsx&filename=27d5efc27f61f272f6b16c2313bf46fa.xlsx)

* * *

#### References

  1. Brown T, Mann B, Ryder N, Subbiah M, Kaplan JD, Dhariwal P, et al. Language models are few-shot learners. 2020. Presented at: Advances in Neural Information Processing Systems; December 6, 2020:1877-1901; Virtual. URL: <https://papers.nips.cc/paper/2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html>
  2. Kojima T, Gu SS, Reid M, Matsuo Y, Iwasawa Y. Large language models are zero-shot reasoners. 2022. Presented at: Advances in Neural Information Processing Systems; November 28, 2022:22199-22213; New Orleans. URL: [https:/​/papers.​nips.cc/​paper_files/​paper/​2022/​hash/​8bb0d291acd4acf06ef112099c16f326-Abstract-Conference.​html](https://papers.nips.cc/paper_files/paper/2022/hash/8bb0d291acd4acf06ef112099c16f326-Abstract-Conference.html)
  3. Liu P, Yuan W, Fu J, Jiang Z, Hayashi H, Neubig G. Pre-train, prompt, and predict: a systematic survey of prompting methods in natural language processing. ACM Comput Surv. Jan 16, 2023;55(9):1-35. [[CrossRef](https://dx.doi.org/10.1145/3560815)]
  4. White J, Fu Q, Hays S, Sandborn M, Olea C, Gilbert H, et al. A prompt pattern catalog to enhance prompt engineering with ChatGPT. ArXiv. Preprint posted online on February 21, 2023. [[FREE Full text](https://arxiv.org/abs/2302.11382v1)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2302.11382)]
  5. Neveol A, Dalianis H, Velupillai S, Savova G, Zweigenbaum P. Clinical natural language processing in languages other than English: opportunities and challenges. J Biomed Semantics. 2018;9(1):12. [[FREE Full text](https://jbiomedsem.biomedcentral.com/articles/10.1186/s13326-018-0179-8)] [[CrossRef](https://dx.doi.org/10.1186/s13326-018-0179-8)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=29602312&dopt=Abstract)]
  6. Luccioni AS, Rogers A. Mind your language (model): fact-checking LLMs and their role in NLP research and practice. ArXiv. Preprint posted online on June 1, 2024. [[CrossRef](https://dx.doi.org/10.48550/arXiv.2308.07120)]
  7. Thirunavukarasu AJ, Ting DSJ, Elangovan K, Gutierrez L, Tan TF, Ting DSW. Large language models in medicine. Nat Med. 2023;29(8):1930-1940. [[CrossRef](https://dx.doi.org/10.1038/s41591-023-02448-8)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37460753&dopt=Abstract)]
  8. Zhao WX, Zhou K, Li J, Tang T, Wang X, Hou Y, et al. A survey of large language models. ArXiv. Preprint posted online on November 24, 2023. [[FREE Full text](https://arxiv.org/abs/2303.18223)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2303.18223)]
  9. Lester B, Al-Rfou R, Constant N. The power of scale for parameter-efficient prompt tuning. 2021. Presented at: Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing; January 10, 2021:3045-3059; Online and Punta Cana, Dominican Republic. [[CrossRef](https://dx.doi.org/10.18653/v1/2021.emnlp-main.243)]
  10. Fries J, Weber L, Seelam N, Altay G, Datta D, Garda S, et al. BigBIO: a framework for data-centric biomedical natural language processing. 2022. Presented at: Advances in Neural Information Processing Systems; November 28, 2022:25792-25806; New Orleans. URL: [https:/​/proceedings.​neurips.cc/​paper_files/​paper/​2022/​hash/​a583d2197eafc4afdd41f5b8765555c5-Abstract-Datasets_and_Benchmarks.​html](https://proceedings.neurips.cc/paper_files/paper/2022/hash/a583d2197eafc4afdd41f5b8765555c5-Abstract-Datasets_and_Benchmarks.html)
  11. Weisenthal SJ. ChatGPT and post-test probability. ArXiv. Preprint posted online on July 20, 2024. [[FREE Full text](http://arxiv.org/abs/2311.12188)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2311.12188)]
  12. Li L, Ning W. ProBioRE: a framework for biomedical causal relation extraction based on dual-head prompt and prototypical network. 2023. Presented at: 2023 IEEE International Conference on Bioinformatics and Biomedicine (BIBM); December 5, 2023:2071-2074; Istanbul, Turkiye. URL: <https://tinyurl.com/3n45uwdb>
  13. Li Z, Belkadi S, Micheletti N, Han L, Shardlow M, Nenadic G. Large language models and control mechanisms improve text readability of biomedical abstracts. ArXiv. Preprint posted online on March 16, 2024. [[FREE Full text](http://arxiv.org/abs/2309.13202)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2309.13202)]
  14. Li Q, Yang X, Wang H, Liu L, Wang Q, Wang J, et al. From beginner to expert: modeling medical knowledge into general LLMs. ArXiv. Preprint posted online on January 7, 2024. [[FREE Full text](http://arxiv.org/abs/2312.01040)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2312.01040)]
  15. Ateia S, Kruschwitz U. Is ChatGPT a biomedical expert? 2023. Presented at: Working Notes of the Conference and Labs of the Evaluation Forum (CLEF 2023); September 18-21, 2023:73-90; Thessaloniki, Greece. URL: <https://ceur-ws.org/Vol-3497/paper-006.pdf>
  16. Belyaeva A, Cosentino J, Hormozdiari F, Eswaran K, Shetty S, Corrado G, et al. Multimodal LLMs for health grounded in individual-specific data. 2023. Presented at: Machine Learning for Multimodal Healthcare Data; July 29, 2023:86-102; Honolulu, Hawaii, United States. [[CrossRef](https://dx.doi.org/10.1007/978-3-031-47679-2_7)]
  17. Chen Q, Sun H, Liu H, Jiang Y, Ran T, Jin X, et al. An extensive benchmark study on biomedical text generation and mining with ChatGPT. Bioinformatics. 2023;39(9):btad557. [[FREE Full text](https://europepmc.org/abstract/MED/37682111)] [[CrossRef](https://dx.doi.org/10.1093/bioinformatics/btad557)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37682111&dopt=Abstract)]
  18. Molla D. Large language models and prompt engineering for biomedical query focused multi-document summarisation. ArXiv. Preprint posted online on November 9, 2023. [[FREE Full text](http://arxiv.org/abs/2311.05169)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2311.05169)]
  19. Nori H, Lee YT, Zhang S, Carignan D, Edgar R, Fusi N, et al. Can generalist foundation models outcompete special-purpose tuning? Case study in medicine. ArXiv. Preprint posted online on November 28, 2023. [[FREE Full text](https://arxiv.org/abs/2311.16452)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2311.16452)]
  20. Singhal K, Azizi S, Tu T, Mahdavi SS, Wei J, Chung HW, et al. Large language models encode clinical knowledge. Nature. 2023;620(7972):172-180. [[FREE Full text](https://europepmc.org/abstract/MED/37438534)] [[CrossRef](https://dx.doi.org/10.1038/s41586-023-06291-2)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37438534&dopt=Abstract)]
  21. Tian S, Jin Q, Yeganova L, Lai PT, Zhu Q, Chen X, et al. Opportunities and challenges for ChatGPT and large language models in biomedicine and health. Brief Bioinform. 2023;25(1):bbad493. [[FREE Full text](https://europepmc.org/abstract/MED/38168838)] [[CrossRef](https://dx.doi.org/10.1093/bib/bbad493)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38168838&dopt=Abstract)]
  22. Lim S, Schmalzle R. Artificial intelligence for health message generation: an empirical study using a large language model (LLM) and prompt engineering. Front Commun. 2023;8:1129082. [[CrossRef](https://dx.doi.org/10.3389/fcomm.2023.1129082)]
  23. Wu YH, Lin YJ, Kao HY. IKM_Lab at BioLaySumm Task 1: longformer-based prompt tuning for biomedical lay summary generation. 2023. Presented at: The 22nd Workshop on Biomedical Natural Language Processing and BioNLP Shared Tasks; July 13, 2023; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.bionlp-1.64)]
  24. Zhang W, Chen C, Wang J, Liu J, Ruan T. A co-adaptive duality-aware framework for biomedical relation extraction. Bioinformatics. 2023;39(5):btad301. [[FREE Full text](https://europepmc.org/abstract/MED/37220895)] [[CrossRef](https://dx.doi.org/10.1093/bioinformatics/btad301)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37220895&dopt=Abstract)]
  25. Chen P, Wang J, Lin H, Zhao D, Yang Z. Few-shot biomedical named entity recognition via knowledge-guided instance generation and prompt contrastive learning. Bioinformatics. 2023;39(8):btad496. [[FREE Full text](https://europepmc.org/abstract/MED/37549065)] [[CrossRef](https://dx.doi.org/10.1093/bioinformatics/btad496)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37549065&dopt=Abstract)]
  26. Luo R, Sun L, Xia Y, Qin T, Zhang S, Poon H, et al. BioGPT: generative pre-trained transformer for biomedical text generation and mining. Brief Bioinform. 2022;23(6):bbac409. [[CrossRef](https://dx.doi.org/10.1093/bib/bbac409)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=36156661&dopt=Abstract)]
  27. Nori H, King N, McKinney SM, Carignan D, Horvitz E. Capabilities of GPT-4 on medical challenge problems. ArXiv. Preprint posted online on April 12, 2023. [[FREE Full text](http://arxiv.org/abs/2303.13375)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2303.13375)]
  28. Heinz MV, Bhattacharya S, Trudeau B, Quist R, Song SH, Lee CM, et al. Testing domain knowledge and risk of bias of a large-scale general artificial intelligence model in mental health. Digit Health. 2023;9:20552076231170499. [[FREE Full text](https://journals.sagepub.com/doi/10.1177/20552076231170499?url_ver=Z39.88-2003&rfr_id=ori:rid:crossref.org&rfr_dat=cr_pub  0pubmed)] [[CrossRef](https://dx.doi.org/10.1177/20552076231170499)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37101589&dopt=Abstract)]
  29. Ting Y, Hsieh T, Wang Y, Kuo Y, Chen Y, Chan P, et al. Performance of ChatGPT incorporated chain-of-thought method in bilingual nuclear medicine physician board examinations. Digit Health. 2024;10:20552076231224074. [[FREE Full text](https://journals.sagepub.com/doi/10.1177/20552076231224074?url_ver=Z39.88-2003&rfr_id=ori:rid:crossref.org&rfr_dat=cr_pub  0pubmed)] [[CrossRef](https://dx.doi.org/10.1177/20552076231224074)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38188855&dopt=Abstract)]
  30. Casola S, Labruna T, Lavelli A, Magnini B. Testing ChatGPT for stability and reasoning: a case study using Italian medical specialty tests. 2023. Presented at: Proceedings of the 9th Italian Conference on Computational Linguistics; November 30-Decemeber 2, 2023; Venice, Italy. URL: <https://ceur-ws.org/Vol-3596/paper13.pdf>
  31. Roemer G, Li A, Mahmood U, Dauer L, Bellamy M. Artificial intelligence model GPT4 narrowly fails simulated radiological protection exam. J Radiol Prot. 2024;44(1):013502. [[CrossRef](https://dx.doi.org/10.1088/1361-6498/ad1fdf)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38232401&dopt=Abstract)]
  32. Ali S, Shahab O, Al Shabeeb R, Ladak F, Yang JO, Nadkarni G, et al. General purpose large language models match human performance on gastroenterology board exam self-assessments. MedRxi. Preprint posted online on September 25, 2023. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2023.09.21.23295918v1)] [[CrossRef](https://dx.doi.org/10.1101/2023.09.21.23295918)]
  33. Patel D, Raut G, Zimlichman E, Cheetirala S, Nadkarni G, Glicksberg BS, et al. The limits of prompt engineering in medical problem-solving: a comparative analysis with ChatGPT on calculation based USMLE medical questions. MedRxiv. Preprint posted online on August 9, 2023. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2023.08.06.23293710v1)] [[CrossRef](https://dx.doi.org/10.1101/2023.08.06.23293710)]
  34. Sallam M, Al-Salahat K, Eid H, Egger J, Puladi B. Human versus artificial intelligence: ChatGPT-4 outperforming Bing, Bard, ChatGPT-3.5, and humans in clinical chemistry multiple-choice questions. MedRxiv. Preprint posted online on January 9, 2024. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2024.01.08.24300995v1)] [[CrossRef](https://dx.doi.org/10.1101/2024.01.08.24300995)]
  35. Savage T, Nayak A, Gallo R, Rangan E, Chen JH. Diagnostic reasoning prompts reveal the potential for large language model interpretability in medicine. NPJ Digit Med. 2024;7(1):20. [[FREE Full text](https://doi.org/10.1038/s41746-024-01010-1)] [[CrossRef](https://dx.doi.org/10.1038/s41746-024-01010-1)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38267608&dopt=Abstract)]
  36. Kung TH, Cheatham M, Medenilla A, Sillos C, De Leon L, Elepaño C, et al. Performance of ChatGPT on USMLE: potential for AI-assisted medical education using large language models. PLOS Digit Health. 2023;2(2):e0000198. [[FREE Full text](https://europepmc.org/abstract/MED/36812645)] [[CrossRef](https://dx.doi.org/10.1371/journal.pdig.0000198)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=36812645&dopt=Abstract)]
  37. Tanaka Y, Nakata T, Aiga K, Etani T, Muramatsu R, Katagiri S, et al. Performance of generative pretrained transformer on the national medical licensing examination in Japan. PLOS Digit Health. 2024;3(1):e0000433. [[FREE Full text](https://europepmc.org/abstract/MED/38261580)] [[CrossRef](https://dx.doi.org/10.1371/journal.pdig.0000433)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38261580&dopt=Abstract)]
  38. Rosoł M, Gąsior JS, Łaba J, Korzeniewski K, Młyńczak M. Evaluation of the performance of GPT-3.5 and GPT-4 on the Polish medical final examination. Sci Rep. 2023;13(1):20512. [[FREE Full text](https://doi.org/10.1038/s41598-023-46995-z)] [[CrossRef](https://dx.doi.org/10.1038/s41598-023-46995-z)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37993519&dopt=Abstract)]
  39. Sivarajkumar S, Kelley M, Samolyk-Mazzanti A, Visweswaran S, Wang Y. An empirical evaluation of prompting strategies for large language models in zero-shot clinical natural language processing. ArXiv. Preprint posted online on September 14, 2023. [[FREE Full text](http://arxiv.org/abs/2309.08008)] [[CrossRef](https://dx.doi.org/10.2196/55318)]
  40. Agrawal M, Hegselmann S, Lang H, Kim Y, Sontag D. Large language models are few-shot clinical information extractors. 2022. Presented at: Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing; May 25, 2022:1998-2022; Abu Dhabi. [[CrossRef](https://dx.doi.org/10.18653/v1/2022.emnlp-main.130)]
  41. Dong B, Wang Z, Li Z, Duan Z, Xu J, Pan T, et al. Toward a stable and low-resource PLM-based medical diagnostic system via prompt tuning and MoE structure. Sci Rep. 2023;13(1):12595. [[FREE Full text](https://doi.org/10.1038/s41598-023-39543-2)] [[CrossRef](https://dx.doi.org/10.1038/s41598-023-39543-2)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37537202&dopt=Abstract)]
  42. Gutierrez KLT, Viacrusis PML. Bridging the gap or widening the divide: a call for capacity-building in artificial intelligence for healthcare in the Philippines. JMUST. 2023;7(2):1325-1334. [[CrossRef](https://dx.doi.org/10.35460/2546-1621.2023-0081)]
  43. Islam KS, Nipu AS, Madiraju P, Deshpande P. Autocompletion of chief complaints in the electronic health records using large language models. 2023. Presented at: 2023 IEEE International Conference on Big Data (BigData); December 15-18, 2023:4912-4921; Sorrento, Italy. URL: <https://tinyurl.com/4ajdyddt> [[CrossRef](https://dx.doi.org/10.1109/bigdata59044.2023.10386778)]
  44. Meoni S, Ryffel T, De La Clergerie É. Annotate French clinical data using large language model predictions. 2023. Presented at: 2023 IEEE 11th International Conference on Healthcare Informatics (ICHI); June 26-29, 2023:550-557; Houston, TX, United States. URL: <https://tinyurl.com/yy2b9fe8> [[CrossRef](https://dx.doi.org/10.1109/ichi57859.2023.00099)]
  45. Meoni S, De la Clergerie E, Ryffel T. Large language models as instructors: a study on multilingual clinical entity extraction. 2023. Presented at: The 22nd Workshop on Biomedical Natural Language Processing and BioNLP Shared Tasks; July 2023:178-190; Toronto, Canada. URL: <https://aclanthology.org/2023.bionlp-1.15/> [[CrossRef](https://dx.doi.org/10.18653/v1/2023.bionlp-1.15)]
  46. Wang X, Yang Q. LingX at ROCLING 2023 MultiNER-health task: intelligent capture of Chinese medical named entities by LLMs. 2023. Presented at: Proceedings of the 35th Conference on Computational Linguistics and Speech Processing (ROCLING 2023); October 20-21, 2023; Taipei City, Taiwan. URL: <https://aclanthology.org/2023.rocling-1.44.pdf>
  47. Yang Y, Li X, Wang H, Guan Y, Jiang J. Modeling clinical thinking based on knowledge hypergraph attention network and prompt learning for disease prediction. SSRN. Preprint posted online on June 30, 2023. [[FREE Full text](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4496800)] [[CrossRef](https://dx.doi.org/10.2139/ssrn.4496800)]
  48. Yao Z, Jaafar A, Wang B, Zhu Y, Yang Z, Yu H. Do physicians know how to prompt? The need for automatic prompt optimization help in clinical note generation. ArXiv. Preprint posted online on July 5, 2024. [[FREE Full text](http://arxiv.org/abs/2311.09684)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2311.09684)]
  49. van Zandvoort D, Wiersema L, Huibers T, van Dulmen S, Brinkkemper S. Enhancing summarization performance through transformer-based prompt engineering in automated medical reporting. ArXiv. Preprint posted online on January 19, 2024. [[FREE Full text](http://arxiv.org/abs/2311.13274)] [[CrossRef](https://dx.doi.org/10.5220/0012422600003657)]
  50. Zhang B, Mishra R, Teodoro D. DS4DH at MEDIQA-Chat 2023: leveraging SVM and GPT-3 prompt engineering for medical dialogue classification and summarization. 2023. Presented at: Proceedings of the 5th Clinical Natural Language Processing Workshop; June 12, 2023:536-545; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.clinicalnlp-1.57)]
  51. Zhu W, Wang X, Chen M, Tang B. Overview of the PromptCBLUE Shared Task in CHIP2023. ArXiv. Preprint posted online on December 29, 2023. [[FREE Full text](http://arxiv.org/abs/2312.17522)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2312.17522)]
  52. Caruccio L, Cirillo S, Polese G, Solimando G, Sundaramurthy S, Tortora G. Can ChatGPT provide intelligent diagnoses? A comparative study between predictive models and ChatGPT to define a new medical diagnostic bot. Expert Syst Appl. 2024;235:121186. [[CrossRef](https://dx.doi.org/10.1016/j.eswa.2023.121186)]
  53. Lee Y, Chen C, Chen C, Lee C, Chen P, Wu C, et al. Unlocking the secrets behind advanced artificial intelligence language models in deidentifying Chinese-English mixed clinical text: development and validation study. J Med Internet Res. 2024;26:e48443. [[FREE Full text](https://www.jmir.org/2024//e48443/)] [[CrossRef](https://dx.doi.org/10.2196/48443)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38271060&dopt=Abstract)]
  54. Bhaumik R, Srivastava V, Jalali A, Ghosh S, Chandrasekaran R. Mindwatch: a smart cloud-based AI solution for suicide ideation detection leveraging large language models. MedRxiv. Preprint posted online on September 26, 2023. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2023.09.25.23296062v1)] [[CrossRef](https://dx.doi.org/10.1101/2023.09.25.23296062)]
  55. Heston TF. Safety of large language models in addressing depression. Cureus. 2023:15. [[FREE Full text](https://www.cureus.com/articles/213293-safety-of-large-language-models-in-addressing-depression.pdf)] [[CrossRef](https://dx.doi.org/10.7759/cureus.50729)]
  56. Grabb D. The impact of prompt engineering in large language model performance: a psychiatric example. J Med Artif Intell. 2023;6:20. [[FREE Full text](https://jmai.amegroups.org/article/view/8190/html)] [[CrossRef](https://dx.doi.org/10.21037/jmai-23-71)]
  57. Santos WR, Paraboni I. Prompt-based mental health screening from social media text. ArXiv. Preprint posted online on May 11, 2024. [[FREE Full text](http://arxiv.org/abs/2401.05912)] [[CrossRef](https://dx.doi.org/10.5753/brasnam.2024.1879)]
  58. Yang K, Ji S, Zhang T, Xie Q, Kuang Z, Ananiadou S. Towards interpretable mental health analysis with large language models. 2023. Presented at: Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing; January 16, 2023:6056-6077; Singapore. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.emnlp-main.370)]
  59. Xu X, Yao B, Dong Y, Gabriel S, Yu H, Hendler J, et al. Mental-LLM: leveraging large language models for mental health prediction via online text data. Proc ACM Interact Mob Wearable Ubiquitous Technol. 2024;8(1):1-32. [[CrossRef](https://dx.doi.org/10.1145/3643540)]
  60. Chen S, Wu M, Zhu KQ, Lan K, Zhang Z, Cui L. LLM-empowered chatbots for psychiatrist and patient simulation: application and evaluation. ArXiv. Preprint posted online on May 23, 2023. [[FREE Full text](http://arxiv.org/abs/2305.13614)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2305.13614)]
  61. Qi H, Zhao Q, Li J, Song C, Zhai W, Dan L, et al. Supervised learning and large language model benchmarks on mental health datasets: cognitive distortions and suicidal risks in Chinese social media. ResearchSquare. Preprint posted online on November 02, 2023. [[FREE Full text](https://www.researchsquare.com/article/rs-3523508/latest)] [[CrossRef](https://dx.doi.org/10.21203/rs.3.rs-3523508/v1)]
  62. Sambath V. Advancements of artificial intelligence in mental health applications?: A comparative analysis of ChatGPT 3.5 and ChatGPT 4. ResearchGate. Preprint posted online on December, 2023. [[FREE Full text](https://www.researchgate.net/publication/376517245_Advancements_of_Artificial_Intelligence_in_Mental_Health_Applications_A_Comparative_analysis_of_ChatGPT_35_and_ChatGPT_4)] [[CrossRef](https://dx.doi.org/10.13140/RG.2.2.28713.36961)]
  63. Choi HS, Song JY, Shin KH, Chang JH, Jang B. Developing prompts from large language model for extracting clinical information from pathology and ultrasound reports in breast cancer. Radiat Oncol J. 2023;41(3):209-216. [[FREE Full text](https://europepmc.org/abstract/MED/37793630)] [[CrossRef](https://dx.doi.org/10.3857/roj.2023.00633)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37793630&dopt=Abstract)]
  64. Lee DT, Vaid A, Menon KM, Freeman R, Matteson DS, Marin MP, et al. Development of a privacy preserving large language model for automated data extraction from thyroid cancer pathology reports. MedRxiv. Preprint posted online on November 8, 2023. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2023.11.08.23298252v1)] [[CrossRef](https://dx.doi.org/10.1101/2023.11.08.23298252)]
  65. Dennstadt F, Hastings J, Putora PM, Vu E, Fischer GF, Suveg K, et al. Exploring capabilities of large language models such as ChatGPT in radiation oncology. Adv Radiat Oncol. 2024;9(3):101400. [[FREE Full text](https://linkinghub.elsevier.com/retrieve/pii/S2452-1094\(23\)00228-2)] [[CrossRef](https://dx.doi.org/10.1016/j.adro.2023.101400)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38304112&dopt=Abstract)]
  66. Zhu S, Gilbert M, Ghanem AI, Siddiqui F, Thind K. Feasibility of using zero-shot learning in transformer-based natural language processing algorithm for key information extraction from head and neck tumor board notes. Int J Radiat Oncol Biol Phys. 2023;117(2):e500. [[CrossRef](https://dx.doi.org/10.1016/j.ijrobp.2023.06.1743)]
  67. Zhao X, Zhang M, Ma M, Su C, Wang M, Qiao X, et al. HW-TSC at SemEval-2023 task 7: exploring the natural language inference capabilities of ChatGPT and pre-trained language model for clinical trial. 2023. Presented at: Proceedings of the 17th International Workshop on Semantic Evaluation (SemEval-2023); July 10, 2023:1603-1608; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.semeval-1.221)]
  68. Nazary F, Deldjoo Y, Di Noia T. ChatGPT-HealthPrompt. Harnessing the power of XAI in prompt-based healthcare decision support using ChatGPT. 2023. Presented at: Artificial Intelligence. ECAI 2023 International Workshops; September 30-October 4, 2023:382-397; Krakow, Poland. [[CrossRef](https://dx.doi.org/10.1007/978-3-031-50396-2_22)]
  69. Wang B, Lai J, Cao H, Jin F, Tang M, Yao C, et al. Enhancing real-world data extraction in clinical research: evaluating the impact of the implementation of large language models in hospital setting. ResearchSquare. Preprint posted online on November 29, 2023. [[FREE Full text](https://doi.org/10.21203/rs.3.rs-3644810/v2)] [[CrossRef](https://dx.doi.org/10.21203/rs.3.rs-3644810/v2)]
  70. Mishra V, Sarraju A, Kalwani NM, Dexter JP. Evaluation of prompts to simplify cardiovascular disease information using a large language model. MedRxiv. Preprint posted online on November 9, 2023. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2023.11.08.23298225v1)] [[CrossRef](https://dx.doi.org/10.1101/2023.11.08.23298225)]
  71. Feng R, Brennan KA, Azizi Z, Goyal J, Pedron M, Chang HJ, et al. Optimizing ChatGPT to detect VT recurrence from complex medical notes. Circulation. 2023;148(Suppl 1):A16401. [[CrossRef](https://dx.doi.org/10.1161/circ.148.suppl_1.16401)]
  72. Chowdhury M, Lim E, Higham A, McKinnon R, Ventoura N, He Y, et al. Can large language models safely address patient questions following cataract surgery? 2023. Presented at: Proceedings of the 5th Clinical Natural Language Processing Workshop; June 10, 2023:131-137; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.clinicalnlp-1.17)]
  73. Kleinig O, Gao C, Kovoor JG, Gupta AK, Bacchi S, Chan WO. How to use large language models in ophthalmology: from prompt engineering to protecting confidentiality. Eye (Lond). 2024;38(4):649-653. [[FREE Full text](https://europepmc.org/abstract/MED/37798360)] [[CrossRef](https://dx.doi.org/10.1038/s41433-023-02772-w)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37798360&dopt=Abstract)]
  74. Arsenyan V, Bughdaryan S, Shaya F, Small K, Shahnazaryan D. Large language models for biomedical knowledge graph construction: information extraction from EMR notes. ArXiv. Preprint posted online on December 9, 2023. [[FREE Full text](https://arxiv.org/abs/2301.12473)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2301.12473)]
  75. Kwon T, Ong KT, Kang D, Moon S, Lee JR, Hwang D, et al. Large language models are clinical reasoners: reasoning-aware diagnosis framework with prompt-generated rationales. 2024. Presented at: Proceedings of the Association for the Advancement of Artificial Intelligence Conference on Artificial Intelligence; February 20, 2024:18417-18425; Vancouver. [[CrossRef](https://dx.doi.org/10.1609/aaai.v38i16.29802)]
  76. Wang C, Liu S, Li A, Liu J. Text dialogue analysis for primary screening of mild cognitive impairment: development and validation study. J Med Internet Res. 2023;25:e51501. [[FREE Full text](https://www.jmir.org/2023//e51501/)] [[CrossRef](https://dx.doi.org/10.2196/51501)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38157230&dopt=Abstract)]
  77. Li J, Wang L, Chen X, Deng X, Wen H, You M, et al. Are you asking GPT-4 medical questions properly?--Prompt engineering in consistency and reliability with evidence-based guidelines for ChatGPT-4: a pilot study. ResearchSquare. Posted online on October 3, 2023. 2023:1-20. [[FREE Full text](https://web.archive.org/web/20240307033415id_/https://assets.researchsquare.com/files/rs-3336823/v1/7c3c8e95-14ee-4a13-b7c0-0cc27487e651.pdf?c=1708503116)] [[CrossRef](https://dx.doi.org/10.21203/rs.3.rs-3336823/v1)]
  78. Zaidat B, Lahoti YS, Yu A, Mohamed KS, Cho SK, Kim JS. Artificially intelligent billing in spine surgery: an analysis of a large language model. Global Spine J. 2023:21925682231224753. [[FREE Full text](https://journals.sagepub.com/doi/abs/10.1177/21925682231224753?url_ver=Z39.88-2003&rfr_id=ori:rid:crossref.org&rfr_dat=cr_pub  0pubmed)] [[CrossRef](https://dx.doi.org/10.1177/21925682231224753)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38147047&dopt=Abstract)]
  79. Datta S, Lee K, Paek H, Manion FJ, Ofoegbu N, Du J, et al. AutoCriteria: a generalizable clinical trial eligibility criteria extraction system powered by large language models. J Am Med Inform Assoc. 2024;31(2):375-385. [[FREE Full text](https://europepmc.org/abstract/MED/37952206)] [[CrossRef](https://dx.doi.org/10.1093/jamia/ocad218)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37952206&dopt=Abstract)]
  80. White R, Peng T, Sripitak P, Rosenberg Johansen A, Snyder M. CliniDigest: a case study in large language model based large-scale summarization of clinical trial descriptions. 2023. Presented at: Proceedings of the 2023 ACM Conference on Information Technology for Social Good; September 6-8, 2023; Lisbon, Portugal. [[CrossRef](https://dx.doi.org/10.1145/3582515.3609559)]
  81. Scherr R, Halaseh FF, Spina A, Andalib S, Rivera R. ChatGPT interactive medical simulations for early clinical education: case study. JMIR Med Educ. 2023;9:e49877. [[FREE Full text](https://mededu.jmir.org/2023//e49877/)] [[CrossRef](https://dx.doi.org/10.2196/49877)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37948112&dopt=Abstract)]
  82. Akinci D'Antonoli T, Stanzione A, Bluethgen C, Vernuccio F, Ugga L, Klontzas ME, et al. Large language models in radiology: fundamentals, applications, ethical considerations, risks, and future directions. Diagn Interv Radiol. 2024;30(2):80-90. [[FREE Full text](https://europepmc.org/abstract/MED/37789676)] [[CrossRef](https://dx.doi.org/10.4274/dir.2023.232417)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37789676&dopt=Abstract)]
  83. Wiest IC, Ferber D, Zhu J, van Treeck M, Meyer SK, Juglan SK, et al. From text to tables: a local privacy preserving large language model for structured information retrieval from medical documents. MedRxiv. Preprint posted online on December 8, 2023. [[FREE Full text](https://www.medrxiv.org/content/10.1101/2023.12.07.23299648v1)] [[CrossRef](https://dx.doi.org/10.1101/2023.12.07.23299648)]
  84. Hamed E, Eid A, Alberry M. Exploring ChatGPT's potential in facilitating adaptation of clinical guidelines: a case study of diabetic ketoacidosis guidelines. Cureus. 2023;15(5):e38784. [[FREE Full text](https://europepmc.org/abstract/MED/37303347)] [[CrossRef](https://dx.doi.org/10.7759/cureus.38784)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37303347&dopt=Abstract)]
  85. Leypold T, Schafer B, Boos A, Beier JP. Can AI think like a plastic surgeon? Evaluating GPT-4's clinical judgment in reconstructive procedures of the upper extremity. Plast Reconstr Surg Glob Open. 2023;11(12):e5471. [[FREE Full text](https://europepmc.org/abstract/MED/38093728)] [[CrossRef](https://dx.doi.org/10.1097/GOX.0000000000005471)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38093728&dopt=Abstract)]
  86. Yang J, Liu C, Deng W, Wu D, Weng C, Zhou Y, et al. Enhancing phenotype recognition in clinical notes using large language models: PhenoBCBERT and PhenoGPT. Patterns (NY). 2024;5(1):100887. [[FREE Full text](https://linkinghub.elsevier.com/retrieve/pii/S2666-3899\(23\)00288-X)] [[CrossRef](https://dx.doi.org/10.1016/j.patter.2023.100887)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38264716&dopt=Abstract)]
  87. Xiong L, Zeng Q, Deng W, Luo W, Liu R. A novel approach to nursing clinical intelligent decision-making: integration of large language models and local knowledge bases. ResearchSquare. Preprint posted online on December 8, 2023. [[FREE Full text](https://assets-eu.researchsquare.com/files/rs-3756467/v1/264ae798-f8f8-4953-9351-9f4a4c2cf87b.pdf?c=1703192974)] [[CrossRef](https://dx.doi.org/10.21203/rs.3.rs-3756467/v1)]
  88. Zeng Q, Liu Y, He P. A medical question classification approach based on prompt tuning and contrastive learning. 2023. Presented at: The Thirty Fifth International Conference on Software Engineering and Knowledge Engineering (SEKE 2023); July 1-10, 2023:632-635; San Francisco, CA, United States. [[CrossRef](https://dx.doi.org/10.18293/seke2023-025)]
  89. Zhao D, Yang Y, Chen P, Meng J, Sun S, Wang J, et al. Biomedical document relation extraction with prompt learning and KNN. J Biomed Inform. 2023;145:104459. [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2023.104459)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37531999&dopt=Abstract)]
  90. Zhu T, Qin Y, Feng M, Chen Q, Hu B, Xiang Y. BioPRO: context-infused prompt learning for biomedical entity linking. IEEE/ACM Trans Audio Speech Lang Process. 2024;32(2023):374-385. [[CrossRef](https://dx.doi.org/10.1109/taslp.2023.3331149)]
  91. Liu C, Zhang S, Li C, Zhao H. CPK-Adapter: infusing medical knowledge into K-adapter with continuous prompt. 2023. Presented at: 2023 8th International Conference on Intelligent Computing and Signal Processing (ICSP); April 21-23, 2023:1017-1023; Xi'an, China. [[CrossRef](https://dx.doi.org/10.1109/icsp58490.2023.10248750)]
  92. Yeh HS, Lavergne T, Zweigenbaum P. Decorate the examples: a simple method of prompt design for biomedical relation extraction. 2022. Presented at: Proceedings of the Thirteenth Language Resources and Evaluation Conference; August 13, 2024:3780-3787; Marseille, France. URL: <https://aclanthology.org/2022.lrec-1.403>
  93. Su Z, Yu X, Chen P. EPTQA: a Chinese medical prompt learning method based on entity pair type question answering. SSRN. 2023:24. [[CrossRef](https://dx.doi.org/10.2139/ssrn.4563840)]
  94. Xu H, Zhang J, Wang Z, Zhang S, Bhalerao M, Liu Y, et al. GraphPrompt: graph-based prompt templates for biomedical synonym prediction. 2023. Presented at: Proceedings of the Association for the Advancement of Artificial Intelligence Conference on Artificial Intelligence; February 7, 2023:10576-10584; Washington, DC, United States. [[CrossRef](https://dx.doi.org/10.1609/aaai.v37i9.26256)]
  95. Chen T, Stefanidis A, Jiang Z, Su J. Improving biomedical claim detection using prompt learning approaches. 2023. Presented at: 2023 IEEE 4th International Conference on Pattern Recognition and Machine Learning (PRML); August 4-6, 2023:369-376; Urumqi, China. [[CrossRef](https://dx.doi.org/10.1109/prml59573.2023.10348317)]
  96. Xu Z, Chen Y, Hu B. Improving biomedical entity linking with cross-entity interaction. 2023. Presented at: Proceedings of the Association for the Advancement of Artificial Intelligence Conference on Artificial Intelligence; February 7, 2023:13869-13877; Washington. [[CrossRef](https://dx.doi.org/10.1609/aaai.v37i11.26624)]
  97. Wang Y, Wang Y, Peng Z, Zhang F, Zhou L, Yang F. Medical text classification based on the discriminative pre-training model and prompt-tuning. Digit Health. 2023;9:1-14. [[FREE Full text](https://journals.sagepub.com/doi/10.1177/20552076231193213?url_ver=Z39.88-2003&rfr_id=ori:rid:crossref.org&rfr_dat=cr_pub  0pubmed)] [[CrossRef](https://dx.doi.org/10.1177/20552076231193213)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37559830&dopt=Abstract)]
  98. Tian X, Wang P, Mao S. Open-world biomedical knowledge probing and verification. 2023. Presented at: Proceedings of The 12th International Joint Conference on Knowledge Graphs (IJCKG-23); December 8-9, 2023; Tokyo, Japan. URL: <https://ijckg2023.knowledge-graph.jp/pages/proc/paper_3.pdf>
  99. Lu K, Potash P, Lin X, Sun Y, Qian Z, Yuan Z, et al. Prompt discriminative language models for domain adaptation. 2023. Presented at: Proceedings of the 5th Clinical Natural Language Processing Workshop; July 14, 2023:247-258; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.clinicalnlp-1.30)]
  100. Hu Y, Chen Y, Xu H. Towards more generalizable and accurate sentence classification in medical abstracts with less data. J Healthc Inform Res. 2023;7(4):542-556. [[CrossRef](https://dx.doi.org/10.1007/s41666-023-00141-6)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37927376&dopt=Abstract)]
  101. Taylor N, Zhang Y, Joyce DW, Gao Z, Kormilitzin A, Nevado-Holgado A. Clinical prompt learning with frozen language models. IEEE Trans Neural Netw Learn Syst. 2023:1-11. [[CrossRef](https://dx.doi.org/10.1109/TNNLS.2023.3294633)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37566498&dopt=Abstract)]
  102. Landi I, Alleva E, Valentine AA, Lepow LA, Charney AW. Clinical text deduplication practices for efficient pretraining and improved clinical tasks. ArXiv. Preprint posted online on September 29, 2023. [[FREE Full text](https://arxiv.org/abs/2312.09469)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2312.09469)]
  103. Sivarajkumar S, Wang Y. HealthPrompt: a zero-shot learning paradigm for clinical natural language processing. AMIA Annu Symp Proc. 2022;2022:972-981. [[FREE Full text](https://europepmc.org/abstract/MED/37128372)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37128372&dopt=Abstract)]
  104. Sivarajkumar S, Wang Y. Evaluation of healthprompt for zero-shot clinical text classification. 2023. Presented at: 2023 IEEE 11th International Conference on Healthcare Informatics (ICHI); June 26-29, 2023:492-494; Houston, TX, United States. [[CrossRef](https://dx.doi.org/10.1109/ichi57859.2023.00081)]
  105. Zhang L, Liu J. Intent-aware prompt learning for medical question summarization. 2022. Presented at: 2022 IEEE International Conference on Bioinformatics and Biomedicine (BIBM); December 6-8, 2022:672-679; Las Vegas, NV, United States. [[CrossRef](https://dx.doi.org/10.1109/bibm55620.2022.9995317)]
  106. Alleva E, Landi I, Shaw LJ, Bottinger E, Fuchs TJ, Ensari I. Keyword-optimized template insertion for clinical information extraction via prompt-based learning. ArXiv. Preprint posted online on October 31, 2023. [[FREE Full text](https://arxiv.org/abs/2310.20089)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2310.20089)]
  107. Cui Z, Yu K, Yuan Z, Dong X, Luo W. Language inference-based learning for low-resource Chinese clinical named entity recognition using language model. J Biomed Inform. 2024;149:104559. [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2023.104559)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38056702&dopt=Abstract)]
  108. Ahmed A, Zeng X, Xi R, Hou M, Shah SA. MED-Prompt: a novel prompt engineering framework for medicine prediction on free-text clinical notes. J King Saud Univ Comput Inf Sci. 2024;36(2):1-17. [[CrossRef](https://dx.doi.org/10.1016/j.jksuci.2024.101933)]
  109. Lu Y, Liu X, Du Z, Gao Y, Wang G. MedKPL: a heterogeneous knowledge enhanced prompt learning framework for transferable diagnosis. J Biomed Inform. 2023;143:104417. [[FREE Full text](https://linkinghub.elsevier.com/retrieve/pii/S1532-0464\(23\)00138-7)] [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2023.104417)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37315832&dopt=Abstract)]
  110. Cui Y, Han L, Nenadic G. MedTem2.0: prompt-based temporal classification of treatment events from discharge summaries. 2023. Presented at: Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 4: Student Research Workshop); July 10-12, 2023:160-183; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.acl-srw.27)]
  111. Wang Z, Sun J. PromptEHR: conditional electronic healthcare records generation with prompt learning. 2022. Presented at: Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, Association for Computational Linguistics; October 11, 2022:2873-2855; Abu Dhabi, United Arab Emirates. [[CrossRef](https://dx.doi.org/10.18653/v1/2022.emnlp-main.185)]
  112. Wang S, Tang L, Majety A, Rousseau JF, Shih G, Ding Y, et al. Trustworthy assertion classification through prompting. J Biomed Inform. 2022;132:104139. [[FREE Full text](https://linkinghub.elsevier.com/retrieve/pii/S1532-0464\(22\)00153-8)] [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2022.104139)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=35811026&dopt=Abstract)]
  113. Yao Z, Tsai J, Liu W, Levy DA, Druhl E, Reisman JI, et al. Automated identification of eviction status from electronic health record notes. J Am Med Inform Assoc. 2023;30(8):1429-1437. [[FREE Full text](https://europepmc.org/abstract/MED/37203429)] [[CrossRef](https://dx.doi.org/10.1093/jamia/ocad081)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37203429&dopt=Abstract)]
  114. Kwon S, Wang X, Liu W, Druhl E, Sung ML, Reisman JI, et al. ODD: a benchmark dataset for the natural language processing based opioid related aberrant behavior detection. 2024. Presented at: Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies; June 16, 2024:1-22; Mexico City. [[CrossRef](https://dx.doi.org/10.18653/v1/2024.naacl-long.244)]
  115. Su J, Zhang J, Peng P, Wang H. EGDE: a framework for bridging the gap in medical zero-shot relation triplet extraction. 2023. Presented at: 2023 IEEE International Conference on Bioinformatics and Biomedicine (BIBM); December 5-8, 2023; Istanbul, Turkiye. [[CrossRef](https://dx.doi.org/10.1109/bibm58861.2023.10385666)]
  116. Li Q, Wang Y, You T, Lu Y. BioKnowPrompt: incorporating imprecise knowledge into prompt-tuning verbalizer with biomedical text for relation extraction. Inf Sci. 2022;617:346-358. [[CrossRef](https://dx.doi.org/10.1016/j.ins.2022.10.063)]
  117. Peng C, Yang X, Chen A, Yu Z, Smith KE, Costa AB, et al. Generative large language models are all-purpose text analytics engines: text-to-text learning is all your need. J Am Med Inform Assoc. Sep 01, 2024;31(9):1892-1903. [[FREE Full text](https://academic.oup.com/jamia/advance-article-abstract/doi/10.1093/jamia/ocae078/7648661?redirectedFrom=fulltext)] [[CrossRef](https://dx.doi.org/10.1093/jamia/ocae078)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38630580&dopt=Abstract)]
  118. Peng C, Yang X, Smith KE, Yu Z, Chen A, Bian J, et al. Model tuning or prompt tuning? A study of large language models for clinical concept and relation extraction. J Biomed Inform. 2024;153:104630. [[FREE Full text](https://europepmc.org/abstract/MED/38548007)] [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2024.104630)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38548007&dopt=Abstract)]
  119. Duan J, Lu F, Liu J. MVP: optimizing multi-view prompts for medical dialogue summarization. 2023. Presented at: 2023 IEEE International Conference on Bioinformatics and Biomedicine (BIBM); December 5-8, 2023; Istanbul, Turkiye. [[CrossRef](https://dx.doi.org/10.1109/bibm58861.2023.10385916)]
  120. Rohanian O, Jauncey H, Nouriborji M, Kumar V, Gonalves BP, Kartsonaki C, et al. Using bottleneck adapters to identify cancer in clinical notes under low-resource constraints. 2023. Presented at: The 22nd Workshop on Biomedical Natural Language Processing and BioNLP Shared Tasks; July 23, 2023:6239-6278; Toronto, Canada. [[CrossRef](https://dx.doi.org/10.18653/v1/2023.bionlp-1.5)]
  121. Elfrink A, Vagliano I, Abu-Hanna A, Calixto I. Soft-prompt tuning to predict lung cancer using primary care free-text Dutch medical notes. In: Artificial Intelligence in Medicine. Cham. Springer Nature Switzerland; 2023:193-198.
  122. Singh Rawat BP, Yu H. Parameter efficient transfer learning for suicide attempt and ideation detection. 2022. Presented at: Proceedings of the 13th International Workshop on Health Text Mining and Information Analysis (LOUHI); September 7, 2022:108-115; Abu Dhabi, United Arab Emirates. [[CrossRef](https://dx.doi.org/10.18653/v1/2022.louhi-1.13)]
  123. Xu S, Wan X, Hu S, Zhou M, Xu T, Wang H, et al. COSSUM: towards conversation-oriented structured summarization for automatic medical insurance assessment. 2022. Presented at: Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining; August 14-18, 2022:4248-4256; Washington, DC, United States. [[CrossRef](https://dx.doi.org/10.1145/3534678.3539116)]
  124. Shaitarova A, Zaghir J, Lavelli A, Krauthammer M, Rinaldi F. Exploring the latest highlights in medical natural language processing across multiple languages: a survey. Yearb Med Inform. 2023;32(1):230-243. [[FREE Full text](http://www.thieme-connect.com/DOI/DOI?10.1055/s-0043-1768726)] [[CrossRef](https://dx.doi.org/10.1055/s-0043-1768726)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=38147865&dopt=Abstract)]
  125. Ding N, Hu S, Zhao W, Chen Y, Liu Z, Zheng HT, et al. OpenPrompt: an open-source framework for prompt-learning. ArXiv. Preprint posted online on November 3, 2021. [[FREE Full text](https://arxiv.org/abs/2111.01998)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2111.01998)]
  126. Ducel F, Fort K, Lejeune G, Lepage Y. Do we name the languages we study? The #BenderRule in LREC and ACL articles. 2022. Presented at: Proceedings of the Thirteenth Language Resources and Evaluation Conference; June 20-25, 2022:564-573; Marseille, France. URL: <https://aclanthology.org/2022.lrec-1.60>
  127. Luo Y, Yang Z, Meng F, Li Y, Zhou J, Zhang Y. An empirical study of catastrophic forgetting in large language models during continual fine-tuning. ArXiv. Preprint posted online on April 2, 2024. [[FREE Full text](https://arxiv.org/abs/2308.08747)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2308.08747)]



  


* * *

#### Abbreviations

**BERT:** Bidirectional Encoder Representations From Transformers  
---  
**CoT:** chain-of-thought  
**LLM:** large language model  
**MCQ:** multiple-choice question  
**MLM:** masked language modeling  
**NLP:** natural language processing  
**PD:** prompt design  
**PL:** prompt learning  
**PRISMA-ScR:** Preferred Reporting Items for Systematic Reviews and Meta-Analyses extension for Scoping Reviews  
**PT:** prompt tuning  
  


* * *

Edited by T de Azevedo Cardoso; submitted 14.05.24; peer-reviewed by B Bhasuran, D Hu, A Jain; comments to author 03.07.24; revised version received 09.07.24; accepted 22.07.24; published 10.09.24.

[Copyright ](https://support.jmir.org/hc/en-us/articles/115002955531)

(C)Jamil Zaghir, Marco Naguib, Mina Bjelogrlic, Aurelie Neveol, Xavier Tannier, Christian Lovis. Originally published in the Journal of Medical Internet Research (https://www.jmir.org), 10.09.2024.

This is an open-access article distributed under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work, first published in the Journal of Medical Internet Research (ISSN 1438-8871), is properly cited. The complete bibliographic information, a link to the original publication on https://www.jmir.org/, as well as this copyright and license information must be included.

  


##  Citation 

Please cite as: 

Zaghir J, Naguib M, Bjelogrlic M, Névéol A, Tannier X, Lovis C   
Prompt Engineering Paradigms for Medical Applications: Scoping Review   
J Med Internet Res 2024;26:e60501   
doi: [ 10.2196/60501 ](https://doi.org/10.2196/60501) PMID: [39255030](https://www.ncbi.nlm.nih.gov/pubmed/39255030) PMCID: [11422740](https://www.ncbi.nlm.nih.gov/pmc/articles/11422740)

Copy Citation to Clipboard 

##  Export Metadata 

[ END ](https://www.jmir.org/article/export/end/jmir_v26i1e60501) for: Endnote

[ BibTeX ](https://www.jmir.org/article/export/bib/jmir_v26i1e60501) for: BibDesk, LaTeX

[ RIS ](https://www.jmir.org/article/export/ris/jmir_v26i1e60501) for: RefMan, Procite, Endnote, RefWorks

[ Add this article to your Mendeley library ](http://www.mendeley.com/import/?doi=10.2196/60501)

##  This paper is in the following e-collection/theme issue:

[ Digital Health Reviews (1438) ](/themes/18)[ Artificial Intelligence (1602) ](/themes/797)[ Generative Language Models Including ChatGPT (413) ](/themes/1437)[ AI Language Models in Health Care (85) ](/themes/1552)[ Natural Language Processing (764) ](/themes/171)[ Artificial Intelligence, Machine Learning, and Natural Language Processing for Public Health (41) ](/themes/1418)[ Theme Issue: ChatGPT and Generative Language Models in Medical Education (92) ](/themes/1302)

##  Download 

[ Download PDF](https://www.jmir.org/2024/1/e60501/PDF) [ Download XML](https://www.jmir.org/2024/1/e60501/XML)

##  Share Article 

[](https://bsky.app/intent/compose?text=Check%20out%20this%20fascinating%20article%20https%3A%2F%2Fwww.jmir.org%2F2024%2F1%2Fe60501 "share-on-Bluesky") [](https://twitter.com/intent/tweet?url=Check%20out%20this%20fascinating%20article%20https%3A%2F%2Fwww.jmir.org%2F2024%2F1%2Fe60501 "share-on-Twitter") [](https://www.facebook.com/sharer.php?s=100&u=https://www.jmir.org/2024/1/e60501&quote=Check%20out%20this%20fascinating%20article "share-on-Facebook") [](https://www.linkedin.com/feed?shareActive=true&text=Check%20out%20this%20fascinating%20article%20https%3A%2F%2Fwww.jmir.org%2F2024%2F1%2Fe60501 "Linkedin")

##  Career Opportunities 

[ Clinical Social Worker  California Correctional Health Care Services  Stockton, California ](https://careers.jmir.org/jobs/json/21157536/clinical-social-worker)

[ Clinical Social Worker  California Correctional Health Care Services  Susanville, California ](https://careers.jmir.org/jobs/json/21157524/clinical-social-worker)

[ Psychologist  California Correctional Health Care Services  Avenal, California ](https://careers.jmir.org/jobs/json/21157672/psychologist)

[ Psychiatrist  California Correctional Health Care Services  Crescent City, California ](https://careers.jmir.org/jobs/json/21157586/psychiatrist)

[ Psychologist  California Correctional Health Care Services  Represa, California ](https://careers.jmir.org/jobs/json/21157694/psychologist)

##  Journal of Medical Internet Research  ISSN 1438-8871 

###  Resource Centre 

  * [ Author Hub ](/resource-centre/author-hub)
  * [ Editor Hub ](/resource-centre/editor-hub)
  * [ Reviewer Hub ](/resource-centre/reviewer-hub)
  * [ Librarian Hub ](/resource-centre/librarian-hub)



###  Browse Journal 

  * [ Latest Announcements ](/announcements)
  * [ Authors ](/search/authors)
  * [ Themes ](/themes)
  * [ Issues ](/issues)
  * [ Blog ](https://blog.jmir.org )



###  About 

  * [ Privacy Statement ](/privacy-statement)
  * [ Contact Us ](/contact-us)
  * [ Sitemap ](/sitemap.xml)



###  Connect With Us 

[](https://bsky.app/profile/jmirpub.bsky.social  "Bluesky")[](https://twitter.com/jmirpub "Twitter")[](https://www.facebook.com/JMedInternetRes "Facebook")[](https://www.linkedin.com/company/jmir-publications "Linkedin")[](https://www.youtube.com/c/JMIRPublications "YouTube")[](https://www.instagram.com/jmirpub "Instagram") [](https://www.jmir.org/feed/atom "RSS Subscription")

###  Get Table of Contents Alerts 

[Get Alerts ](https://landingpage.jmirpublications.com/journal-preference-selection "Newsletter Subscription")

Copyright ©  2025  JMIR Publications 

[](javascript:; "Scroll to the top of the page")


url: https://medinform.jmir.org/2024/1/e55318
scrape_date: 2025-03-17T12:00:37.307439
content_type: markdown
hash: d70a0fb5d3cc9ef1cc68b4add4d1921d78d2f0f82e4a5cb20eeda227ebb1204f
title:
JMIR Medical Informatics - An Empirical Evaluation of Prompting Strategies for Large Language Models in Zero-Shot Clinical Natural Language Processing: Algorithm Development and Validation Study

content:
Skip to Main Content  Skip to Footer 

[![JMIR Publications](https://asset.jmir.pub/resources/images/logos/JMIR_logo.png)](https://jmirpublications.com)

Select options  Articles  Help 

  * [ Career Center ](https://careers.jmir.org/)
  * [Login](javascript:;)
  * Register



  * [ JMIR Medical Informatics ](/)

    * [Journal of Medical Internet Research 9502 articles ](https://www.jmir.org)
    * [JMIR Research Protocols 4498 articles ](https://www.researchprotocols.org)
    * [JMIR Formative Research 3332 articles ](https://formative.jmir.org)
    * [JMIR mHealth and uHealth 2764 articles ](https://mhealth.jmir.org)
    * [Online Journal of Public Health Informatics 1723 articles ](https://ojphi.jmir.org)
    * [JMIR Public Health and Surveillance 1713 articles ](https://publichealth.jmir.org)
    * [JMIR Medical Informatics 1474 articles ](/)
    * [JMIR Mental Health 1119 articles ](https://mental.jmir.org)
    * [JMIR Human Factors 881 articles ](https://humanfactors.jmir.org)
    * [JMIR Serious Games 673 articles ](https://games.jmir.org)
    * [JMIR Medical Education 597 articles ](https://mededu.jmir.org)
    * [Iproceedings 510 articles ](https://www.iproc.org)
    * [JMIR Aging 477 articles ](https://aging.jmir.org)
    * [JMIRx Med 468 articles ](https://xmed.jmir.org)
    * [Interactive Journal of Medical Research 467 articles ](https://www.i-jmr.org)
    * [JMIR Pediatrics and Parenting 443 articles ](https://pediatrics.jmir.org)
    * [JMIR Cancer 434 articles ](https://cancer.jmir.org)
    * [JMIR Dermatology 319 articles ](https://derma.jmir.org)
    * [JMIR Diabetes 278 articles ](https://diabetes.jmir.org)
    * [JMIR Rehabilitation and Assistive Technologies 275 articles ](https://rehab.jmir.org)
    * [JMIR Cardio 213 articles ](https://cardio.jmir.org)
    * [JMIR Infodemiology 169 articles ](https://infodemiology.jmir.org)
    * [JMIR AI 135 articles ](https://ai.jmir.org)
    * [JMIR Perioperative Medicine 124 articles ](https://periop.jmir.org)
    * [JMIR Nursing 120 articles ](https://nursing.jmir.org)
    * [Journal of Participatory Medicine 107 articles ](https://jopm.jmir.org)
    * [JMIR Biomedical Engineering 96 articles ](https://biomedeng.jmir.org)
    * [JMIR Bioinformatics and Biotechnology 54 articles ](https://bioinform.jmir.org)
    * [Asian/Pacific Island Nursing Journal 31 articles ](https://apinj.jmir.org)
    * [JMIR Neurotechnology 27 articles ](https://neuro.jmir.org)
    * [Medicine 2.0 26 articles ](https://www.medicine20.com)
    * [JMIRx Bio 26 articles ](https://xbio.jmir.org)
    * [JMIR XR and Spatial Computing (JMXR) 25 articles ](https://xr.jmir.org)
    * [JMIR Data ](https://data.jmir.org)
    * [JMIR Challenges ](https://challenges.jmir.org)
    * [JMIR Preprints ](https://preprints.jmir.org)
  * Journal Information 
    * [ Focus and Scope ](/about-journal/focus-and-scope)
    * [ Editorial Board ](/about-journal/editorial-board)
    * [ Author Information ](/author-information/instructions-for-authors)
    * [ Resource Center ](/resource-centre/author-hub)
    * [ Article Processing Fees ](/about-journal/article-processing-fees)
    * [ Publishing Policies ](/publishing-policies/section-policies)
    * [ Get Involved ](/get-involved/new-journal-editor-in-chief-proposals)
    * [ Top Articles ](/top-articles/overview)
    * [ Institutional Partners ](/fees/institutional-partners)
    * [ Indexing and Impact Factor ](/about-journal/indexing-and-impact-factor)
  * Browse Journal 
    * Year:  Select...  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025 

    * [ Latest Announcements ](/announcements)
    * [ Authors ](/search/authors)
    * [ Themes ](/themes)
    * [ Issues ](/issues)
    * [ Blog ](https://blog.jmir.org/)
  * [Submit Article](/author)



  * [ JMIR Medical Informatics ](/)

    * [Journal of Medical Internet Research 9502 articles ](https://www.jmir.org)
    * [JMIR Research Protocols 4498 articles ](https://www.researchprotocols.org)
    * [JMIR Formative Research 3332 articles ](https://formative.jmir.org)
    * [JMIR mHealth and uHealth 2764 articles ](https://mhealth.jmir.org)
    * [Online Journal of Public Health Informatics 1723 articles ](https://ojphi.jmir.org)
    * [JMIR Public Health and Surveillance 1713 articles ](https://publichealth.jmir.org)
    * [JMIR Medical Informatics 1474 articles ](/)
    * [JMIR Mental Health 1119 articles ](https://mental.jmir.org)
    * [JMIR Human Factors 881 articles ](https://humanfactors.jmir.org)
    * [JMIR Serious Games 673 articles ](https://games.jmir.org)
    * [JMIR Medical Education 597 articles ](https://mededu.jmir.org)
    * [Iproceedings 510 articles ](https://www.iproc.org)
    * [JMIR Aging 477 articles ](https://aging.jmir.org)
    * [JMIRx Med 468 articles ](https://xmed.jmir.org)
    * [Interactive Journal of Medical Research 467 articles ](https://www.i-jmr.org)
    * [JMIR Pediatrics and Parenting 443 articles ](https://pediatrics.jmir.org)
    * [JMIR Cancer 434 articles ](https://cancer.jmir.org)
    * [JMIR Dermatology 319 articles ](https://derma.jmir.org)
    * [JMIR Diabetes 278 articles ](https://diabetes.jmir.org)
    * [JMIR Rehabilitation and Assistive Technologies 275 articles ](https://rehab.jmir.org)
    * [JMIR Cardio 213 articles ](https://cardio.jmir.org)
    * [JMIR Infodemiology 169 articles ](https://infodemiology.jmir.org)
    * [JMIR AI 135 articles ](https://ai.jmir.org)
    * [JMIR Perioperative Medicine 124 articles ](https://periop.jmir.org)
    * [JMIR Nursing 120 articles ](https://nursing.jmir.org)
    * [Journal of Participatory Medicine 107 articles ](https://jopm.jmir.org)
    * [JMIR Biomedical Engineering 96 articles ](https://biomedeng.jmir.org)
    * [JMIR Bioinformatics and Biotechnology 54 articles ](https://bioinform.jmir.org)
    * [Asian/Pacific Island Nursing Journal 31 articles ](https://apinj.jmir.org)
    * [JMIR Neurotechnology 27 articles ](https://neuro.jmir.org)
    * [Medicine 2.0 26 articles ](https://www.medicine20.com)
    * [JMIRx Bio 26 articles ](https://xbio.jmir.org)
    * [JMIR XR and Spatial Computing (JMXR) 25 articles ](https://xr.jmir.org)
    * [JMIR Data ](https://data.jmir.org)
    * [JMIR Challenges ](https://challenges.jmir.org)
    * [JMIR Preprints ](https://preprints.jmir.org)



##  This paper is in the following e-collection/theme issue:

[ Natural Language Processing (764) ](/themes/171)[ Clinical Information and Decision Making (1548) ](/themes/67)[ Clinical Informatics (1107) ](/themes/58)[ Machine Learning (1627) ](/themes/500)[ Ontologies, Classifications, and Coding (256) ](/themes/235)[ Artificial Intelligence (1602) ](/themes/797)[ Tools, Programs and Algorithms (305) ](/themes/146)[ Natural Language Processing (26) ](/themes/1251)[ Chatbots and Conversational Agents (589) ](/themes/763)[ Generative Language Models Including ChatGPT (413) ](/themes/1437)

Published on 08.04.2024  in [ Vol 12 (2024)](/2024/1)

This is a member publication of [ University of Pittsburgh ](/fees/memberships/479)

Preprints (earlier versions) of this paper are available at <https://preprints.jmir.org/preprint/55318>, first published December 08, 2023. 

![An Empirical Evaluation of Prompting Strategies for Large Language Models in Zero-Shot Clinical Natural Language Processing: Algorithm Development and Validation Study](https://asset.jmir.pub/placeholder.svg)

# An Empirical Evaluation of Prompting Strategies for Large Language Models in Zero-Shot Clinical Natural Language Processing: Algorithm Development and Validation Study

##  An Empirical Evaluation of Prompting Strategies for Large Language Models in Zero-Shot Clinical Natural Language Processing: Algorithm Development and Validation Study 

Authors of this article: 

[ Sonish Sivarajkumar1 ](/search?term=Sonish%20Sivarajkumar&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0003-4173-1988) ; [ Mark Kelley2 ](/search?term=Mark%20Kelley&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0009-0003-9436-5595) ; [ Alyssa Samolyk-Mazzanti2 ](/search?term=Alyssa%20Samolyk-Mazzanti&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0009-0005-0081-5183) ; [ Shyam Visweswaran1, 3 ](/search?term=Shyam%20Visweswaran&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0002-2079-8684) ; [ Yanshan Wang1, 2, 3 ](/search?term=Yanshan%20Wang&type=author&precise=true&authorlink=true) [![Author Orcid Image](https://asset.jmir.pub/assets/static/images/Orcid-ID-Logo-Colour.png)](https://orcid.org/0000-0003-4433-7839)

[ Article ](/2024/1/e55318/)[ Authors ](/2024/1/e55318/authors)[ Cited by (23) ](/2024/1/e55318/citations)[ Tweetations (4) ](/2024/1/e55318/tweetations)[ Metrics ](/2024/1/e55318/metrics)




#### Original Paper

  * [Sonish Sivarajkumar1, BS](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Sonish+Sivarajkumar)[ ](https://orcid.org/0000-0003-4173-1988 "ORCID");
  * [Mark Kelley2, MS](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Mark+Kelley)[ ](https://orcid.org/0009-0003-9436-5595 "ORCID");
  * [Alyssa Samolyk-Mazzanti2, MS](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Alyssa+Samolyk-Mazzanti)[ ](https://orcid.org/0009-0005-0081-5183 "ORCID");
  * [Shyam Visweswaran1,3, MD, PhD](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Shyam+Visweswaran)[ ](https://orcid.org/0000-0002-2079-8684 "ORCID");
  * [Yanshan Wang1,2,3, PhD](/search/searchResult?field%5B%5D=author&criteria%5B%5D=Yanshan+Wang)[ ](https://orcid.org/0000-0003-4433-7839 "ORCID")



1Intelligent Systems Program, University of Pittsburgh, Pittsburgh, PA, United States

2Department of Health Information Management, University of Pittsburgh, Pittsburgh, PA, United States

3Department of Biomedical Informatics, University of Pittsburgh, Pittsburgh, PA, United States

### Corresponding Author:

Yanshan Wang, PhD

Department of Health Information Management

University of Pittsburgh

6026 Forbes Tower

Pittsburgh, PA, 15260

United States

Phone: 1 4123832712

Email: [yanshan.wang@pitt.edu](mailto:yanshan.wang@pitt.edu)

  


### Abstract

Background: Large language models (LLMs) have shown remarkable capabilities in natural language processing (NLP), especially in domains where labeled data are scarce or expensive, such as the clinical domain. However, to unlock the clinical knowledge hidden in these LLMs, we need to design effective prompts that can guide them to perform specific clinical NLP tasks without any task-specific training data. This is known as in-context learning, which is an art and science that requires understanding the strengths and weaknesses of different LLMs and prompt engineering approaches.  


Objective: The objective of this study is to assess the effectiveness of various prompt engineering techniques, including 2 newly introduced types--heuristic and ensemble prompts, for zero-shot and few-shot clinical information extraction using pretrained language models.  


Methods: This comprehensive experimental study evaluated different prompt types (simple prefix, simple cloze, chain of thought, anticipatory, heuristic, and ensemble) across 5 clinical NLP tasks: clinical sense disambiguation, biomedical evidence extraction, coreference resolution, medication status extraction, and medication attribute extraction. The performance of these prompts was assessed using 3 state-of-the-art language models: GPT-3.5 (OpenAI), Gemini (Google), and LLaMA-2 (Meta). The study contrasted zero-shot with few-shot prompting and explored the effectiveness of ensemble approaches.  


Results: The study revealed that task-specific prompt tailoring is vital for the high performance of LLMs for zero-shot clinical NLP. In clinical sense disambiguation, GPT-3.5 achieved an accuracy of 0.96 with heuristic prompts and 0.94 in biomedical evidence extraction. Heuristic prompts, alongside chain of thought prompts, were highly effective across tasks. Few-shot prompting improved performance in complex scenarios, and ensemble approaches capitalized on multiple prompt strengths. GPT-3.5 consistently outperformed Gemini and LLaMA-2 across tasks and prompt types.  


Conclusions: This study provides a rigorous evaluation of prompt engineering methodologies and introduces innovative techniques for clinical information extraction, demonstrating the potential of in-context learning in the clinical domain. These findings offer clear guidelines for future prompt-based clinical NLP research, facilitating engagement by non-NLP experts in clinical NLP advancements. To the best of our knowledge, this is one of the first works on the empirical evaluation of different prompt engineering approaches for clinical NLP in this era of generative artificial intelligence, and we hope that it will inspire and inform future research in this area.  


**JMIR Med Inform 2024;12:e55318**  
  
[doi:10.2196/55318](https://doi.org/10.2196/55318)  
  


### Keywords

[large language model](/search?type=keyword&term=large language model&precise=true); [LLM](/search?type=keyword&term=LLM&precise=true); [LLMs](/search?type=keyword&term=LLMs&precise=true); [natural language processing](/search?type=keyword&term=natural language processing&precise=true); [NLP](/search?type=keyword&term=NLP&precise=true); [in-context learning](/search?type=keyword&term=in-context learning&precise=true); [prompt engineering](/search?type=keyword&term=prompt engineering&precise=true); [evaluation](/search?type=keyword&term=evaluation&precise=true); [zero-shot](/search?type=keyword&term=zero-shot&precise=true); [few shot](/search?type=keyword&term=few shot&precise=true); [prompting](/search?type=keyword&term=prompting&precise=true); [GPT](/search?type=keyword&term=GPT&precise=true); [language model](/search?type=keyword&term=language model&precise=true); [language](/search?type=keyword&term=language&precise=true); [models](/search?type=keyword&term=models&precise=true); [machine learning](/search?type=keyword&term=machine learning&precise=true); [clinical data](/search?type=keyword&term=clinical data&precise=true); [clinical information](/search?type=keyword&term=clinical information&precise=true); [extraction](/search?type=keyword&term=extraction&precise=true); [BARD](/search?type=keyword&term=BARD&precise=true); [Gemini](/search?type=keyword&term=Gemini&precise=true); [LLaMA-2](/search?type=keyword&term=LLaMA-2&precise=true); [heuristic](/search?type=keyword&term=heuristic&precise=true); [prompt](/search?type=keyword&term=prompt&precise=true); [prompts](/search?type=keyword&term=prompts&precise=true); [ensemble](/search?type=keyword&term=ensemble&precise=true)

  
  


### Introduction

Clinical information extraction (IE) is the task of identifying and extracting relevant information from clinical narratives, such as clinical notes, radiology reports, or pathology reports. Clinical IE has many applications in health care, such as improving diagnosis, treatment, and decision-making; facilitating clinical research; and enhancing patient care [1,2]. However, clinical IE faces several challenges, such as the scarcity and heterogeneity of annotated data, the complexity and variability of clinical language, and the need for domain knowledge and expertise.

Zero-shot IE is a promising paradigm that aims to overcome these challenges by leveraging large pretrained language models (LMs) that can perform IE tasks without any task-specific training data [3]. In-context learning is a framework for zero-shot and few-shot learning, where a large pretrained LM takes a context and directly decodes the output without any retraining or fine-tuning [4]. In-context learning relies on prompt engineering, which is the process of crafting informative and contextually relevant instructions or queries as inputs to LMs to guide their output for specific tasks [5]. The use of prompt engineering lies in its ability to leverage the powerful capabilities of large LMs (LLMs), such as GPT-3.5 (OpenAI) [6], Gemini (Google) [7], LLaMA-2 (Meta) [8], even in scenarios where limited or no task-specific training data are available. In clinical natural language processing (NLP), where labeled data sets tend to be scarce, expensive, and time-consuming to create, splintered across institutions, and constrained by data use agreements, prompt engineering becomes even more crucial to unlock the potential of state-of-the-art LLMs for clinical NLP tasks.

While prompt engineering has been widely explored for general NLP tasks, its application and impact in clinical NLP remain relatively unexplored. Most of the existing literature on prompt engineering in the health care domain focuses on biomedical NLP tasks rather than clinical NLP tasks that involve processing real-world clinical notes. For instance, Chen et al [9] used a fixed template as the prompt to measure the performance of LLMs on biomedical NLP tasks but did not investigate different kinds of prompting methods. Wang et al [10] gave a comprehensive survey of prompt engineering for health care NLP applications such as question-answering systems, text summarization, and machine translation. However, they did not compare and evaluate different types of prompts for specific clinical NLP tasks and how the performance varies across different LLMs. There is a lack of systematic and comprehensive studies on how to engineer prompts for clinical NLP tasks, and the existing literature predominantly focuses on general NLP problems. This creates a notable gap in the research, warranting a dedicated investigation into the design and development of effective prompts specifically for clinical NLP. Currently, researchers in the field lack a comprehensive understanding of the types of prompts that exist, their relative effectiveness, and the challenges associated with their implementation in clinical settings.

The main research question and objectives of this study are to investigate how to engineer prompts for clinical NLP tasks, identify best practices, and address the challenges in this emerging field. By doing so, we aim to propose a guideline for future prompt-based clinical NLP studies. In this work, we present a comprehensive empirical evaluation study on prompt engineering for 5 diverse clinical NLP tasks, namely, clinical sense disambiguation, biomedical evidence extraction, coreference resolution, medication status extraction, and medication attribute extraction [11,12]. By systematically evaluating different types of prompts proposed in recent literature, including prefix [13], cloze [14], chain of thought [15], and anticipatory prompts [16], we gain insights into their performance and suitability for each task. Two new types of prompting approaches were also introduced: (1) heuristic prompts and (2) ensemble prompts. The rationale behind these novel prompts is to leverage the existing knowledge and expertise in rule-based NLP, which has been prominent and has shown significant results in the clinical domain [17]. We hypothesize that heuristic prompts, which are based on rules derived from domain knowledge and linguistic patterns, can capture the salient features and constraints of the clinical IE tasks. We also conjecture that ensemble prompts, which are composed of multiple types of prompts, can benefit from the complementary strengths and mitigate the weaknesses of each individual prompt.

One of the key aspects of prompt engineering is the number of examples or shots that are provided to the model along with the prompt. Few-shot prompting is a technique that provides the model with a few examples of input-output pairs, while zero-shot prompting does not provide any examples [3,18]. By contrasting these strategies, we aim to shed light on the most efficient and effective ways to leverage prompt engineering in clinical NLP. Finally, we propose a prompt engineering framework to build and deploy zero-shot NLP models for the clinical domain. This study covers 3 state-of-the-art LMs, including GPT-3.5, Gemini, and LLaMA-2, to assess the generalizability of the findings across various models. This work yields novel insights and guidelines for prompt engineering specifically for clinical NLP tasks.

  


### Methods

#### Tasks

We selected 5 distinct clinical NLP tasks representing diverse categories of natural language understanding: clinical sense disambiguation (text classification) [19], biomedical evidence extraction (named entity recognition) [20], coreference resolution [21], medication status extraction (named entity recognition+classification) [22], and medication attribute extraction (named entity recognition+relation extraction) [23]. Table 1 provides a succinct overview of each task, an example scenario, and the corresponding prompt type used for each task.

**Table 1.** Task descriptions.Task| NLPa task category| Description| Example prompt  
---|---|---|---  
Clinical sense disambiguation| Text classification| This task involves identifying the correct meaning of clinical abbreviations within a given context.| What is the meaning of the abbreviation CRb in the context of cardiology?  
Biomedical evidence extraction| Text extraction| In this task, interventions are extracted from biomedical abstracts.| Identify the psychological interventions in the given text?  
Coreference resolution| Coreference resolution| The goal here is to identify all mentions in clinical text that refer to the same entity.| Identify the antecedent for the patient in the clinical note.  
Medication status extraction| NERc+classification| This task involves identifying whether a medication is currently being taken, not taken, or unknown.| What is the current status of [24] in the treatment of [25]?  
Medication attribute extraction| NER+REd| The objective here is to identify specific attributes of a medication, such as dosage and frequency.| What is the recommended dosage of [26] for [27] and how often?  
  
aNLP: natural language processing.

bCR: cardiac resuscitation.

cNER: named entity recognition.

dRE: relation extraction.

#### Data Sets and Evaluation

The prompts were evaluated on 3 LLMs, GPT-3.5, Gemini, and LLaMA-2, under both zero-shot and few-shot prompting conditions, using precise experimental settings and parameters. To simplify the evaluation process and facilitate clear comparisons, we adopted accuracy as the sole evaluation metric for all tasks. Accuracy is defined as the proportion of correct outputs generated by the LLM for each task, using a resolver that maps the output to the label space. Table 2 shows the data sets and sample size for each clinical NLP task. The data sets are as follows:

  * Clinical abbreviation sense inventories: This is a data set of clinical abbreviations, senses, and instances [28]. It contains 41 acronyms from 18,164 notes, along with their expanded forms and contexts. We used a randomly sampled subset from this data set for clinical sense disambiguation, coreference resolution, medication status extraction, and medication attribute extraction tasks (Table 2).
  * Evidence-based medicine-NLP: This is a data set of evidence-based medicine annotations for NLP [29]. It contains 187 abstracts and 20 annotated abstracts, with interventions extracted from the text. We used this data set for the biomedical evidence extraction task.



**Table 2.** Evaluation data sets and samples for different tasks.Task| Data set| Data set example| Samples  
---|---|---|---  
Clinical sense disambiguation| CASIa| The abbreviation "CRb" can refer to "cardiac resuscitation" or "computed radiography."| 11 acronyms from 55 notes  
Biomedical evidence extraction| EBMc-NLPd| Identifying panic, avoidance, and agoraphobia (psychological interventions)| 187 abstracts and 20 annotated abstracts  
Coreference resolution| CASI| Resolving references to "the patient" or "the study" within a clinical trial report.| 105 annotated examples  
Medication status extraction| CASI| Identifying that a patient is currently taking insulin for diabetes.| 105 annotated examples with 340 medication status pairs  
Medication attribute extraction| CASI| Identifying dosage, frequency, and route of a medication for a patient.| 105 annotated examples with 313 medications and 533 attributes  
  
aCASI: clinical abbreviation sense inventories.

bCR: cardiac resuscitation.

cEBM: evidence-based medicine.

dNLP: natural language processing.

All experiments were carried out in different system settings. All GPT-3.5 experiments were conducted using the GPT-3.5 Turbo application programming interface as of the September 2023 update. The LLaMA-2 model was directly accessed for our experiments. Gemini was accessed using the Gemini application (previously BARD)--Google's generative artificial intelligence conversational system. These varied system settings and access methods were taken into account to ensure the reliability and validity of our experimental results, given the differing architectures and capabilities of each LLM.

In evaluating the prompt-based approaches on GPT-3.5, Gemini, and LLaMA-2, we have also incorporated traditional NLP baselines to provide a comprehensive understanding of the LLMs' performance in a broader context. These baselines include well-established models such as Bidirectional Encoder Representations From Transformers (BERT) [30], Embeddings From Language Models (ELMO) [31], and PubMedBERT-Conditional Random Field (PubMedBERT-CRF) [32], which have previously set the standard in clinical NLP tasks. By comparing the outputs of LLMs against these baselines, we aim to offer a clear perspective on the advancements LLMs represent in the field. This comparative analysis is crucial for appreciating the extent to which prompt engineering techniques can leverage the inherent capabilities of LLMs, marking a significant evolution from traditional approaches to more dynamic and contextually aware methodologies in clinical NLP.

#### Prompt Creation Process

A rigorous process was followed to create suitable prompts for each task. These prompts were carefully crafted to match the specific context and objectives of each task. There is no established method for prompt design and selection as of now. Therefore, we adopted an iterative approach where prompts, which are created by health care experts, go through a verification and improvement process in an iterative cycle, which involved design, experimentation, and evaluation, as depicted in Figure 1.

[![](https://asset.jmir.pub/assets/9ec1a17ab387ef2369ff2bd9e10f169c.png)](https://asset.jmir.pub/assets/9ec1a17ab387ef2369ff2bd9e10f169c.png "Figure 1. Iterative prompt design process: a schematic diagram of the iterative prompt creation process for clinical NLP tasks. The process consists of 3 steps: sampling, prompt designing, and deployment. The sampling step involves defining the task and collecting data and annotations. The prompt designing step involves creating and refining prompts using different types and language models. The deployment step involves selecting the best model and deploying the model for clinical use. LLM: large language model; NER: named entity recognition; NLP: natural language processing; RE: relation extraction.")**Figure 1.** Iterative prompt design process: a schematic diagram of the iterative prompt creation process for clinical NLP tasks. The process consists of 3 steps: sampling, prompt designing, and deployment. The sampling step involves defining the task and collecting data and annotations. The prompt designing step involves creating and refining prompts using different types and language models. The deployment step involves selecting the best model and deploying the model for clinical use. LLM: large language model; NER: named entity recognition; NLP: natural language processing; RE: relation extraction. 

Figure 1 illustrates the 3 main steps of our prompt creation process: sampling, prompt designing, and deployment. In the sampling step (step 1), we defined the clinical NLP task (eg, named entity recognition, relation extraction, and text classification) and collected a sample of data and annotations as an evaluation for the task. In the prompt designing step (step 2), a prompt was designed for the task using one of the prompt types (eg, simple prefix prompt, simple cloze prompt, heuristic prompt, chain of thought prompt, question prompt, and anticipatory prompt). We also optionally performed few-shot prompting by providing some examples along with the prompt. The LLMs and the evaluation metrics for the experiment setup were then configured. We ran experiments with various prompt types and LLMs and evaluated their performance on the task. Based on the results, we refined or modified the prompt design until we achieved satisfactory performance or reached a limit. In the deployment step (step 3), the best prompt-based models were selected based on their performance metrics, and the model was deployed for the corresponding task.

#### Prompt Engineering Techniques

##### Overview

Prompt engineering is the process of designing and creating prompts that elicit desired responses from LLMs. Prompts can be categorized into different types based on their structure, function, and complexity.

Each prompt consists of a natural language query that is designed to elicit a specific response from the pretrained LLM. The prompts are categorized into 7 types, as illustrated in Figure 2 (all prompts have been included in Multimedia Appendix 1). Prefix prompts are the simplest type of prompts, which prepend a word or phrase indicating the type or format or tone of response for control and relevance. Cloze prompts are based on the idea of fill in the blank exercises, which create a masked token in the input text and ask the LLM to predict the missing word or phrase [3]. Anticipatory prompts are the prompts anticipating the next question or command based on experience or knowledge, guiding the conversation. Chain of thought prompting involves a series of intermediate natural language reasoning steps that lead to the final output [15].

In addition to the existing types of prompts, 2 new novel prompts were also designed: heuristic prompts and ensemble prompts, which will be discussed in the following sections.

[![](https://asset.jmir.pub/assets/a8d187beec29e94f418c040d250db68e.png)](https://asset.jmir.pub/assets/a8d187beec29e94f418c040d250db68e.png "Figure 2. Types of prompts: examples of 7 types of prompts that we used to query the pretrained language model for different clinical information extraction tasks. \[X\]: context; \[Y\]: abbreviation; \[Z\]: expanded form.")**Figure 2.** Types of prompts: examples of 7 types of prompts that we used to query the pretrained language model for different clinical information extraction tasks. [X]: context; [Y]: abbreviation; [Z]: expanded form. 

##### Heuristic Prompts

Heuristic prompts are rule-based prompts that decompose complex queries into smaller, more manageable components for comprehensive answers. Adopting the principles of traditional rule-based NLP, which relies on manually crafted, rule-based algorithms for specific clinical NLP applications, we have integrated these concepts into our heuristic prompts approach. These prompts use a set of predefined rules to guide the LLM in expanding abbreviations within a given context. For instance, a heuristic prompt might use the rule that an abbreviation is typically capitalized, followed by a period, and preceded by an article or a noun. This approach contrasts with chain of thought prompts, which focus on elucidating the reasoning or logic behind an output. Instead, heuristic prompts leverage a series of predefined rules to direct the LLM in executing a specific task.

Mathematically, we can express a heuristic prompt as _H_(_x_), a function applied to an input sequence _x_. This function is defined as a series of rule-based transformations _T i_, where _i_ indicates the specific rule applied. The output of this function, denoted as _y H_, is then:

> yH=H(x)=Tn(T{n-1}(... T1(x)))

Here, each transformation _T i_ applies a specific heuristic rule to modify the input sequence, making it more suitable for processing by LLMs.

From an algorithmic standpoint, heuristic prompts are implemented by defining a set of rules _R={R 1, R2, ..., Rm_}. Each rule _R j_ is a function that applies a specific heuristic criterion to an input token or sequence of tokens. Algorithmically, the heuristic prompting process can be summarized as follows:

> ![](https://asset.jmir.pub/assets/07d75725ec9498f05c0da2ff262e7285.png)

By merging the precision and specificity of traditional rule-based NLP methods with the advanced capabilities of LLMs, the heuristic prompts offer a robust and accurate system for clinical information processing and analysis.

##### Ensemble Prompts

Ensemble prompts are prompts that combine multiple prompts using majority voting for aggregated outputs. They use various types of prompts to generate multiple responses to the same input, subsequently selecting the most commonly occurring output as the final answer. For instance, an ensemble prompt might use 3 different prefix prompts, or a combination of other prompt types, to produce 3 potential expansions for an abbreviation. The most frequently appearing expansion is then chosen. For the sake of simplicity, we amalgamated the outputs from all 5 different prompt types using a majority voting approach.

Mathematically, consider a set of _m_ different prompting methods _P_ 1, _P_ 2, ..., _P m_ applied to the same input _x_. Each method generates an output _y i_ for _i_ =1,2, ..., _m_. The ensemble prompt's output _y E_ is then the mode of these outputs:

_y E_=mode (_y_ 1, _y_ 2, ..., _y m_)

Algorithmically, the ensemble prompting process is as follows:

> ![](https://asset.jmir.pub/assets/2e6998f66e256be484714db1f721c342.png)

The rationale behind an ensemble prompt is that by integrating multiple types of prompts, we can use the strengths and counterbalance the weaknesses of each individual prompt, offering a robust and potentially more accurate response. Some prompts may be more effective for specific tasks or models, while others might be more resilient to noise or ambiguity. Majority voting allows us to choose the most likely correct or coherent output from the variety generated by different prompt types.

  


### Results

#### Overview

In this section, we present the results of our experiments on prompt engineering for zero-shot clinical IE. Various prompt types were evaluated across 5 clinical NLP tasks, aiming to understand how different prompts influence the accuracy of different LLMs. Zero-shot and few-shot prompting strategies were also compared, exploring how the addition of context affects the model performance. Furthermore, we tested an ensemble approach that combines the outputs of different prompt types using majority voting. Finally, the impact of different LLMs on task performance was analyzed, and some interesting patterns were observed. Table 3 illustrates that different prompt types have different levels of effectiveness for different tasks and LLMs. We can also observe some general trends across the tasks and models.

**Table 3.** Performance comparison of different prompt types and language models.Task and language model| Simple prefix| Simple cloze| Anticipatory| Heuristic| Chain of thought| Ensemble| Few shot  
---|---|---|---|---|---|---|---  
**Clinical sense disambiguation**  
  
|  GPT-3.5| 0.88| 0.86| 0.88| 0.96a| 0.9| 0.9| 0.82  
  
| Gemini| 0.76b| 0.68| 0.71| 0.75| 0.72| 0.71| 0.67  
  
| LLaMA-2| 0.88b| 0.76| 0.82| 0.82| 0.78| 0.82| 0.78  
  
| BERTc (from [33])| 0.42| 0.42| 0.42| 0.42| 0.42| 0.42| 0.42  
  
| ELMOd (from [33])| 0.55| 0.55| 0.55| 0.55| 0.55| 0.55| 0.55  
**Biomedical evidence extraction**  
  
|  GPT-3.5| 0.92| 0.82| 0.88| 0.94| 0.94| 0.88| 0.96a  
  
| Gemini| 0.89| 0.89| 0.91b| 0.9| 0.91b| 0.9| 0.88  
  
| LLaMA-2| 0.85| 0.88b| 0.87| 0.88b| 0.87| 0.88| 0.86  
  
| PubMedBERT-CRFe (from [29])| 0.35| 0.35| 0.35| 0.35| 0.35| 0.35| 0.35  
**Coreference resolution**  
  
|  GPT-3.5| 0.78| 0.6| 0.74| 0.94a| 0.94a| 0.74| 0.74  
  
| Gemini| 0.69| 0.81b| 0.73| 0.67| 0.71| 0.69| 0.7  
  
| LLaMA-2| 0.8b| 0.64| 0.74| 0.76| 0.8b| 0.78| 0.68  
  
| Toshniwal et al [34]| 0.69| 0.69| 0.69| 0.69| 0.69| 0.69| 0.69  
**Medication status extraction**  
  
|  GPT-3.5| 0.76a| 0.72| 0.75| 0.74| 0.73| 0.75| 0.72  
  
| Gemini| 0.67b| 0.51| 0.65| 0.55| 0.59| 0.58| 0.55  
  
| LLaMA-2| 0.58| 0.48| 0.52| 0.64b| 0.52| 0.58| 0.42  
  
| ScispaCy [35]| 0.52| 0.52| 0.52| 0.52| 0.52| 0.52| 0.52  
**Medication attribute extraction**  
  
|  GPT-3.5| 0.88| 0.84| 0.9| 0.96a| 0.96a| 0.9| 0.96a  
  
| Gemini| 0.68| 0.72| 0.88c| 0.7| 0.74| 0.76| 0.88b  
  
| LLaMA-2| 0.6| 0.66| 0.58| 0.66| 0.72b| 0.64| 0.6  
  
| ScispaCy| 0.70| 0.70| 0.70| 0.70| 0.70| 0.70| 0.70  
  
aBest performance on a task regardless of the model (ie, for each GPT-3.5 or Gemini or LLaMA-2 triple).

bBest performance for each model on a task.

cBERT: Bidirectional Encoder Representations From Transformers.

dELMO: Embeddings From Language Models.

ePubMedBERT-CRF: PubMedBERT-Conditional Random Field.

#### Prompt Optimization and Evaluation

For clinical sense disambiguation, the heuristic and prefix prompts consistently achieved the highest performance across all LLMs, significantly outperforming baselines such as BERT [30] and ELMO, with GPT-3.5 achieving an accuracy of 0.96, showcasing its advanced understanding of clinical context using appropriate prompting strategies. For biomedical evidence extraction, the heuristic and chain of thought prompts excelled across all LLMs in zero-shot setting. This indicates that these prompt types were able to provide enough information and constraints for the model to extract the evidence from the clinical note. GPT-3.5 achieved an accuracy of 0.94 with these prompt types, which was higher than any other model or prompt type combination. For coreference resolution, the chain of thought prompt type performed best among all prompt types with 2 LLMs--GPT-3.5 and LLaMA-2. This indicates that this prompt type was able to provide enough structure and logic for the model to resolve the coreference in the clinical note. GPT-3.5 displayed high accuracy with this prompt type, achieving an accuracy of 0.94. For medication status extraction, simple prefix and heuristic prompts yielded good results across all LLMs. These prompt types were able to provide enough introduction or rules for the model to extract the status of the medication in relation to the patient or condition. GPT-3.5 excelled with these prompt types, achieving an accuracy of 0.76 and 0.74, respectively. For medication attribute extraction, we found that the chain of thought and heuristic prompts were effective across all LLMs. These prompt types were able to provide enough reasoning or rules for the model to extract and label the attributes of medications from clinical notes. Anticipatory prompts, however, had the best accuracy for Gemini among all the prompts. GPT-3.5 achieved an accuracy of 0.96 with these prompt types, which was higher than any other model or prompt type combination.

Thus, we can see that task-specific prompt tailoring is crucial for achieving high accuracy. Different tasks require different levels of information and constraints to guide the LLM to produce the desired output. The experiments show that heuristic, prefix, and chain of thought prompts are generally very effective for guiding the LLM to produce clear and unambiguous outputs. As shown in Figure 3, it is clear that GPT-3.5 is a superior and versatile LLM that can handle various clinical NLP tasks in zero-shot settings, outperforming other models in most cases.

[![](https://asset.jmir.pub/assets/5deee853ac7b9709ba7c73b258f41972.png)](https://asset.jmir.pub/assets/5deee853ac7b9709ba7c73b258f41972.png "Figure 3. Graphical comparison of prompt types in the 5 clinical natural language processing tasks used in this study.")**Figure 3.** Graphical comparison of prompt types in the 5 clinical natural language processing tasks used in this study. 

Overall, the prompt-based approach has demonstrated remarkable superiority over traditional baseline models across all the 5 tasks. For clinical sense disambiguation, GPT-3.5's heuristic prompts achieved a remarkable accuracy of 0.96, showcasing a notable improvement over baselines such as BERT (0.42) and ELMO (0.55). In biomedical evidence extraction, GPT-3.5 again set a high standard with an accuracy of 0.94 using heuristic prompts, far surpassing the baseline performance of PubMedBERT-CRF at 0.35. Coreference resolution saw GPT-3.5 reaching an accuracy of 0.94 with chain of thought prompts, eclipsing the performance of existing methods such as Toshniwal et al [34] (0.69). In medication status extraction, GPT-3.5 outperformed the baseline ScispaCy (0.52) with an accuracy of 0.76 using simple prefix prompts. Finally, for medication attribute extraction, GPT-3.5's heuristic prompts achieved an impressive accuracy of 0.96, significantly higher than the ScispaCy baseline (0.70). These figures not only showcase the potential of LLMs in clinical settings but also set a foundation for future research to build upon, exploring even more sophisticated prompt engineering strategies and their implications for health care informatics.

#### Zero-Shot Versus Few-Shot Prompting

The performance of zero-shot prompting and few-shot prompting strategies was compared for each clinical NLP task. The same prompt types and LLMs were used as in the previous experiments, but some context was added to the input in the form of examples or explanations. Two examples or explanations were used for each task (2-shot) depending on the complexity and variability of the task. Table 3 shows that few-shot prompting consistently improved the accuracy of all combinations for all tasks except for clinical sense disambiguation and medication attribute extraction, where some zero-shot prompt types performed better. We also observed some general trends across the tasks and models.

We found that few-shot prompting enhanced accuracy by providing limited context that aided complex scenario understanding. The improvement was more pronounced compared to simple cloze prompts, which had lower accuracy in most of the tasks. We also found that some zero-shot prompt types were very effective for certain tasks, even outperforming few-shot prompting. These prompt types used a rule-based or reasoning approach to generate sentences that contained definitions or examples of the target words or concepts, which helped the LLM to understand and match the context. For example, heuristic prompts achieved higher accuracy than few-shot prompting for clinical sense disambiguation and medication attribute extraction, while chain of thought prompts achieved higher accuracy than few-shot prompting for coreference resolution and medication attribute extraction. Alternatively, the clinical evidence extraction task likely benefits from additional context provided by few-shot examples, which can guide the model more effectively than the broader inferences made in zero-shot scenarios. This suggests that tasks requiring deeper contextual understanding might be better suited to few-shot learning approaches.

From these results, we can infer that LLMs can be effectively used for clinical NLP in a no-data scenario, where we do not have many publicly available data sets, by using appropriate zero-shot prompt types that guide the LLM to produce clear and unambiguous outputs. However, few-shot prompting can also improve the performance of LLMs by providing some context that helps the LLM to handle complex scenarios.

#### Other Observations

##### Ensemble Approaches

We experimented with an ensemble approach by combining outputs from multiple prompts using majority voting. The ensemble approach was not the best-performing strategy for any of the tasks, but it was better than the low-performing prompts. The ensemble approach was able to benefit from the diversity and complementarity of different prompt types and avoid some of the pitfalls of individual prompts. For example, for clinical sense disambiguation, the ensemble approach achieved an accuracy of 0.9 with GPT-3.5, which was the second best-performing prompt type. Similarly, for medication attribute extraction, the ensemble approach achieved an accuracy of 0.9 with GPT-3.5 and 0.76 with Gemini, which were close to the best single prompt type (anticipatory). However, the ensemble approach also had some drawbacks, such as inconsistency and noise. For tasks that required more specific or consistent outputs, such as coreference resolution, the ensemble approach did not improve the accuracy over the best single prompt type and sometimes even decreased it. This suggests that the ensemble approach may introduce ambiguity for tasks that require more precise or coherent outputs.

While the ensemble approach aims to reduce the variance introduced by individual prompt idiosyncrasies, our specific implementation observed instances where the combination of diverse prompt types introduced additional complexity. This complexity occasionally manifested as inconsistency and noise in the outputs contrary to our objective of achieving higher performance. Future iterations of this approach may include refinement of the prompt selection process to enhance consistency and further reduce noise in the aggregated outputs.

##### Impact of LLMs

Variations in performance were observed among different LLMs (Table 3). We found that GPT-3.5 generally outperformed Gemini and LLaMA-2 on most tasks. This suggests that GPT-3.5 has a better generalization ability and can handle a variety of clinical NLP tasks with different prompt types. However, Gemini and LLaMA-2 also showed some advantages over GPT-3.5 on certain tasks and prompt types. For example, Gemini achieved the highest accuracy of 0.81 with simple cloze prompts and LLaMA-2 achieved the highest accuracy of 0.8 with simple prefix prompts for coreference resolution. This indicates that Gemini and LLaMA-2 may have some domain-specific knowledge that can benefit certain clinical NLP tasks for specific prompt types.

##### Persona Patterns

Persona patterns are a way of asking the LLM to act like a persona or a system that is relevant to the task or domain. For example, one can ask the LLM to "act as a clinical NLP expert." This can help the LLM to generate outputs that are more appropriate and consistent with the persona or system. For example, one can use the following prompt for clinical sense disambiguation:

> _Act as a clinical NLP expert. Disambiguate the word "cold" in the following sentence: "She had a cold for three days."  
>  _

We experimented with persona patterns for different tasks and LLMs and found that they can improve the accuracy and quality of the outputs. Persona patterns can help the LLM to focus on the relevant information and constraints for the task and avoid generating outputs that are irrelevant or contradictory to the persona or system.

##### Randomness in Output

Most LLMs do not produce the output in the same format every time. There is inherent randomness in the outputs the LLMs produce. Hence, the prompts need to be specific in the way they are done for the task. Prompts are powerful when they are specific and if we use them in the right way.

Randomness in output can be beneficial or detrimental for different tasks and scenarios. In the clinical domain, randomness can introduce noise and errors in the outputs, which can make them less accurate and reliable for the users. For example, for tasks that involve extracting factual information, such as biomedical evidence extraction and medication status extraction, randomness can cause the LM to produce outputs that are inconsistent or contradictory with the input or context.

#### Guidelines and Suggestions for Optimal Prompt Selection

In recognizing the evolving nature of clinical NLP, we expand our discussion to contemplate the adaptability of our recommended prompt types and LM combinations across a wider spectrum of clinical tasks and narratives. This speculative analysis aims to bridge the gap between our current findings and their applicability to unexplored clinical NLP challenges, setting a foundation for future research to validate and refine these recommendations. In this section, we synthesize the main findings from our experiments and offer some practical advice for prompt engineering for zero-shot and few-shot clinical IE. We propose the following steps for selecting optimal prompts for different tasks and scenarios:

The first step is to identify the type of clinical NLP task, which can be broadly categorized into three types: (1) classification, (2) extraction, and (3) resolution. Classification tasks involve assigning a label or category to a word, phrase, or sentence in a clinical note, such as clinical sense disambiguation or medication status extraction. Extraction tasks involve identifying and extracting relevant information from a clinical note, such as biomedical evidence extraction or medication attribute extraction. Resolution tasks involve linking or matching entities or concepts in a clinical note, such as coreference resolution.

The second step is to choose the prompt type that is most suitable for the task type. We found that different prompt types have different strengths and weaknesses for different task types, depending on the level of information and constraints they provide to the LLM. Table 4 summarizes our findings and recommendations for optimal prompt selection for each task type.

The third step is to choose the LLM that is most compatible with the chosen prompt type. We found that different LLMs have different capabilities and limitations for different prompt types, depending on their generalization ability and domain-specific knowledge. Table 5 summarizes our findings and recommendations for optimal LLM selection for each prompt type.

The fourth step is to evaluate the performance of the chosen prompt type and LLM combination on the clinical NLP task using appropriate metrics such as accuracy, precision, recall, or _F_ 1-score. If the performance is satisfactory, then the prompt engineering process is complete. If not, then the process can be repeated by choosing a different prompt type or LLM or by modifying the existing prompt to improve its effectiveness.

**Table 4.** Optimal prompt types for different clinical natural language processing task types.Task type| Prompt type  
---|---  
Classification| Heuristic or prefix  
Extraction| Heuristic or chain of thought  
Resolution| Chain of thought  
  
**Table 5.** Optimal language models for different prompt types.Prompt type| Language model  
---|---  
Heuristic| GPT-3.5  
Prefix| GPT-3.5 or LLaMA-2  
Cloze| Gemini or LLaMA-2  
Chain of thought| GPT-3.5  
Anticipatory| Gemini  
  
  


### Discussion

#### Principal Findings

In this paper, we have presented a novel approach to zero-shot and few-shot clinical IE using prompt engineering. Various prompt types were evaluated across 5 clinical NLP tasks: clinical sense disambiguation, biomedical evidence extraction, coreference resolution, medication status extraction, and medication attribute extraction. The performance of different LLMs, GPT-3.5, Gemini, and LLaMA-2, was also compared. Our main findings are as follows:

  1. Task-specific prompt tailoring is crucial for achieving high accuracy. Different tasks require different levels of information and constraints to guide the LLM to produce the desired output. Therefore, it is important to design prompts that are relevant and specific to the task at hand and avoid using generic or vague prompts that may confuse the model or lead to erroneous outputs.
  2. Heuristic prompts are generally very effective for guiding the LLM to produce clear and unambiguous outputs. These prompts use a rule-based approach to generate sentences that contain definitions or examples of the target words or concepts, which help the model to understand and match the context. Heuristic prompts are especially useful for tasks that involve disambiguation, extraction, or classification of entities or relations.
  3. Chain of thought prompts are also effective for guiding the LLM to produce logical and coherent outputs. These prompts use a multistep approach to generate sentences that contain a series of questions and answers that resolve the task in the context. Chain of thought prompts are especially useful for tasks that involve reasoning, inference, or coreference resolution.
  4. Few-shot prompting can improve the performance of LLMs by providing some context that helps the model to handle complex scenarios. Few-shot prompting can be done by adding some examples or explanations to the input depending on the complexity and variability of the task. Few-shot prompting can enhance accuracy by providing limited context that aids complex scenario understanding. The improvement is more pronounced compared to simple prefix and cloze prompts, which had lower accuracy in most of the tasks.
  5. Ensemble approaches can also improve the performance of LLMs by combining outputs from multiple prompts using majority voting. Ensemble approaches can leverage the strengths of each prompt type and reduce the errors of individual prompts. Ensemble approaches are especially effective for tasks that require multiple types of information or reasoning, such as biomedical evidence extraction and medication attribute extraction.



It is noteworthy that context size has a significant impact on the performance of LLMs in zero-shot IE [36]. In the scope of this study, we have avoided the context size dependence on performance, as it is a complex issue that requires careful consideration.

This study serves as an initial exploration into the efficacy of prompt engineering in clinical NLP, providing foundational insights rather than exhaustive guidelines. Given the rapid advancements in generative artificial intelligence and the complexity of clinical narratives, we advocate for continuous empirical testing of these prompt strategies across diverse clinical tasks and data sets. This approach will not only validate the generalizability of our findings but also uncover new avenues for enhancing the accuracy and applicability of LLMs in clinical settings.

#### Limitations

In this study, we primarily focused on exploring the capabilities and versatility of generative LLMs in the context of zero-shot and few-shot learning for clinical NLP tasks. Our approach also has some limitations that we acknowledge in this work. First, it relies on the quality and availability of pretrained LLMs, which may vary depending on the domain and task. As LLMs are rapidly evolving, some parts of the prompt engineering discipline may be timeless, while some parts may evolve and adapt over time as different capabilities of models evolve. Second, it requires a lot of experimentation and iteration to optimize prompts for different applications, which may be iterative and time-consuming. However, once optimal prompts are identified, the approach offers time savings in subsequent applications by reusing these prompts or making minor adjustments for similar tasks. We may not have explored all the possible combinations and variations of prompts that could potentially improve the performance of the clinical NLP tasks. Third, the LLMs do not release the details of the data set that they were trained on. Hence, the high accuracy could be because the models would have already seen the data during training and not because of the effectiveness of the prompts.

#### Future Work

We plan to address these challenges and limitations in our future work. We aim to develop more systematic and automated methods for prompt design and evaluation, such as using prompt-tuning or meta-learning techniques. We also aim to incorporate more domain knowledge or external resources into the prompts or the LLMs, such as using ontologies, knowledge graphs, or databases. We also aim to incorporate more quality control or error correction mechanisms into the prompts or the LLMs, such as using adversarial examples, confidence scores, or human feedback.

#### Conclusions

In this paper, we have benchmarked different prompt engineering techniques for both zero-shot and few-shot clinical NLP tasks. Two new types of prompts, heuristic and ensemble prompts, were also conceptualized and proposed. We have demonstrated that prompt engineering can enable the use of pretrained LMs for various clinical NLP tasks without requiring any fine-tuning or additional data. We have shown that task-specific prompt tailoring, heuristic prompts, chain of thought prompts, few-shot prompting, and ensemble approaches can improve the accuracy and quality of the outputs. We have also shown that GPT-3.5 is very adaptable and precise across all tasks and prompt types, while Gemini and LLaMA-2 may have some domain-specific advantages for certain tasks and prompt types.

We believe that a prompt-based approach has several benefits over existing methods for clinical IE. It reduces the cost and time in the initial phases of clinical NLP application development, where prompt-based methods offer a streamlined alternative to the conventional data preparation and model training processes. It is flexible and adaptable, as it can be applied to various clinical NLP tasks with different prompt types and LLMs. It is interpretable and explainable, as it uses natural language prompts that can be easily understood and modified by humans.

#### Acknowledgments

This work was supported by the National Institutes of Health (awards U24 TR004111 and R01 LM014306). The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health.

#### Authors' Contributions

SS conceptualized, designed, and organized this study; analyzed the results; and wrote, reviewed, and revised the paper. MK and AS-M analyzed the results, and wrote, reviewed, and revised the paper. SV wrote, reviewed, and revised the paper. YW conceptualized, designed, and directed this study and wrote, reviewed, and revised the paper.

#### Conflicts of Interest

None declared.

Multimedia Appendix 1

Prompts for clinical natural language processing tasks.

[DOCX File , 31 KB](https://jmir.org/api/download?alt_name=medinform_v12i1e55318_app1.docx&filename=f4ab9fa12e117d0ac403dfc9b7ff57ea.docx)

* * *

#### References

  1. Wang Y, Wang L, Rastegar-Mojarad M, Moon S, Shen F, Afzal N, et al. Clinical information extraction applications: a literature review. J Biomed Inform. 2018;77:34-49. [[FREE Full text](https://linkinghub.elsevier.com/retrieve/pii/S1532-0464\(17\)30256-3)] [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2017.11.011)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=29162496&dopt=Abstract)]
  2. Landolsi MY, Hlaoua L, Romdhane LB. Information extraction from electronic medical documents: state of the art and future research directions. Knowl Inf Syst. 2023;65(2):463-516. [[FREE Full text](https://europepmc.org/abstract/MED/36405956)] [[CrossRef](https://dx.doi.org/10.1007/s10115-022-01779-1)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=36405956&dopt=Abstract)]
  3. Sivarajkumar S, Wang Y. HealthPrompt: a zero-shot learning paradigm for clinical natural language processing. AMIA Annu Symp Proc. 2022;2022:972-981. [[FREE Full text](https://europepmc.org/abstract/MED/37128372)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=37128372&dopt=Abstract)]
  4. Min S, Lyu X, Holtzman A, Artetxe M, Lewis M, Hajishirzi H, et al. Rethinking the role of demonstrations: what makes in-context learning work? 2022. Presented at: Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing; December 7-11, 2022;11048-11064; Abu Dhabi, United Arab Emirates. URL: <https://aclanthology.org/2022.emnlp-main.759/> [[CrossRef](https://dx.doi.org/10.18653/v1/2022.emnlp-main.759)]
  5. White J, Fu Q, Hays S, Sandborn M, Olea C, Gilbert H, et al. A prompt pattern catalog to enhance prompt engineering with chatGPT. ArXiv. Preprint posted online on February 21, 2023. [[FREE Full text](https://arxiv.org/abs/2302.11382)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2302.11382)]
  6. Ouyang L, Wu J, Jiang X, Almeida D, Wainwright C, Mishkin P, et al. Training language models to follow instructions with human feedback. In: Koyejo S, Mohamed S, Agarwal A, Belgrave D, Cho K, Oh A, editors. Advances in Neural Information Processing Systems 35 (NeurIPS 2022). Red Hook, NY. Curran Associates, Inc; 2022;27730-27744.
  7. Gemini Team Google. Gemini: a family of highly capable multimodal models. ArXiv. Preprint posted online on December 19, 2023. [[FREE Full text](https://arxiv.org/abs/2312.11805)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2312.11805)]
  8. Touvron H, Martin L, Stone K, Albert P, Almahairi A, Babaei Y, et al. Llama 2: open foundation and fine-tuned chat models. ArXiv. Preprint posted online on July 28, 2023. [[FREE Full text](https://arxiv.org/abs/2307.09288)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2307.09288)]
  9. Chen Q, Du J, Hu Y, Keloth VK, Peng X, Raja K, et al. Large language models in biomedical natural language processing: benchmarks, baselines, and recommendations. ArXiv. Preprint posted online on May 10, 2023. [[FREE Full text](https://arxiv.org/abs/2305.16326)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2305.16326)]
  10. Wang J, Shi E, Yu S, Wu Z, Ma C, Dai H, et al. Prompt engineering for healthcare: methodologies and applications. ArXiv. Preprint posted online on April 28, 2023. [[FREE Full text](https://arxiv.org/abs/2304.14670)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2304.14670)]
  11. Hu Y, Chen Q, Du J, Peng X, Keloth VK, Zuo X, et al. Improving large language models for clinical named entity recognition via prompt engineering. ArXiv. Preprint posted online on March 29, 2023. [[FREE Full text](https://arxiv.org/abs/2303.16416)] [[CrossRef](https://dx.doi.org/10.48550/arXiv.2303.16416)]
  12. Yuan C, Xie Q, Ananiadou S. Zero-shot temporal relation extraction with chatGPT. 2023. Presented at: The 22nd Workshop on Biomedical Natural Language Processing and BioNLP Shared Tasks; July 13, 2023;92-102; Toronto, Canada. URL: <https://aclanthology.org/2023.bionlp-1.7/> [[CrossRef](https://dx.doi.org/10.18653/v1/2023.bionlp-1.7)]
  13. Li X, Liang L. Prefix-tuning: optimizing continuous prompts for generation. 2021. Presented at: Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers); August 1-6, 2021;4582-4597; Virtual Event. URL: <https://aclanthology.org/2021.acl-long.353/> [[CrossRef](https://dx.doi.org/10.18653/v1/2021.acl-long.353)]
  14. Liu P, Yuan W, Fu J, Jiang Z, Hayashi H, Neubig G. Pre-train, prompt, and predict: a systematic survey of prompting methods in natural language processing. ACM Comput Surv. 2023;55(9):1-35. [[FREE Full text](https://dl.acm.org/doi/10.1145/3560815)] [[CrossRef](https://dx.doi.org/10.1145/3560815)]
  15. Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, et al. Chain-of-thought prompting elicits reasoning in large language models. In: Koyejo S, Mohamed S, Agarwal A, Belgrave D, Cho K, Oh A, editors. Advances in Neural Information Processing Systems 35 (NeurIPS 2022). Red Hook, NY. Curran Associates Inc; 2022;24824-24837.
  16. Hancock B, Bordes A, Mazare PE, Weston J. Learning from dialogue after deployment: feed yourself, chatbot!. 2019. Presented at: Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics; July 28-August 2, 2019;3667-3684; Florence, Italy. URL: <https://aclanthology.org/P19-1358/> [[CrossRef](https://dx.doi.org/10.18653/v1/p19-1358)]
  17. Mykowiecka A, Marciniak M, Kupść A. Rule-based information extraction from patients' clinical data. J Biomed Inform. 2009;42(5):923-936. [[FREE Full text](https://linkinghub.elsevier.com/retrieve/pii/S1532-0464\(09\)00100-2)] [[CrossRef](https://dx.doi.org/10.1016/j.jbi.2009.07.007)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=19646551&dopt=Abstract)]
  18. Agrawal M, Hegselmann S, Lang H, Kim Y, Sontag D. Large language models are few-shot clinical information extractors. Association for Computational Linguistics; 2022. Presented at: The 2022 Conference on Empirical Methods in Natural Language Processing; December 7-11, 2022;1998-2022; Abu Dhabi, United Arab Emirates. URL: <https://aclanthology.org/2022.emnlp-main.130.pdf> [[CrossRef](https://dx.doi.org/10.18653/v1/2022.emnlp-main.130)]
  19. Wu Y, Xu J, Zhang Y, Xu H. Clinical abbreviation disambiguation using neural word embeddings. 2015. Presented at: Proceedings of the 2015 Workshop on Biomedical Natural Language Processing (BioNLP 2015); July 30, 2015;171-176; Beijing, China. URL: <https://aclanthology.org/W15-3822.pdf> [[CrossRef](https://dx.doi.org/10.18653/v1/w15-3822)]
  20. Abdelkader W, Navarro T, Parrish R, Cotoi C, Germini F, Iorio A, et al. Machine learning approaches to retrieve high-quality, clinically relevant evidence from the biomedical literature: systematic review. JMIR Med Inform. 2021;9(9):e30401. [[FREE Full text](https://medinform.jmir.org/2021/9/e30401/)] [[CrossRef](https://dx.doi.org/10.2196/30401)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=34499041&dopt=Abstract)]
  21. Uzuner O, Bodnari A, Shen S, Forbush T, Pestian J, South BR. Evaluating the state of the art in coreference resolution for electronic medical records. J Am Med Inform Assoc. 2012;19(5):786-791. [[FREE Full text](https://europepmc.org/abstract/MED/22366294)] [[CrossRef](https://dx.doi.org/10.1136/amiajnl-2011-000784)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=22366294&dopt=Abstract)]
  22. Denny JC, Peterson JF, Choma NN, Xu H, Miller RA, Bastarache L, et al. Extracting timing and status descriptors for colonoscopy testing from electronic medical records. J Am Med Inform Assoc. 2010;17(4):383-388. [[FREE Full text](https://europepmc.org/abstract/MED/20595304)] [[CrossRef](https://dx.doi.org/10.1136/jamia.2010.004804)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=20595304&dopt=Abstract)]
  23. Jagannatha A, Liu F, Liu W, Yu H. Overview of the first natural language processing challenge for extracting medication, indication, and adverse drug events from electronic health record notes (MADE 1.0). Drug Saf. 2019;42(1):99-111. [[FREE Full text](https://europepmc.org/abstract/MED/30649735)] [[CrossRef](https://dx.doi.org/10.1007/s40264-018-0762-z)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=30649735&dopt=Abstract)]
  24. Chen Y, Wu X, Chen M, Song Q, Wei J, Li X, et al. Dynamic text categorization of search results for medical class recognition in real world evidence studies in the Chinese language. Association for Computing Machinery, Presented at: Proceedings of the International Conference on Bioinformatics and Computational Intelligence (ICBCI 2017); 2017;40-48; Beijing, China. [[CrossRef](https://dx.doi.org/10.1145/3135954.3135962)]
  25. Mallick PK, Balas VE, Bhoi AK, Zobaa AF. Cognitive Informatics and Soft Computing Proceeding of CISC 2017, Advances in Intelligent Systems and Computing (AISC, Volume 768). New York. Springer Verlag; 2019. 
  26. Ananiadou S, Lee D, Xu H, Song M. DTMBIO'12--The Proceedings of the Sixth ACM International Workshop on Data and Text Mining in Biomedical Informatics. 2012. Presented at: 6th ACM International Workshop on Data and Text Mining in Biomedical Informatics, DTMBIO 2012, in Conjunction with the 21st ACM International Conference on Information and Knowledge Management, CIKM 2012; 2012; New York. URL: <https://dl.acm.org/action/showFmPdf?doi=10.1145%2F2390068> [[CrossRef](https://dx.doi.org/10.1145/2396761.2398758)]
  27. Elghandour I, State R, Brorsson M, Le L, Antonopoulos N, Xie Y, et al. IEEE/ACM International Symposium on Big Data Computing (BDC). 2016. Presented at: 2016 IEEE/ACM 3rd International Conference on Big Data Computing Applications and Technologies (BDCAT); December 6-9, 2016; Shanghai, China. URL: <https://ieeexplore.ieee.org/xpl/conhome/7876287/proceeding> [[CrossRef](https://dx.doi.org/10.1109/bdcat.2018.00008)]
  28. Moon S, Pakhomov S, Liu N, Ryan JO, Melton GB. A sense inventory for clinical abbreviations and acronyms created using clinical notes and medical dictionary resources. J Am Med Inform Assoc. 2014;21(2):299-307. [[FREE Full text](https://europepmc.org/abstract/MED/23813539)] [[CrossRef](https://dx.doi.org/10.1136/amiajnl-2012-001506)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=23813539&dopt=Abstract)]
  29. Nye B, Li JJ, Patel R, Yang Y, Marshall I, Nenkova A, et al. A corpus with multi-level annotations of patients, interventions and outcomes to support language processing for medical literature. 2018. Presented at: Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers); July 15-20, 2018;197-207; Melbourne, Australia. URL: <https://aclanthology.org/P18-1019/> [[CrossRef](https://dx.doi.org/10.18653/v1/p18-1019)]
  30. Devlin J, Chang MW, Lee K, Toutanova K. BERT: pre-training of deep bidirectional transformers for language understanding. ArXiv. Preprint posted online on May 24, 2019. [[FREE Full text](https://arxiv.org/abs/1810.04805)]
  31. Sarzynska-Wawer J, Wawer A, Pawlak A, Szymanowska J, Stefaniak I, Jarkiewicz M, et al. Detecting formal thought disorder by deep contextualized word representations. Psychiatry Res. 2021;304:114135. [[CrossRef](https://dx.doi.org/10.1016/j.psychres.2021.114135)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=34343877&dopt=Abstract)]
  32. Gu Y, Tinn R, Cheng H, Lucas M, Usuyama N, Liu X, et al. Domain-specific language model pretraining for biomedical natural language processing. ACM Trans Comput Healthcare. 2021;3(1):1-23. [[CrossRef](https://dx.doi.org/10.1145/3458754)]
  33. Adams G, Ketenci M, Bhave S, Perotte A, Elhadad N. Zero-shot clinical acronym expansion via latent meaning cells. Proc Mach Learn Res. 2020;136:12-40. [[FREE Full text](https://europepmc.org/abstract/MED/34790898)] [[Medline](https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=34790898&dopt=Abstract)]
  34. Toshniwal S, Xia P, Wiseman S, Livescu K, Gimpel K. On generalization in coreference resolution. ArXiv. Preprint posted online on September 20, 2021. [[FREE Full text](https://arxiv.org/abs/2109.09667)] [[CrossRef](https://dx.doi.org/10.18653/v1/2021.crac-1.12)]
  35. Neumann M, King D, Beltagy I, Ammar W. ScispaCy: fast and robust models for biomedical natural language processing. ArXiv. Preprint posted online on October 9, 2019. [[FREE Full text](https://arxiv.org/abs/1902.07669)] [[CrossRef](https://dx.doi.org/10.18653/v1/w19-5034)]
  36. Sivarajkumar S, Wang Y. Evaluation of healthprompt for zero-shot clinical text classification. 2023. Presented at: 2023 IEEE 11th International Conference on Healthcare Informatics (ICHI); June 26-29, 2023; Houston, TX, USA. [[CrossRef](https://dx.doi.org/10.1109/ichi57859.2023.00081)]



  


* * *

#### Abbreviations

**BERT:** Bidirectional Encoder Representations From Transformers  
---  
**ELMO:** Embeddings From Language Models  
**IE:** information extraction  
**LLM:** large language model  
**LM:** language model  
**NLP:** natural language processing  
**PubMedBERT-CRF:** PubMedBERT-Conditional Random Field  
  


* * *

Edited by C Lovis; submitted 08.12.23; peer-reviewed by J Zaghir, M Torii, J Zheng; comments to author 04.02.24; revised version received 20.02.24; accepted 24.02.24; published 08.04.24.

[Copyright ](https://support.jmir.org/hc/en-us/articles/115002955531)

(C)Sonish Sivarajkumar, Mark Kelley, Alyssa Samolyk-Mazzanti, Shyam Visweswaran, Yanshan Wang. Originally published in JMIR Medical Informatics (https://medinform.jmir.org), 08.04.2024.

This is an open-access article distributed under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work, first published in JMIR Medical Informatics, is properly cited. The complete bibliographic information, a link to the original publication on https://medinform.jmir.org/, as well as this copyright and license information must be included.

  


##  Citation 

Please cite as: 

Sivarajkumar S, Kelley M, Samolyk-Mazzanti A, Visweswaran S, Wang Y   
An Empirical Evaluation of Prompting Strategies for Large Language Models in Zero-Shot Clinical Natural Language Processing: Algorithm Development and Validation Study   
JMIR Med Inform 2024;12:e55318   
doi: [ 10.2196/55318 ](https://doi.org/10.2196/55318) PMID: [38587879](https://www.ncbi.nlm.nih.gov/pubmed/38587879) PMCID: [11036183](https://www.ncbi.nlm.nih.gov/pmc/articles/11036183)

Copy Citation to Clipboard 

##  Export Metadata 

[ END ](https://medinform.jmir.org/article/export/end/medinform_v12i1e55318) for: Endnote

[ BibTeX ](https://medinform.jmir.org/article/export/bib/medinform_v12i1e55318) for: BibDesk, LaTeX

[ RIS ](https://medinform.jmir.org/article/export/ris/medinform_v12i1e55318) for: RefMan, Procite, Endnote, RefWorks

[ Add this article to your Mendeley library ](http://www.mendeley.com/import/?doi=10.2196/55318)

##  This paper is in the following e-collection/theme issue:

[ Natural Language Processing (764) ](/themes/171)[ Clinical Information and Decision Making (1548) ](/themes/67)[ Clinical Informatics (1107) ](/themes/58)[ Machine Learning (1627) ](/themes/500)[ Ontologies, Classifications, and Coding (256) ](/themes/235)[ Artificial Intelligence (1602) ](/themes/797)[ Tools, Programs and Algorithms (305) ](/themes/146)[ Natural Language Processing (26) ](/themes/1251)[ Chatbots and Conversational Agents (589) ](/themes/763)[ Generative Language Models Including ChatGPT (413) ](/themes/1437)

##  Download 

[ Download PDF](https://medinform.jmir.org/2024/1/e55318/PDF) [ Download XML](https://medinform.jmir.org/2024/1/e55318/XML)

##  Share Article 

[](https://bsky.app/intent/compose?text=Check%20out%20this%20fascinating%20article%20https%3A%2F%2Fmedinform.jmir.org%2F2024%2F1%2Fe55318 "share-on-Bluesky") [](https://twitter.com/intent/tweet?url=Check%20out%20this%20fascinating%20article%20https%3A%2F%2Fmedinform.jmir.org%2F2024%2F1%2Fe55318 "share-on-Twitter") [](https://www.facebook.com/sharer.php?s=100&u=https://medinform.jmir.org/2024/1/e55318&quote=Check%20out%20this%20fascinating%20article "share-on-Facebook") [](https://www.linkedin.com/feed?shareActive=true&text=Check%20out%20this%20fascinating%20article%20https%3A%2F%2Fmedinform.jmir.org%2F2024%2F1%2Fe55318 "Linkedin")

##  Career Opportunities 

[ Clinical Social Worker  California Correctional Health Care Services  Stockton, California ](https://careers.jmir.org/jobs/json/21157536/clinical-social-worker)

[ Clinical Social Worker  California Correctional Health Care Services  Susanville, California ](https://careers.jmir.org/jobs/json/21157524/clinical-social-worker)

[ Psychologist  California Correctional Health Care Services  Avenal, California ](https://careers.jmir.org/jobs/json/21157672/psychologist)

[ Psychiatrist  California Correctional Health Care Services  Crescent City, California ](https://careers.jmir.org/jobs/json/21157586/psychiatrist)

[ Psychologist  California Correctional Health Care Services  Represa, California ](https://careers.jmir.org/jobs/json/21157694/psychologist)

##  JMIR Medical Informatics  ISSN 2291-9694 

###  Resource Centre 

  * [ Author Hub ](/resource-centre/author-hub)
  * [ Editor Hub ](/resource-centre/editor-hub)
  * [ Reviewer Hub ](/resource-centre/reviewer-hub)
  * [ Librarian Hub ](/resource-centre/librarian-hub)



###  Browse Journal 

  * [ Latest Announcements ](/announcements)
  * [ Authors ](/search/authors)
  * [ Themes ](/themes)
  * [ Issues ](/issues)
  * [ Blog ](https://blog.jmir.org )



###  About 

  * [ Privacy Statement ](/privacy-statement)
  * [ Contact Us ](/contact-us)
  * [ Sitemap ](/sitemap.xml)



###  Connect With Us 

[](https://bsky.app/profile/jmirpub.bsky.social  "Bluesky")[](https://twitter.com/jmirpub "Twitter")[](https://www.facebook.com/JMedInternetRes "Facebook")[](https://www.linkedin.com/company/jmir-publications "Linkedin")[](https://www.youtube.com/c/JMIRPublications "YouTube")[](https://www.instagram.com/jmirpub "Instagram") [](https://medinform.jmir.org/feed/atom "RSS Subscription")

###  Get Table of Contents Alerts 

[Get Alerts ](https://landingpage.jmirpublications.com/journal-preference-selection "Newsletter Subscription")

Copyright ©  2025  JMIR Publications 

[](javascript:; "Scroll to the top of the page")


url: https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering
title: Modern Advances in Prompt Engineering
scrape_date: 2025-03-17T12:00:37.467405
content_type: markdown
hash: f36620560ca5390657e3091d0ffd7aa17b901b5ec9b6ce3237781418fe9cd280
content:
[![Deep \(Learning\) Focus](https://substackcdn.com/image/fetch/w_80,h_80,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fab9b43fb-52d5-40da-995d-5b7cd3f91064_896x896.png)](/)

# [Deep (Learning) Focus](/)

SubscribeSign in

#### Share this post

[![](https://substackcdn.com/image/fetch/w_520,h_272,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f77fa47-f998-420e-a4f3-2defeea24374_2124x1194.png)![Deep \(Learning\) Focus](https://substackcdn.com/image/fetch/w_36,h_36,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fab9b43fb-52d5-40da-995d-5b7cd3f91064_896x896.png)Deep (Learning) FocusModern Advances in Prompt Engineering](https://substack.com/home/post/p-143156742?utm_campaign=post&utm_medium=web)

Copy linkFacebookEmailNotesMore

# Modern Advances in Prompt Engineering

### Distilling and understanding the most rapidly-evolving research topic in AI...

[![](https://substackcdn.com/image/fetch/w_36,h_36,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F69aba7df-b571-4609-aa47-fc2d031c11b8_1242x1595.jpeg)](https://substack.com/@cwolferesearch)

[Cameron R. Wolfe, Ph.D.](https://substack.com/@cwolferesearch)

Apr 29, 2024

111

#### Share this post

[![](https://substackcdn.com/image/fetch/w_520,h_272,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f77fa47-f998-420e-a4f3-2defeea24374_2124x1194.png)![Deep \(Learning\) Focus](https://substackcdn.com/image/fetch/w_36,h_36,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fab9b43fb-52d5-40da-995d-5b7cd3f91064_896x896.png)Deep (Learning) FocusModern Advances in Prompt Engineering](https://substack.com/home/post/p-143156742?utm_campaign=post&utm_medium=web)

Copy linkFacebookEmailNotesMore

[7](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comments)17

[Share](javascript:void\(0\))

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F824499cf-f366-4612-a437-8785af41ee50_2134x1184.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F824499cf-f366-4612-a437-8785af41ee50_2134x1184.png)(from [17, 29, 35, 39])

Due to their ease of use, large language models (LLMs) have seen an explosive rise to popularity. By just crafting a textual prompt, even those who are completely unfamiliar with deep learning can leverage massive neural networks to quickly solve a wide variety of complex problems. Over time, these models have become even easier to use via improved instruction following capabilities and alignment. However, effectively prompting LLMs is both an art and a science— _significant_ _performance improvements can be achieved by slightly tweaking our prompting implementation or strategy_. In this overview, we will develop a comprehensive understanding of prompt engineering, beginning with basic concepts and going all the way to cutting-edge techniques that have been proposed in recent months.

## What is prompt engineering?

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06a25852-e696-4033-9887-1560baf4f37c_2456x840.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06a25852-e696-4033-9887-1560baf4f37c_2456x840.png)

One major reason that LLMs are so popular is because their text-to-text interface makes them incredibly simple to use. In a prior generation, solving a task with deep learning would require that we (at a minimum) finetune a model over some data to teach the model how to solve that task. Plus, most of these models were narrow experts, meaning that they would specialize in solving a single task. Due to the emergent [in-context learning](https://x.com/cwolferesearch/status/1753458022251180439) abilities of LLMs, however, we can solve a variety of problems via a textual prompt; see above. Previously complex problem solving processes have been [abstracted into natural language](https://karpathy.medium.com/software-2-0-a64152b37c35)!

> _“Prompt engineering is a relatively new discipline for developing and optimizing prompts to efficiently use LMs for a wide variety of applications and research topics.”_ \- from [1]

**What is prompt engineering?** The simplicity of LLMs has democratized their use. You don’t need to be a data scientist or an MLE to use an LLM— _as long as you understand English (or your language of choice) you can solve relatively complex problems with an LLM_! When solving a problem with an LLM, however, the results that we achieve depend heavily upon the textual prompt provided to the model. For this reason, prompt engineering— _the empirical science of testing different prompts to optimize an LLM’s performance_ —has become extremely popular and impactful, resulting in the discovery of many techniques and best practices.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7df4b8f5-6894-4e63-8057-36db0d19f095_1574x928.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7df4b8f5-6894-4e63-8057-36db0d19f095_1574x928.png)Including indicators within a prompt

**Prompt components.** There are many ways to prompt an LLM. However, most prompting strategies share a few common components:

  * _Input Data_ : the actual data that the LLM is expected to process (e.g., the sentence being translated or classified, the document being summarized, etc.).

  * _Exemplars_ : concrete examples of correct input-output pairs that are included within the prompt.

  * _Instruction_ : a textual description of the output that is expected of the model.

  * _Indicators_ : tags or formatting elements that are used to create structure within the prompt; see above. 

  * _Context_ : any extra information provided to the LLM in the prompt.




In the figure below, we see an example that combines all of the above-mentioned prompt components within a single prompt for sentence classification. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4dbc86-70b9-476e-8c63-78bd6d4c0c75_1266x916.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4dbc86-70b9-476e-8c63-78bd6d4c0c75_1266x916.png)Prompt with all components in the style of LLaMA-2 (see [here](https://huggingface.co/blog/llama2#how-to-prompt-llama-2))

**The context window.** During pretraining, an LLM sees input sequences of a particular length. This choice of sequence length during pretraining becomes the model’s _“context length”_ , or the maximum length of sequence that the model is capable of processing. Given a textual sequence that is significantly longer than this predetermined context length, the model may behave unpredictably and produce incorrect output. However, there are methods— _such as[Self-Extend](https://cameronrwolfe.substack.com/i/140501286/llm-maybe-longlm-self-extend-llm-context-window-without-tuning) or [positional interpolation](https://arxiv.org/abs/2306.15595)_—that can be used to extend the model’s context window.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe32bfe12-7ae3-4670-a1a8-34a72c6cda89_1834x944.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe32bfe12-7ae3-4670-a1a8-34a72c6cda89_1834x944.png)Illustration of positional interpolation with RoPE (from [34])

Recent research on LLMs has emphasized the creation of [long context windows](https://blog.google/technology/ai/google-gemini-next-generation-model-february-2024/), which allow the model to process more information within each prompt (e.g., more exemplars or a larger amount of context). As we will see, however, _not all LLMs pay perfect attention to their context_! The ability of an LLM to leverage information within a long context window is typically assessed via a [needle in the haystack test](https://github.com/gkamradt/LLMTest_NeedleInAHaystack), which _i)_ embeds a random fact within the context, _ii)_ asks the model to retrieve the fact, and _iii)_ repeats this test over various context lengths and positions of the fact in the context. Such a test yields a picture like the one shown below, where we can easily spot deficiencies in the context window.

[![GPT-4-128 Context Testing](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9546823-fd44-4b5a-ad85-2d8da8ae69d7_1712x958.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9546823-fd44-4b5a-ad85-2d8da8ae69d7_1712x958.png)([source](https://github.com/gkamradt/LLMTest_NeedleInAHaystack))

**My prompt engineering strategy.** The details of prompt engineering differ a lot based upon the model being used. However, there are a few general principals that are often useful for guiding the prompt engineering process:

  1. _Be empirical_ : the first step of prompt engineering is to setup a reliable way of evaluating your prompt (e.g., via test cases, human evaluators, or [LLM-as-a-judge](https://arxiv.org/abs/2306.05685)) so that you can easily evaluate changes to a prompt.

  2. _Start simple_ : the first prompt you try should not be a chain-of-thought prompt (or some other specialized prompting technique). Start with the simplest prompt possible and slowly add complexity while measuring the change in performance (see above) to determine if extra complexity is necessary[1](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-1-143156742).

  3. _Be specific and direct_ : eliminate ambiguity in the prompt and try to be concise, direct, and specific when describing the desired output of the LLM.

  4. _Use exemplars_ : if describing the desired output is difficult, try adding some exemplars to the prompt. Exemplars eliminate ambiguity by providing concrete examples of what is expected of the LLM. 

  5. _Avoid complexity (if possible)_ : complex prompting strategies are sometimes necessary (e.g., to solve multi-step reasoning problems), but we should think twice before using such approaches. Be empirical and use the established evaluation strategy to truly determine whether the complexity is necessary. 




To summarize everything above, my personal prompt engineering strategy is to _i)_ invest into a really good evaluation framework, _ii)_ start with a simple prompt, and _iii)_ slowly add complexity as necessary to achieve the desired level of performance.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddb7772f-305e-4d12-9ca3-68ec34dcf714_2096x636.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddb7772f-305e-4d12-9ca3-68ec34dcf714_2096x636.png)Writing prompts is an iterative process!

## Prompting Techniques

We have previously learned about a variety of prompting techniques through a series of related overviews:

  * Practical Prompt Engineering [[link](https://cameronrwolfe.substack.com/p/practical-prompt-engineering-part)]

  * Advanced Prompt Engineering [[link](https://cameronrwolfe.substack.com/p/advanced-prompt-engineering)]

  * Chain of Thought Prompting [[link](https://cameronrwolfe.substack.com/p/chain-of-thought-prompting-for-llms)]

  * Prompt Ensembles [[link](https://cameronrwolfe.substack.com/p/prompt-ensembles-make-llms-more-reliable)]




We will now overview relevant prompting techniques once again, providing a foundation for the more complex approaches that will be introduced later in the post. As we learn about each of these techniques, however, we should keep in mind the importance of simplicity in prompt engineering. _Just because a prompting technique is more intricate or complex does not make it better than simpler strategies_!

#### Basic Prompting Strategies

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe749d0ff-794c-4fd5-a8bf-d75873bf3e38_924x322.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe749d0ff-794c-4fd5-a8bf-d75873bf3e38_924x322.png)(from [3])

**Zero-shot prompting** (shown above)— _as popularized by[GPT-2](https://cameronrwolfe.substack.com/i/85568430/language-models-are-unsupervised-multitask-learners-gpt) _[2]—is one of the most basic prompting strategies that we can employ. To solve a task via zero-shot prompting, we just _i)_ describe the task in the prompt and _ii)_ prompt the model to solve the problem. In the case of the problem above, the task is translating a word from English to French, and we prompt the model to make this translation via the string “cheese =>”, which prompts the model to emit the French translation of the word cheese. Several examples of zero-shot prompts are provided below.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fc2ea13-cf4b-4b6c-955f-835dbbf27be4_2412x752.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fc2ea13-cf4b-4b6c-955f-835dbbf27be4_2412x752.png)Zero-shot learning (outputs produced with GPT-3.5-Turbo)

Although zero-shot learning performs well in some cases, it is limited by the ambiguity of task descriptions. Performance is dependent upon the creation of a clear/comprehensive description, and we rely upon the model’s ability to produce the correct output based on this description alone. Oftentimes, we can achieve better performance by inserting more concrete information into the prompt. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ee0351-5743-4f1a-bdee-2f0e13074579_1590x1044.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50ee0351-5743-4f1a-bdee-2f0e13074579_1590x1044.png)(from [3])

**Few-shot prompting** does exactly this by inserting several examples of correct problem solutions into the prompt. This strategy was popularized by [GPT-3](https://cameronrwolfe.substack.com/i/88082618/language-models-are-few-shot-learners) [3], which showed that LLMs develop impressive few-shot learning abilities at scale; see above. Intuitively, few-shot learning eliminates the ambiguity of zero-shot learning by providing several examples of the expected output. As such, the model can understand the correct behavior directly from these exemplars, rather than inferring the desired behavior from the task description; see below. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c1bf7a-0962-479a-8510-e20fd94882db_944x542.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c1bf7a-0962-479a-8510-e20fd94882db_944x542.png)(from [3])

The LLM can learn from these examples provided within the prompt, a strategy commonly referred to as _“in-context learning”_ ; see below. However, this style of learning is not like normal training of a neural network— _the parameters of the model are not modified at all_. Rather, we put relevant information in the prompt, and the model can use this information as context for generating a better output. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc2d031-d1b8-487c-9db6-9cb55baab3ad_1688x832.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc2d031-d1b8-487c-9db6-9cb55baab3ad_1688x832.png)(from [3])

When using few-shot learning in practice, there are two key settings that we must tune properly:

  1. The number of exemplars to use.

  2. The strategy for selecting exemplars.




To determine the correct number of exemplars to use, we can perform some basic [hyperparameter tuning](https://www.jeremyjordan.me/hyperparameter-tuning/) using an evaluation set. Many papers have explored strategies for exemplar selection (e.g., based on [random selection](https://arxiv.org/abs/2005.14165), [diversity](https://arxiv.org/abs/2209.01975), [semantic similarity](https://arxiv.org/abs/2101.06804), [active learning](https://arxiv.org/abs/2302.12246), or more [complex metrics](https://arxiv.org/abs/2211.04486))[2](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-2-143156742). However, random selection of exemplars is oftentimes an effective strategy in practice. Beyond these strategies, there are a variety of practical rules and findings relevant to few-shot learning that we should always keep in mind [4, 5]:

  * The distribution of labels— _even if they are incorrect_ —for exemplars can impact the model’s answer, as the model is biased towards common labels.

  * The answer is biased towards recently-observed exemplars in the prompt[3](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-3-143156742). 

  * The formatting of exemplars in the prompt is important. 

  * Selecting exemplars randomly can help to remove bias (e.g., position or majority label bias) within the model’s generated answer. 




Despite its simplicity, few-shot learning is one of the most effective prompting strategies and is widely-used within practical applications.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F709a92cd-ab31-4343-bf83-62fc865d9c13_1154x928.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F709a92cd-ab31-4343-bf83-62fc865d9c13_1154x928.png)Several examples of instruction prompts (from [6])

**Instruction prompting** is a more direct method of expressing the LLM’s desired output. With few-shot learning, we explain our intent to the model via concrete exemplars of a task being solved, _but these exemplars consume a lot of tokens_! Simply explaining our intent to the model in words would be much more efficient. For this to work well, the LLM being used must be [aligned](https://cameronrwolfe.substack.com/i/138218863/language-model-alignment) to consistently follow instructions. Such models are said to be _“steerable”_ because they understand detailed instructions provided and can adjust their output accordingly.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f305e4-aebd-42cd-afe3-54f7be1961a0_1614x752.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f305e4-aebd-42cd-afe3-54f7be1961a0_1614x752.png)(from [6])

Research on LLMs has heavily focused upon improving instruction following capabilities. Pre-trained LLMs are not good at following instructions out-of-the-box. As shown by InstructGPT [6], however, we can align models to be much better at following instructions via a combination of [supervised finetuning (SFT)](https://cameronrwolfe.substack.com/p/understanding-and-using-supervised) and [reinforcement learning from human feedback (RLHF)](https://cameronrwolfe.substack.com/p/the-story-of-rlhf-origins-motivations). We see in the figure above that this strategy can improve instruction following, as well as other key properties of the LLM (e.g., factuality and constraint following). 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f48aa5f-60f5-46ef-9de3-57bd700bf350_1264x1220.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f48aa5f-60f5-46ef-9de3-57bd700bf350_1264x1220.png)Role prompting with LaMDA (from [8])

Given recent advancements in LLM alignment, instruction prompting— _which can even be combined with few-shot prompting [7]_ —is a highly effective approach that is commonly used in practical applications. In fact, several popular prompting strategies (e.g., [role prompting](https://learnprompting.org/docs/basics/roles), [specifying an audience](https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/#instruction-prompting), or [tool usage](https://arxiv.org/abs/2303.17580) to name a few) are just more specific versions of instruction prompting! When writing instructions, we should be clear and precise to ensure the best possible results.

#### Advanced Prompting Strategies

Although the prompting techniques outlined above are highly effective, sometimes more complex prompts can be useful for solving difficult problems (e.g., math/coding or multi-step reasoning problems). Because LLMs naturally struggle with these problems[4](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-4-143156742) (i.e., reasoning capabilities do not improve monotonically with model scale [9]), a majority of existing research on prompt engineering is focused upon improving reasoning and complex problem solving capabilities— _simple prompts will work for solving most other problems_.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F599a636e-b0b2-4de3-84c8-3edf906bfa82_1616x882.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F599a636e-b0b2-4de3-84c8-3edf906bfa82_1616x882.png)(from [10])

**Chain of Thought (CoT) prompting [10]** elicits reasoning capabilities in LLMs by inserting a chain of thought (i.e., a series of intermediate reasoning steps) into exemplars within a model’s prompt; see above. By augmenting each exemplar with a chain of thought, the model learns (via in-context learning) to generate a similar chain of thought prior to outputting the final answer for the problem in question. Interestingly, we see in [10] that sufficiently large models (i.e., >100B parameters) benefit heavily from this approach on arithmetic, commonsense and symbolic reasoning tasks— _explicitly explaining the underlying reasoning process for solving a problem actually makes the model more effective at reasoning_. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d770953-ca52-4025-9945-683b5195c67d_1604x1394.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d770953-ca52-4025-9945-683b5195c67d_1604x1394.png)(from [10])

The implementation of CoT prompting is simple. Instead of each few-shot exemplar having only an input and output, exemplars are triplets of the form `(input, chain of thought, output)`; see above. The major downside of this approach is that we must manually (or synthetically) curate exemplars that include a full rationale for the solution to a problem, which can be expensive and/or time consuming. As such, many papers focus upon eliminating the dependence of CoT prompting upon human-written rationales!

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e413891-7356-4f90-b36c-0a046eab0ccb_1932x550.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e413891-7356-4f90-b36c-0a046eab0ccb_1932x550.png)(from [11, 12])

**CoT variants.** Due to the effectiveness and popularity of CoT prompting, numerous extensions of this approach have been proposed. For example, zero-shot CoT [11] prompting eliminates few-shot exemplars and instead encourages the model to generate a problem-solving rationale by appending the words _“Let’s think step by step.”_ to the end of the prompt. We can also improve the robustness of the reasoning process by _i)_ independently generating multiple chains of thought when solving a problem and _ii)_ taking a majority vote of the final answers produced with each chain of thought[5](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-5-143156742). Despite increasing the cost of solving a problem, this approach, called self-consistency [12], improves the reliability of LLMs when solving more complex classes of reasoning problems.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd80814e2-0e61-4119-978f-87f1790d04bd_866x684.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd80814e2-0e61-4119-978f-87f1790d04bd_866x684.png)(from [13])

Least-to-most prompting [13] goes beyond CoT prompting by explicitly breaking down a complex problem into multiple parts; see above. Each sub-problem is solved individually, and the solution to each sub-problem is passed as context for solving the next sub-problem. Once we have reached the final sub-problem, we can use the context of prior solutions to output a final answer to the question. 

> _“It is perhaps surprising that underlying all this progress [for LLMs] is still the original autoregressive mechanism for generating text, which makes token-level decisions one by one and in a left-to-right fashion.”_ \- from [14]

**Tree of thoughts (ToT) prompting [14].** Techniques like CoT prompting follow a left-to-right generation approach that uses [next-token prediction](https://cameronrwolfe.substack.com/i/136638774/understanding-next-token-prediction) to output a solution in a single attempt. Such an approach, although effective in certain scenarios, may fail to solve complex problems that can benefit from extensive planning, strategic lookahead, backtracking, and exploration of numerous viable solutions in parallel. _This is where ToT prompting comes in_! ToT prompting— _somewhat similarly to least-to-most prompting [13]_ —breaks a complex problem into a series of simpler problems (or “thoughts”) that can be solved individually.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04dd32f-0938-47dc-a8c8-c6a4377a5b12_1604x858.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04dd32f-0938-47dc-a8c8-c6a4377a5b12_1604x858.png)(from [14])

Unlike CoT prompting, ToT prompting does not require that we follow a single path of thoughts when solving a problem. Additionally, ToT prompting does not simply take a majority vote of multiple reasoning paths like self-consistency; see above. During exploration, the LLM generates many thoughts and continually evaluates its progress toward a final solution via natural language (i.e., we just prompt the model!). By leveraging the model’s self-evaluation of its own progress towards a final solution, we can power the exploration process with widely-used search algorithms (e.g., [breadth-first search or depth-first search](https://www.geeksforgeeks.org/difference-between-bfs-and-dfs/)), allowing lookahead and backtracking to be performed within the problem-solving process. Check out [this overview](https://cameronrwolfe.substack.com/p/tree-of-thoughts-prompting) for a more detailed explanation of ToT prompting. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc113cb01-ac85-4e0e-a418-a21c5dd9a4e0_1728x718.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc113cb01-ac85-4e0e-a418-a21c5dd9a4e0_1728x718.png)(from [35])

**Graph of Thoughts (GoT) prompting [35, 36].** Later work generalized research on ToT prompting to graph-based strategies for reasoning. Overall, these techniques are similar to ToT prompting, but they make no assumption that the path of thoughts used to generate a final solution is linear. Rather, we can re-use thoughts or even recurse through a sequence of several thoughts when deriving a solution; see above. Multiple graph-based prompting strategies have been proposed (see [here](https://cameronrwolfe.substack.com/p/graph-based-prompting-and-reasoning) for more details) [35, 36]. However, these prompting techniques— _as well as ToT prompting_ —have been criticized for their lack of practicality. Namely, solving a reasoning problem with GoT prompting could potentially require a massive number of inference steps from the LLM!

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F836d1309-73a6-44c6-9f22-056742ac3cee_2318x746.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F836d1309-73a6-44c6-9f22-056742ac3cee_2318x746.png)A basic RAG pipeline

**Retrieval Augmented Generation (RAG) [37]** (shown above), though not purely a prompting technique, is a widely used strategy that improves the quality of an LLM’s output by retrieving relevant context to include in the prompt. To retrieve useful context, we can use just use existing search techniques; e.g., pure vector search or a hybrid search engine. Despite its simplicity, research has shown that RAG is incredibly effective at injecting knowledge into an LLM and reducing the number of hallucinations generated by the model [38]. Plus, we can easily provide citations to users of the LLM by simply exposing the relevant documents being retrieved by RAG. However, the manner in which we process and retrieve data, as well as how we structure the context that is inserted into the prompt, can have a significant impact upon performance; see [here](https://cameronrwolfe.substack.com/p/a-practitioners-guide-to-retrieval) for more details.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F525f50a2-5174-4851-99b3-0bf251d59477_908x930.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F525f50a2-5174-4851-99b3-0bf251d59477_908x930.png)(from [39])

**Generated knowledge prompting [39]** is an interesting alternative to RAG that uses an LLM to generate relevant context to include in the prompt instead of retrieving this context from an external database; see above. Despite being very simple and having positive performance indications, this approach (obviously) lacks in reliability due to the tendency of LLMs to hallucinate information.

## Recent Directions of Research

Although we have covered a variety of prompting techniques so far, many papers have been published recently that both expand upon these methods and explore completely new styles of prompts for solving complex problems. Here, we have separated this work into several categories based upon the topic or focus:

  * Reasoning

  * Tool Usage

  * Program-Aided Language Models

  * Context Windows

  * Writing

  * Miscellaneous (other notable papers)




For each category, a variety of different works are covered. Given the massive amount of research that has been published on the topic of prompt engineering, however, there’s a good chance that several papers were missed. If you know of a good paper that should be included, please share it in the comments!

#### Improving Reasoning Capabilities

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec269102-c433-4bb8-8276-33124df49574_1392x810.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec269102-c433-4bb8-8276-33124df49574_1392x810.png)(from [15])

**Auto-CoT [15].** CoT prompting uses intermediate reasoning steps to solve complex problems, and there are two ways we can elicit these reasoning steps within an LLM’s output (depicted above):

  1. _Zero-shot_ : prompt the LLM to “think step-by-step”.

  2. _Manual_ : provide several few-shot examples of questions, rationales, and answers prior to answering the desired question.




Although LLMs are decent zero-shot reasoners, providing concrete exemplars consistently yields better performance with CoT prompting. However, this strategy also requires human annotators— _or the prompt engineer_ —to craft manual demonstrations of rationales used to answer each question. Crafting these manual demonstrations is time consuming, but it can be avoided!

> _“We show that such manual efforts may be eliminated by leveraging LLMs with the Let’s think step by step prompt to generate reasoning chains for demonstrations one by one.”_ \- from [15]

In [15], authors propose an automatic CoT (Auto-CoT) prompting approach that uses zero-shot CoT prompting to automatically generate examples for manual CoT prompting, thus eliminating the need to manually craft problem-solving rationales. However, because these automatically-generated rationales are incorrect in some cases, a few tricks are required for Auto-CoT to work well. 

Given a question as input, a naive approach would be to _i)_ retrieve a set of similar questions (e.g., using an embedding model like sBERT and [vector search](https://cameronrwolfe.substack.com/p/the-basics-of-ai-powered-vector-search)), _ii)_ generate rationales/answers for each of these questions with zero-shot CoT prompting, and _iii)_ perform manual CoT prompting with the automatically-generated demonstrations. However, this approach works quite poorly, which authors in [1] claim is due to mistakes in the LLM-generated rationales. To solve this, we simply need to ensure the generated rationales are sufficiently diverse.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F599d84f3-d343-4085-8050-2642c216c500_1398x842.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F599d84f3-d343-4085-8050-2642c216c500_1398x842.png)(from [15])

Given a dataset of questions that should be answered by the LLM, authors in [15] devise a two-part strategy (shown above) for selecting/generating demonstrations used within the prompt for Auto-CoT:

  * Divides the questions into `k` clusters using question embeddings from [sBERT](https://cameronrwolfe.substack.com/i/140061921/sentence-bert-sentence-embeddings-using-siamese-bert-networksextensions-of-sbert) and [k-means clustering](https://en.wikipedia.org/wiki/K-means_clustering).

  * Selects a representative question from each cluster and generates an associated rationale for each question using zero-shot CoT. 




Such an approach ensures that the diversity of demonstrations used for Auto-CoT is high, which reduces the correlation between mistakes made by the model across synthetic rationales. In experiments with GPT-3, Auto-CoT consistently matches or exceeds the performance of few-shot CoT prompting, which requires the manual creation of demonstrations, on over ten different benchmarks.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18f2b729-03de-4100-bcce-55dd3d6f5542_1344x830.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18f2b729-03de-4100-bcce-55dd3d6f5542_1344x830.png)(from [16])

**Complexity-Based Prompting [16].** Given that CoT prompting relies upon selecting demonstrations of problem-solving rationales to include in the prompt, we might wonder: _How do we best select these demonstrations?_ In [16], authors show that selecting demonstrations based on their complexity is a good heuristic. We can measure the complexity of a demonstration by simply counting the number of steps present within the chain of thought, where individual steps are separated by newline characters (`\n`). The complexity-based prompting approach proposed in [16] advocates sampling demonstrations with the highest complexity. 

> _“The reasoning performance of GPT-3 175B clearly improves with the increased input prompt complexity.”_ \- from [16]

Interestingly, authors in [16] discover that including demonstrations with more reasoning steps in the CoT prompt substantially improves performance on multi-step reasoning tasks. Going further, one can extend this strategy to the output space by using a self-consistency approach that takes a majority vote over `k` generated outputs with the highest complexity. Compared to alternative selection schemes like manual tuning and retrieval-based selection, complexity-based prompting performs favorably, achieving state-of-the-art performance on several datasets (i.e., [GSM8K](https://huggingface.co/datasets/gsm8k), [MultiArith](https://huggingface.co/datasets/ChilleD/MultiArith), and [MathQA](https://huggingface.co/datasets/math_qa)) with GPT-3 and Codex. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1bff3de2-7f9b-427f-a158-acbb1c1420b6_1610x1332.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1bff3de2-7f9b-427f-a158-acbb1c1420b6_1610x1332.png)(from [17])

**Progressive-Hint Prompting (PHP) [17].** One downside of CoT prompting is that it solves a problem in a single shot. Given a question as input, we generate a rationale and answer, but the LLM does not get a chance to consider or revise this answer. One can achieve better performance by repeating this process multiple times and taking a majority vote— _this is just self-consistency_ —but none of these generations consider the LLM’s prior outputs to better inform the answer. 

> _“PHP follows a human-like thought process where previous answers are leveraged as hints to arrive at the correct answer after re-evaluating the question.”_ \- from [17]

To solve this issue, authors in [17] propose PHP to leverage prior outputs of the LLM to iteratively refine the generated rationale. Intuitively, the LLM can use rationales previously generated by the model as hints towards discovering the correct answer. Concretely, PHP proceeds in three steps:

  1. Given a question, prompt the LLM to provide a base answer.

  2. Concatenate the question and base answer, then prompt the LLM to generate a revised answer based on this input. 

  3. Repeat step two until the LLM’s answer is stable for at least two iterations.




Such an approach allows the LLM to iteratively refine its answer over several passes, using its prior output as context during the process. Additionally, PHP is fully compatible with CoT prompting and self-consistency— _we can combine these techniques to further improve performance_. In experiments, PHP improves the performance of GPT-3.5 in comparison to a complexity-based prompting strategy, and using PHP with GPT-4 yields state-of-the-art performance on several notable datasets (e.g., [SVAMP](https://huggingface.co/datasets/ChilleD/SVAMP), GSM8K, [AQuA](https://huggingface.co/datasets/aqua_rat), and [MATH](https://huggingface.co/datasets/math_dataset)).

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e704c2f-9eb1-4a27-b43a-1c239f31eca7_1336x526.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e704c2f-9eb1-4a27-b43a-1c239f31eca7_1336x526.png)(from [18])

**Decomposed Prompting (DecomP) [18]** tries to address the difficulty of solving multi-step reasoning problems with complex steps via prompting. As tasks become more complex, few-shot prompting (i.e., showing a few examples of a correct solution) will fall short. However, we can do better by decomposing complex tasks into sub-tasks that can be solved independently via prompting. In particular, authors in [18] propose a prompting framework with two components:

  1. _Decomposer_ : prompts an LLM to decompose a problem into a series of simpler sub-tasks.

  2. _Sub-task handlers_ : uses a separate prompt to solve a simpler sub-task (as dictated by the decomposer) with an LLM. 




The decomposer and sub-task handlers are just LLMs prompted in a few-shot manner. The DecomP strategy proposed above uses one prompt to identify solvable sub-tasks that are then delegated to another system (e.g., a new prompt, different LLM, or tool) to be solved. Such a modular approach has many benefits:

  * Tasks with long context can be decomposed into multiple components.

  * Each sub-task can be shown a broader set of examples.

  * Complex sub-tasks can be further decomposed into sub-tasks if needed.

  * Instead of solving all sub-tasks with an LLM, we can also use other symbolic systems (e.g., a task-specific model, retrieval mechanism, etc.). 




Let’s consider a simple task as an example. Given a set of words as input, we want to extract the third character of each word, concatenate these characters, and provide their concatenation as output. To do this, we can create a sequence of three sub-tasks: _i)_ collect the list of words, _ii)_ extract the third letter of each word, and _iii)_ concatenate the extracted letters. We can implement each of these sub-tasks with a separate few-shot prompt, as shown in the figure below. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb0fdef1-cbc8-4ef8-8cc1-f23ce6d8471c_1600x606.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb0fdef1-cbc8-4ef8-8cc1-f23ce6d8471c_1600x606.png)(from [18])

Within Decomp, sub-tasks are iteratively generated by the decomposer, solved, and returned (with relevant output) to the decomposer to generate the next sub-task. The decomposer will continue to generate sub-tasks, acting as a controller for the reasoning process, until the end-of-question `[EOQ]` marker is generated, signifying that the final answer has been produced; see below. Overall, DecomP can be thought of as a more general/flexible version of least-to-most prompting. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce5cef6-7ba2-40d1-b540-d86dbb2835b3_1608x830.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce5cef6-7ba2-40d1-b540-d86dbb2835b3_1608x830.png)(from [18])

**Hypotheses-to-Theories [29].** Reasoning abilities can be elicited within LLMs by prompting the model with example rationales that decompose a complex task into simple steps. However, the model may hallucinate when producing output and performance is poor on tasks that go beyond conventional or common knowledge. Put simply, _problems occur when there is a mismatch between the LLM’s knowledge base and the knowledge required to solve a task_. To solve this problem, we need a prompting approach that empowers the LLM to discover and apply necessary knowledge when solving complex reasoning problems.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d994fc6-c57e-4028-b9ac-e17d379ce363_1602x1126.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d994fc6-c57e-4028-b9ac-e17d379ce363_1602x1126.png)(from [29])

Inspired by the scientific discovery process of humans, authors in [29] propose a prompting technique, called Hypotheses-to-Theories (HtT) prompting, that follows a strategy of freely proposing (potentially incorrect) hypotheses, only keeping those that can be verified empirically, and using these verified hypothesis to solve a problem. At a high level, the goal of this strategy is to learn a rule library for the LLM that can be used for problem solving. More concretely, HtT prompting (depicted above) is comprised of two steps:

  1. _Induction_ : The LLM is asked to generate and verify rules over a set of training examples. Rules that appear often and frequently produce a correct answer are collected to form a rule library. 

  2. _Deduction_ : the LLM is prompted to use the rule set generated via induction to perform reasoning and answer a question. 




By using a rule set during reasoning, HtT prompting reduces the probability of hallucinations. Such a finding is verified across both numerical and relational reasoning tasks, where HtT prompting is shown to provide a 11-27% absolute improvement in accuracy compared to prior prompting techniques (e.g., CoT prompting). Interestingly, the rules generated by HtT prompting are also interpretable and even transferable to different (but similar) problems. 

#### Tool Usage

Although LLMs are powerful, they have notable limitations! For example, LLMs make arithmetic mistakes, lack access to current information, and even struggle to comprehend the progression of time. Many advancements in the human race have been catalyzed by access to new and innovative tools (e.g., the [printing press](https://www.history.com/news/printing-press-renaissance) or [computer](https://www.youtube.com/watch?v=L40B08nWoMk)), and the same may be true of LLMs. Namely, we can solve many limitations of these models by giving them access to a set of external, specialized tools (e.g., a calculator or search engine) and teaching the model when, where, and how to properly invoke these tools to more reliably solve problems. For more info, check out the prior overviews on this topic below:

  * Teaching Language Models to Use Tools [[link](https://cameronrwolfe.substack.com/p/teaching-language-models-to-use-tools)]

  * Language Models and Friends [[link](https://cameronrwolfe.substack.com/p/language-models-and-friends-gorilla)]

  * Can language models make their own tools? [[link](https://cameronrwolfe.substack.com/p/can-language-models-make-their-own)]




[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9396abd-34ec-4a58-bdca-4e2548476f03_2144x700.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9396abd-34ec-4a58-bdca-4e2548476f03_2144x700.png)(from [32])

**Toolformer [32]** was one of the first works to explore the integration of LLMs with external tools. These tools are made available to the model via a simple, fixed set of text-to-text APIs; see above. To use the tools, the LLM must learn to _i)_ identify scenarios that require a tool, _ii)_ specify which tool to use, _iii)_ provide relevant textual input to the tool’s API, and _iv)_ use text returned from the API to craft a response. The LLM is taught these skills by constructing a synthetic training dataset that starts with an initial seed dataset and uses a more powerful LLM (e.g., GPT-4) to add examples of valid API calls into the data; see below. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe24f1112-591c-4cc5-845e-2b01391194b1_752x1076.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe24f1112-591c-4cc5-845e-2b01391194b1_752x1076.png)(from [32])

From here, we can simply finetune an LLM over this data. The model will learn to generate and process calls to necessary APIs directly within the textual sequence that it generates. In this case, handling API calls in an inline manner is simple because we only consider APIs with textual input and output; see below.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb430281-e4d5-4b7e-b6ea-5b76ecba8992_758x1054.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb430281-e4d5-4b7e-b6ea-5b76ecba8992_758x1054.png)(from [32])

> _“LLMs face inherent limitations, such as an inability to access up-to-date information or perform precise mathematical reasoning … enhancing current LLMs with the capability to automatically compose external tools for real-world task solving is critical to address these drawbacks.”_ \- from [19]

**Chameleon [19]** aims to mitigate the limitations of LLMs referenced above. Interestingly, some of these limitations are not addressed by existing work on integrating LLMs with external tools, as the set of tools used is typically fixed (or domain-specific) and cannot always generalize to new domains. To create a more generic framework, Chameleon uses a “plug-and-play” strategy that uses a central LLM-based controller to generate a program— _written in natural language_ —that composes several tools to solve a complex reasoning task; see below. Unlike prior work, the tools available to Chameleon are quite comprehensive; e.g., LLMs, off-the-shelf vision models, web search engines, Python functions, and more. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86507a92-7e5e-49c7-ba25-2637c6223503_1342x688.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86507a92-7e5e-49c7-ba25-2637c6223503_1342x688.png)(from [19])

The Chameleon framework has two primary components:

  1. _Planner_ : decomposes the input query into sub-tasks that can be solved via available tools. 

  2. _Module inventory_ : a set of task-specific tools (along with descriptions and usage examples) that are available for Chameleon to use. 




The planner, which is implemented with an LLM, uses natural language to generate calls to external tools (e.g., `image_captioner` or `query_generator`). We can identify these tools via simple string matching, and the sequence of tools outputted by the planner forms a natural language program that can be executed by calling each of the corresponding task-specific modules. Examples of prompts used for the planner and a task-specific module are shown below.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cbe7583-47ed-45fa-9ca6-3f53ade26520_1656x1008.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cbe7583-47ed-45fa-9ca6-3f53ade26520_1656x1008.png)(from [19])

To teach the controller when to use certain tools, we include tool descriptions and usage examples within a few-shot prompt, which can easily be extended to new tools and modules. Because we leverage the planner’s in-context learning abilities to generate a solution, no training or curated rules are required to solve real-world queries. Rather, we simply provide examples of available tools to the LLM, which can then use this information to infer a sequence of tools that can be executed to yield the correct final response to a query. Going further, this tool sequence is human readable and can be easily debugged by a human user.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08781afc-0d91-4d2b-9891-a810623c2179_1618x644.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08781afc-0d91-4d2b-9891-a810623c2179_1618x644.png)(from [19])

In experiments, Chameleon is applied to two complex, multi-modal (i.e., meaning that both text and images are involved) reasoning tasks with GPT-4: [ScienceQA](https://huggingface.co/datasets/derek-thomas/ScienceQA) and [TabMWP](https://github.com/lupantech/PromptPG). Chameleon achieves new state-of-the-art performance of 86.54% on ScienceQA, outperforming CoT prompting with GPT-4 and GPT-3 by 2.55% and 11.37%, respectively. On TabMWP, we see a similar improvement with Chameleon, which achieves an accuracy of 98.78%. However, it should be noted that Chameleon’s effectiveness is powered by GPT-4’s ability to infer constraints and construct rational/consistent plans for solving complex reasoning problems.

> _“We propose a simple yet effective method, called GPT4Tools, designed to empower open-source LLMs with the ability to use tools via self-instruct from advanced LLMs” - from [20]_

**GPT4Tools [20].** Although a variety of papers have demonstrated the ability of LLMs to leverage tools in a few-shot manner, most of these papers are dependent upon proprietary language models and purely leverage prompt engineering to facilitate tool usage, leading us to wonder if similar results could be replicated with open LLMs. In [20], authors propose an approach that uses self-instruct [21] to generate a finetuning dataset that can be used to enable open-source LLMs (e.g., [LLaMA](https://cameronrwolfe.substack.com/i/135439692/llama-a-leap-in-open-source-quality) and [OPT](https://cameronrwolfe.substack.com/i/135273362/open-pre-trained-transformers-opt-language-models)) to use a set of multimodal tools. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80abfb29-4238-4251-bda4-e06e5bededaf_1342x1160.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80abfb29-4238-4251-bda4-e06e5bededaf_1342x1160.png)(from [21])

First, authors use a self-instruct approach to generate a tool usage dataset by prompting a powerful teacher model (i.e., ChatGPT) to create examples of relevant tools being used. Within the prompts, both visual content— _captions and bounding boxes extracted from an image_ —and tool descriptions are included. The teacher leverages this information to generate tool-related instructions that can be used to process multimodal information and solve problems; see above. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde2cc6c7-ac8f-4485-98f3-ff226bdb4cbf_1880x506.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde2cc6c7-ac8f-4485-98f3-ff226bdb4cbf_1880x506.png)(from [21])

Once the dataset is generated, [Low-Rank Adaptation (LoRA)](https://cameronrwolfe.substack.com/p/easily-train-a-specialized-llm-peft) can be used to easily finetune an open-source LLM to solve a range of visual problems with the help of multimodal tools. In [20], this approach is shown to improve accuracy of calls that are made by the LLM to known tools (i.e., those included in the finetuning dataset), as well as improve the model’s ability to generalize to new tools in a zero-shot manner. A direct comparison of GPT4Tools to prior work on integrating LLMs with external tools is provided within the table above.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F551d868f-9e9b-40d0-8d4f-fdc85fdfbe8b_2138x1120.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F551d868f-9e9b-40d0-8d4f-fdc85fdfbe8b_2138x1120.png)(from [30])

**Gorilla [30].** Although many works have studied integrating LLMs with a fixed set of tools, authors in [30] tackle the broader goal of teaching an LLM to use any model API that is available online. To do this, a retrieval technique is adopted that _i)_ searches for model APIs that are relevant to solving a problem and _ii)_ adds the documentation for these APIs into the model’s context. Such an approach allows the LLM to access a massive number of changing tools, but hallucination (e.g., incorrect arguments or calls to a non-existent API) may still occur; see above.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c7983b-29ab-4301-84f2-50cd9d6aa28c_1608x536.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c7983b-29ab-4301-84f2-50cd9d6aa28c_1608x536.png)(from [30])

To solve this issue, authors in [30] construct a dataset with examples of using over 1,600 different model APIs using self-instruct [21]. Within each example, both the prompt and relevant documentation are used as context to generate an output. In other words, this is a retrieval-aware finetuning process (similar to [RAFT](https://cameronrwolfe.substack.com/i/142727381/raft-adapting-language-model-to-domain-specific-rag)); see above. The resulting model, called Gorilla (a finetuned version of [LLaMA-7B](https://cameronrwolfe.substack.com/p/llama-llms-for-everyone)), is an interface for leveraging a variety of different deep learning model APIs to solve problems. The resulting LLM can use a massive number of APIs and _can even adapt to changes in the documentation for any of these APIs!_

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469e1fa3-1ff3-48f3-a459-00210aa6fba6_1186x1414.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469e1fa3-1ff3-48f3-a459-00210aa6fba6_1186x1414.png)(from [31])

**HuggingGPT [31]** is pretty similar to Gorilla in that it explores the integration of LLMs with specialized deep learning models (e.g., for image recognition, video detection, text classification, and much more) via a tool usage approach. The LLM serves as the “brain” of a problem solving system, which plans how to solve a problem and coordinates efforts between different deep learning models that solve necessary subtasks for this problem. Unlike Gorilla, however, HuggingGPT does not perform any finetuning. Problem solving is decomposed into four steps:

  1. _Task planning:_ use the LLM to decompose a user’s request into solvable tasks.

  2. _Model selection_ : select models from HuggingFace to use for solving tasks.

  3. _Task execution_ : run each selected model and return results to the LLM.

  4. _Response generation_ : use the LLM to generate a final response for the user.




For each of these steps, we leverage prompting with curated instructions and exemplars to yield the desired behavior; see below for example prompts. Given a sufficiently powerful foundation model, such an approach is quite effective.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6466c8-645a-4bcb-a2c0-374ce1d7f900_1182x1554.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f6466c8-645a-4bcb-a2c0-374ce1d7f900_1182x1554.png)(from [31])

#### Program-Aided Language Models

>  _“The computation can be delegated to a program interpreter, which is used to execute the generated program, thus decoupling complex computation from reasoning and language understanding.”_ \- from [41]

Integrating LLMs with external tools is an interesting avenue of research, and one of the most useful tools to which these models can be given access is the ability to write and execute programs. Most prompting techniques solve complex problems in two steps:

  1. Generate a problem-solving rationale.

  2. Use this rationale to actually solve the problem.




In CoT prompting, we rely upon the LLM to solve both of these steps, _but these models only excel at solving the first step_! In fact, generating an incorrect answer despite outputting a correct rationale is a common failure case for LLMs. To solve this problem, we can teach the model to output a rationale in the form of interleaved language and code (e.g., a Python program with useful comments). Then, we can generate a final answer by simply executing the provided code!

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccd5a835-8604-44b8-a0da-27921ea8af2c_1646x1428.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccd5a835-8604-44b8-a0da-27921ea8af2c_1646x1428.png)(from [40])

**Program-Aided Language Model (PAL) [40]** is similar to CoT prompting in that the LLM is tasked with breaking a problem down into a series of intermediate steps to find a solution. However, this rationale contains both natural language and programatic components. We can execute the code from the rationale (using a sandboxed Python environment) to generate a reliable final solution— _the process of actually generating the solution is delegated to a code interpreter_. In [40], we see that an LLM that has been sufficiently trained on code (e.g., [Codex](https://arxiv.org/abs/2107.03374)) can be taught to solve problems in this way using a few-shot learning approach. 

> _“This bridges an important gap in chain-of-thought-like methods, where reasoning chains can be correct but produce an incorrect answer.”_ \- from [40]

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f486545-4d69-49e6-abb2-7f90049d7c77_2180x1530.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f486545-4d69-49e6-abb2-7f90049d7c77_2180x1530.png)(from [41])

**Program of Thoughts (PoT) prompting [41]** is quite similar to PAL in that it _i)_ uses a code-augmented prompting technique and _ii)_ delegates the process of deriving a solution to a code interpreter. This process relies upon a few-shot prompting strategy; see above. Unlike PaL, however, code written by PoT relies upon a symbolic math library called [SymPy](https://github.com/sympy/sympy). This package allows the user to define mathematical “symbols” that can be combined to form complex expressions that are evaluated via SymPy’s `solve` function; see below.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39fd5b16-44ad-4625-b434-e18951b7847f_2340x698.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39fd5b16-44ad-4625-b434-e18951b7847f_2340x698.png)(from [41])

At a high level, PoT directly addresses the inability of LLMs to solve complex equations by providing access to a symbolic math library that enables such equations to be easily composed/evaluated, whereas PAL is focused upon more generally solving problems via a combination of natural language and code. Check out [this related overview](https://cameronrwolfe.substack.com/p/program-aided-language-models) for more information on program-aided models.

#### Understanding and Using the Context Window

Given the recent popularity of RAG and emphasis upon [long context windows](https://blog.gopenai.com/how-to-speed-up-llms-and-use-100k-context-window-all-tricks-in-one-place-ffd40577b4c) within state-of-the-art LLMs, understanding how these models process the context provided in their prompts is important. Luckily, recent research has studied the topics of context windows and in-context learning in depth, resulting in several interesting takeaways that are relevant to prompt engineering. 

**Large Language Models Can Be Easily Distracted by Irrelevant Context [22].** When prompting a language model, we usually include only relevant context and information within the prompt. However, in real-world applications, the model’s prompt usually contains contextually similar information that may or may not be relevant to the particular problem being solved. With this in mind, we might wonder: _Does adding irrelevant context to the prompt have negative side effects?_

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813f7d4c-4ae4-4a1e-a073-f582cd3fbed0_1128x750.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F813f7d4c-4ae4-4a1e-a073-f582cd3fbed0_1128x750.png)(from [22])

In [22], authors study the distractibility of modern LLMs, finding that the performance of these models can drastically deteriorate when irrelevant context is included in the prompt. To measure LLM distractibility, authors introduce a new Grade-School Math with Irrelevant Context (GSM-IC) dataset, which contains arithmetic reasoning problems with irrelevant information in the problem description; see above. Then, we can measure whether an LLM is distracted by irrelevant context by simply testing if the addition of an irrelevant sentence to the model’s prompt changes the resulting solution to a problem.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd435d7aa-339a-453b-89cc-8b9807e116c4_1646x1300.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd435d7aa-339a-453b-89cc-8b9807e116c4_1646x1300.png)(from [22])

This strategy is used to test both Codex and GPT-3.5 with several different prompting techniques (see above for a depiction):

  * CoT prompting (and zero-shot CoT prompting)

  * Least-to-most prompting

  * Prompting with programs 




Interestingly, the performance of these models drastically deteriorates when irrelevant information is included in the context. However, the impact of irrelevant context can be mitigated by _i)_ using self-consistency, _ii)_ adding an instruction for the model to ignore irrelevant information, and _iii)_ including few-shot examples that demonstrate solving problems with irrelevant information. LLMs are capable of learning to ignore information via instructions or context.

> _“We prepend an instruction sentence ‘feel free to ignore irrelevant information in the problem description’ to the exemplars.”_ \- from [22]

**Lost in the Middle [23].** Generative LLMs have a text-to-text format, meaning that they take a sequence of text as input (i.e., the prompt) and produce a corresponding sequence of text as output. The input passed to the LLM has a variable length— _it can be a short (zero-shot) problem description, or it can be a complex instruction containing large amounts of external context (e.g., for RAG)._ For this reason,__ LLMs must be capable of operating over long contexts and using the entirety of this context to effectively solve downstream tasks. 

Along these lines, authors in [23] study the ability of several LLMs— _both open ([MPT](https://cameronrwolfe.substack.com/p/democratizing-ai-mosaicmls-impact)) and closed models (GPT-3.5-Turbo and Claude-1.3)_—to concretely leverage information provided to them within long contexts. In particular, two types of tasks are studied in [23]:

  * _Multi-document QA_ : similar to the standard RAG setup, this problem requires the model to reason over several documents to answer a question.

  * _Key-value retrieval_ : this is a synthetic task that tests the model’s ability to retrieve matching tokens by returning the value associated with a key from a collection of JSON key-value pairs provided as context.




When solving these tasks, authors control both _i_) the length of the input context (by using more documents or key-value pairs) and _ii)_ the position— _beginning, middle, or end_ —of the relevant context within the input. Then, we can study the impact of changes in context length and position on model performance. In experiments, we see a clear “U-shaped” performance curve (shown below) based on the position of relevant information within the model’s context. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb4a2567-cffd-41b0-ab5c-421bc0ceb498_900x1312.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb4a2567-cffd-41b0-ab5c-421bc0ceb498_900x1312.png)(from [23])

This visualization shows us that LLMs pay the most attention to information at the beginning and end of their context. When relevant information is in the middle of the context, model performance degrades significantly— _the information is “lost in the middle”_. In fact, GPT-3.5-Turbo performs better without any relevant context on multi-document QA tasks than when relevant documents are placed in the middle of the context. Performance varies a lot as we tweak the position of relevant information, and models with extended contexts do not show signs of improved robustness to these positional biases; see below. However, these issues have been improved in more recent models (e.g., [Gemini-1.5](https://blog.google/technology/ai/google-gemini-next-generation-model-february-2024/) and [Claude-3](https://www.anthropic.com/news/claude-3-family)). 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd560977c-ed29-4593-877e-71b819a39e15_906x1120.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd560977c-ed29-4593-877e-71b819a39e15_906x1120.png)(from [23])

**Large Language Models Are Latent Variable Models [24].** Although we know that LLMs have in-context learning abilities, it is unclear how these abilities emerge from standard language model pretraining. Additionally, in-context learning is generally sensitive to the choice and format of examples used for few-shot learning. Certain demonstrations are effective examples for the model, while others are not. Currently, there are no standard criteria for choosing the best examples for few-shot learning. In [24], authors study this topic, aiming to find a practical strategy for identifying the best possible few-shot exemplars. 

> _“In-context learning has been demonstrated to be an effective technique for a wide range of NLP tasks. However, it is sensitive to the choice, format, and even the order of the demonstrations used.”_ \- from [24]

Many papers have studied the mechanics of in-context learning from a theoretical perspective, but few of them provide practical or actionable insights. In [24], authors view LLMs in the lens of simple [topic](https://en.wikipedia.org/wiki/Topic_model) / [latent variable](https://en.wikipedia.org/wiki/Latent_variable_model) models that relate the generation of new tokens to prior tokens observed by the language model. The details can be found in the paper, but at a high level this formulation allows us to theoretically describe the language model’s output with respect to the format and task information used within the model’s input prompt.

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5846d77-5cac-488c-9dfd-4cabf50bd509_1888x732.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5846d77-5cac-488c-9dfd-4cabf50bd509_1888x732.png)(from [24])

From this formulation, authors develop a practical technique for selecting the best possible few-shot exemplars that uses a smaller language model to measure the [posterior probability](https://en.wikipedia.org/wiki/Posterior_probability) of the model’s input— _this tells us the likelihood of different input exemplars based upon the model’s input and parameters_. We can use exemplars selected with the smaller LLM for in-context learning with a larger model (see above), which is found to yield a practical benefit. Put simply, this paper proposes an interesting (and relatively simple) theoretical view of in-context learning that can be used in practice to select better few-shot exemplars.

#### Improving Writing Capabilities

>  _“SoT is an initial attempt at data-centric optimization for inference efficiency, and showcases the potential of eliciting high-quality answers by explicitly planning the answer structure in language.”_ \- from [25]

**Skeleton-of-Thought (SoT) [25]** is a prompting technique that aims to reduces the latency of generating output with an LLM. As we know, generating output with an LLM can be expensive for a few reasons:

  * The models are large, so compute/memory/IO costs are high.

  * The attention operation is IO bound and has memory/compute complexity that increases quadratically with sequence length.

  * The output is generated sequentially one token at at time (i.e., [using next token prediction](https://cameronrwolfe.substack.com/i/136638774/understanding-next-token-prediction)). 




In [25], authors try to address the last problem mentioned above— _the latency of sequential decoding_. Put simply, sequential decoding is a problem because we generate one token at a time and, therefore, cannot parallelize the generation of tokens in the output sequence. For this reason, the cost of generating an output is directly related to the length of the output. It takes much longer to generate an output sequence with many tokens. But, _can we avoid fully sequential decoding?_

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1467d923-adf1-41f6-a6be-c2136ffaa5c0_1606x1020.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1467d923-adf1-41f6-a6be-c2136ffaa5c0_1606x1020.png)(from [25])

We see in [25] that a more efficient decoding strategy can be devised by mimicking the thinking and writing process of humans without requiring any changes to the model, system, or hardware. In particular, humans tend to plan an outline for what they want to write, then fill in details for each element of their outline. _This is not a purely sequential process_[6](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-6-143156742)! Inspired by this idea, authors in [25] propose Skeleton-of-Thought (SoT) prompting (see above), which has two steps:

  1. Prompt the LLM to generate a skeleton/outline of its answer.

  2. Conduct parallel API calls to fill in the contents of each outline element.




Although this might seem a bit vague, we can see how this works by checking out the SoT prompt shown below. The process is pretty simple— _we just generate the skeleton and use a generic prompt template to fill in all of the remaining details._

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2e445f-f9b5-48f0-af95-e252d3d554c8_1626x986.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2e445f-f9b5-48f0-af95-e252d3d554c8_1626x986.png)(from [25])

By generating each element of the skeleton in parallel, we can save a lot on inference latency. For example, the question shown at the beginning of this summary can be answered in 12 seconds (instead of 22 seconds) without making any changes to the underlying model or system— _we just use SoT prompting_. Similar speedups are observed across 12 different LLMs in [25]. Interestingly, authors also note that creating an outline can oftentimes improve writing quality[7](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-7-143156742).

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9475efbf-e7b4-44f5-9e39-f46445e8619d_1882x1324.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9475efbf-e7b4-44f5-9e39-f46445e8619d_1882x1324.png)(from [27])

**Directional Stimulus Prompting [27].** Given the computational expense of finetuning, prompting is usually the easiest way to solve a task with an LLM. However, prompting has limitations— _guiding the LLM towards generating output with our desired content or style can be difficult_. To solve this issue, authors in [27] propose directional stimulus prompting (DSP), which introduces a “directional stimulus” into the LLM’s prompt as shown in the figure above. 

This stimulus is just a textual hint or clue that gives the LLM more information about the expected output. The directional stimulus, which is instance-specific and solely based upon the input query, is generated using a smaller model (e.g., [T5](https://cameronrwolfe.substack.com/p/t5-text-to-text-transformers-part)) that is much easier to train or finetune relative to the LLM. By doing this, we can circumvent the difficulty of directly training the LLM, choosing instead to finetune the model used to generate the directional stimulus[8](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-8-143156742). DSP is evaluated on summarization, dialogue, and reasoning tasks, where it is found to improve model performance while requiring minimal labeled data. 

[![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9afab7f-6cfd-4a75-9a91-7fead1d7beae_1528x984.png)](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9afab7f-6cfd-4a75-9a91-7fead1d7beae_1528x984.png)(from [28])

**Chain of Density Prompting [28].** Recent developments in LLMs have revolutionized the problem of automatic summarization, as we can simply prompt an LLM to generate a high-quality summary instead of performing finetuning over labeled data. When automatically generating a summary, one important aspect of the resulting summary’s quality is information density. We want the summary to present all relevant information in a concise manner, but we want to avoid writing summaries that are overly dense or illegible.

To study this tradeoff in information density, authors in [28] propose chain of density (CoD) prompting, which starts by generating a summary via a vanilla prompt to GPT-4. From here, CoD prompting is used to iteratively add additional entities into the summary while keeping the length of the summary fixed, thus increasing the summary’s information density. Interestingly, we see in [28] that humans prefer summaries that are almost as dense as human-written summaries, but more dense than those generated by a vanilla prompt to GPT-4. By using CoD prompting, we can explore this tradeoff and generate higher-quality summaries.

> _“Summaries generated by CoD are more abstractive, exhibit more fusion, and have less of a lead bias than GPT-4 summaries generated by a vanilla prompt.”_ \- from [28] 

#### Other Notable Papers

  * **Active Prompting [26]** tackles the difficulty of selecting (and annotating) exemplars for CoT prompting by providing a technique— _based upon work in uncertainty-based active learning_ —for identifying the most helpful exemplars to select (and annotate) for solving a particular reasoning problem. 

  * **TaskMatrix [33]** is a position paper— _meaning that it presents a position or outlook on a notable issue_ —that considers the integration of [foundation models](https://crfm.stanford.edu/) with millions of different APIs.

  * **Set of Marks Prompting [42]** is a visual prompting method that employs pretrained segmentation models to partition an image into regions and overlay these regions with a set of marks (i.e., alphanumerics, masks, boxes, etc.) to improve the visual grounding of models like [GPT-4V](https://openai.com/research/gpt-4v-system-card). 

  * **Multimodal CoT Prompting [43]** extends CoT prompting to inputs that include both images and text by treating rationale and answer generation as two distinct steps in the problem solving process.

  * The topic of [automatic prompting](https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/#automatic-prompt-design) (i.e., generating better prompts via an optimization process) is not explored in this post.

  * _Anything else?_ Please let me know in the comments!




## Conclusion

Within this overview, we have learned about everything from the basics of prompt engineering to cutting-edge techniques that have been proposed in the last two months! This post contains a massive amount of information, but many of the techniques we have seen are slight variations that leverage the same core prompt components: _instructions, exemplars, context, and problem-solving rationales._ Plus, we should recall the prompt engineering strategy proposed at the outset:

  1. Start by creating a comprehensive evaluation strategy that allows you to easily and quantitatively measure the quality of a prompt.

  2. The first prompt you write should be simple (e.g., an instruction prompt). 

  3. As you make the prompt more complex, make sure that the added complexity results in a corresponding performance improvement.

  4. Continue iterating on the prompt until the desired performance is reached.




Many problems can be solved via simple instruction and few-shot prompts. For complex reasoning problems, it may be necessary to use a more advanced strategy like CoT prompting with self-consistency. Additionally, we have seen a variety of prompting strategies that are useful for specific problem domains (e.g., PoT prompting for math problems or CoD prompting for summarization). Although being aware of these techniques is useful, their use cases are relatively rare, and we should only use them if we see a clear and measurable performance impact. 

#### New to the newsletter?

Hi! I’m [Cameron R. Wolfe](https://cameronrwolfe.me/), and this is the Deep (Learning) Focus newsletter, where I help readers understand AI research. If you like the newsletter, please subscribe, share it, or follow me on [X](https://twitter.com/cwolferesearch) and [LinkedIn](https://www.linkedin.com/in/cameron-r-wolfe-ph-d-04744a238/)!

Subscribe

#### Bibliography

[1] Saravia, Elvis, et al. “Prompt Engineering Guide”, <https://github.com/dair-ai/Prompt-Engineering-Guide> (2022).

[2] Radford, Alec, et al. "Language Models are Unsupervised Multitask Learners."

[3] Brown, Tom, et al. "Language models are few-shot learners."  _Advances in neural information processing systems_ 33 (2020): 1877-1901.

[4] Work, What Makes In-Context Learning. "Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?."

[5] Zhao, Zihao, et al. "Calibrate before use: Improving few-shot performance of language models."  _International conference on machine learning_. PMLR, 2021.

[6] Ouyang, Long, et al. "Training language models to follow instructions with human feedback."  _Advances in neural information processing systems_ 35 (2022): 27730-27744.

[7] Ye, Seonghyeon, et al. "Investigating the effectiveness of task-agnostic prefix prompt for instruction following."  _Proceedings of the AAAI Conference on Artificial Intelligence_. Vol. 38. No. 17. 2024.

[8] Thoppilan, Romal, et al. "Lamda: Language models for dialog applications."  _arXiv preprint arXiv:2201.08239_ (2022).

[9] Rae, Jack W., et al. "Scaling language models: Methods, analysis & insights from training gopher."  _arXiv preprint arXiv:2112.11446_ (2021).

[10] Wei, Jason, et al. "Chain-of-thought prompting elicits reasoning in large language models."  _Advances in neural information processing systems_ 35 (2022): 24824-24837.

[11] Kojima, Takeshi, et al. "Large language models are zero-shot reasoners."  _arXiv preprint arXiv:2205.11916_ (2022).

[12] Wang, Xuezhi, et al. "Self-consistency improves chain of thought reasoning in language models."  _arXiv preprint arXiv:2203.11171_ (2022).

[13] Zhou, Denny, et al. "Least-to-most prompting enables complex reasoning in large language models."  _arXiv preprint arXiv:2205.10625_ (2022).

[14] Yao, Shunyu, et al. "Tree of thoughts: Deliberate problem solving with large language models."  _arXiv preprint arXiv:2305.10601_ (2023).

[15] Zhang, Zhuosheng, et al. "Automatic chain of thought prompting in large language models."  _arXiv preprint arXiv:2210.03493_ (2022).

[16] Fu, Yao, et al. "Complexity-based prompting for multi-step reasoning."  _The Eleventh International Conference on Learning Representations_. 2022.

[17] Zheng, Chuanyang, et al. "Progressive-hint prompting improves reasoning in large language models."  _arXiv preprint arXiv:2304.09797_ (2023).

[18] Khot, Tushar, et al. "Decomposed prompting: A modular approach for solving complex tasks."  _arXiv preprint arXiv:2210.02406_ (2022).

[19] Lu, Pan, et al. "Chameleon: Plug-and-play compositional reasoning with large language models."  _Advances in Neural Information Processing Systems_ 36 (2024).

[20] Yang, Rui, et al. "Gpt4tools: Teaching large language model to use tools via self-instruction."  _Advances in Neural Information Processing Systems_ 36 (2024).

[21] Wang, Yizhong, et al. "Self-instruct: Aligning language models with self-generated instructions."  _arXiv preprint arXiv:2212.10560_ (2022).

[22] Shi, Freda, et al. "Large language models can be easily distracted by irrelevant context."  _International Conference on Machine Learning_. PMLR, 2023.

[23] Liu, Nelson F., et al. "Lost in the middle: How language models use long contexts."  _Transactions of the Association for Computational Linguistics_ 12 (2024): 157-173.

[24] Wang, Xinyi, et al. "Large language models are latent variable models: Explaining and finding good demonstrations for in-context learning."  _Advances in Neural Information Processing Systems_ 36 (2024).

[25] Ning, Xuefei, et al. "Skeleton-of-thought: Large language models can do parallel decoding."  _arXiv preprint arXiv:2307.15337_ (2023).

[26] Diao, Shizhe, et al. "Active prompting with chain-of-thought for large language models."  _arXiv preprint arXiv:2302.12246_ (2023).

[27] Li, Zekun, et al. "Guiding large language models via directional stimulus prompting."  _Advances in Neural Information Processing Systems_ 36 (2024).

[28] Adams, Griffin, et al. "From sparse to dense: GPT-4 summarization with chain of density prompting."  _arXiv preprint arXiv:2309.04269_ (2023).

[29] Zhu, Zhaocheng, et al. "Large language models can learn rules."  _arXiv preprint arXiv:2310.07064_ (2023).

[30] Patil, Shishir G., et al. "Gorilla: Large language model connected with massive apis."  _arXiv preprint arXiv:2305.15334_ (2023).

[31] Shen, Yongliang, et al. "Hugginggpt: Solving ai tasks with chatgpt and its friends in huggingface."  _arXiv preprint arXiv:2303.17580_ (2023).

[32] Schick, Timo, et al. "Toolformer: Language models can teach themselves to use tools."  _arXiv preprint arXiv:2302.04761_ (2023).

[33] Liang, Yaobo, et al. "Taskmatrix. ai: Completing tasks by connecting foundation models with millions of apis."  _arXiv preprint arXiv:2303.16434_ (2023).

[34] Chen, Shouyuan, et al. "Extending context window of large language models via positional interpolation."  _arXiv preprint arXiv:2306.15595_ (2023).

[35] Besta, Maciej, et al. "Graph of Thoughts: Solving Elaborate Problems with Large Language Models."  _arXiv preprint arXiv:2308.09687_ (2023).

[36] Yao, Yao, Zuchao Li, and Hai Zhao. "Beyond Chain-of-Thought, Effective Graph-of-Thought Reasoning in Large Language Models."  _arXiv preprint arXiv:2305.16582_ (2023).

[37] Lewis, Patrick, et al. "Retrieval-augmented generation for knowledge-intensive nlp tasks."  _Advances in Neural Information Processing Systems_ 33 (2020): 9459-9474.

[38] Ovadia, Oded, et al. "Fine-tuning or retrieval? comparing knowledge injection in llms."  _arXiv preprint arXiv:2312.05934_ (2023).

[39] Liu, Jiacheng, et al. "Generated knowledge prompting for commonsense reasoning."  _arXiv preprint arXiv:2110.08387_ (2021).

[40] Gao, Luyu, et al. "PAL: Program-aided Language Models."  _arXiv preprint arXiv:2211.10435_ (2022).

[41] Chen, Wenhu, et al. "Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks."  _arXiv preprint arXiv:2211.12588_ (2022).

[42] Yang, Jianwei, et al. "Set-of-mark prompting unleashes extraordinary visual grounding in gpt-4v."  _arXiv preprint arXiv:2310.11441_ (2023).

[43] Zhang, Zhuosheng, et al. "Multimodal chain-of-thought reasoning in language models."  _arXiv preprint arXiv:2302.00923_ (2023).

[1](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-1-143156742)

Remember, longer prompts are always more expensive! When using an API, you pay for these tokens directly. For open-source models, you pay for the extra tokens in extra compute and latency costs. 

[2](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-2-143156742)

For a great overview of these techniques (as well as more prompting techniques and a variety of other awesome topics), check out [Lillian Weng’s blog](https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/)!

[3](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-3-143156742)

To eliminate this issue, we can randomly order or even permute the exemplars within the prompt and generate output for multiple permutations of exemplars.

[4](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-4-143156742)

In fact, poor reasoning capabilities are one of the [go-to criticisms](https://bdtechtalks.com/2022/06/27/large-language-models-logical-reasoning/) of modern LLMs. Many researchers cite the inability of LLMs to reason as evidence of a shallow understanding of important concepts. 

[5](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-5-143156742)

Many researchers have argued that this majority vote strategy is insufficient for solving complex problems. This has led to a lot of research on prompt ensembles and other self-consistency variants that was in-depth [here](https://cameronrwolfe.substack.com/p/prompt-ensembles-make-llms-more-reliable). 

[6](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-6-143156742)

In fact, writing this newsletter is far from sequential. My writing strategy is usually to _i)_ overview a bunch of similar papers, _ii)_ add some sections with shared ideas and background, then _iii)_ write the intro and conclusion. This is the exact opposite of a sequential process (the intro is the last thing that I write!). 

[7](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-7-143156742)

When we ask the LLM to generate a rationale our outline for its answer, we oftentimes see a benefit from this process, similarly to benefits observed with CoT prompting. However, it is worth noting that SoT prompting performs multiple disjoint generations (i.e., one to generate the skeleton, then one for each skeleton component), while a CoT prompt is typically used to generate output in a single pass.

[8](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering#footnote-anchor-8-143156742)

This model can be finetuned using either [supervised finetuning (SFT)](https://cameronrwolfe.substack.com/p/understanding-and-using-supervised) or an RL-based strategy similar to [RLHF](https://cameronrwolfe.substack.com/p/the-story-of-rlhf-origins-motivations). 

111

#### Share this post

[![](https://substackcdn.com/image/fetch/w_520,h_272,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f77fa47-f998-420e-a4f3-2defeea24374_2124x1194.png)![Deep \(Learning\) Focus](https://substackcdn.com/image/fetch/w_36,h_36,c_fill,f_auto,q_auto:good,fl_progressive:steep,g_auto/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fab9b43fb-52d5-40da-995d-5b7cd3f91064_896x896.png)Deep (Learning) FocusModern Advances in Prompt Engineering](https://substack.com/home/post/p-143156742?utm_campaign=post&utm_medium=web)

Copy linkFacebookEmailNotesMore

[7](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comments)17

[Share](javascript:void\(0\))

#### Discussion about this post

CommentsRestacks

![](https://substackcdn.com/image/fetch/w_32,h_32,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack.com%2Fimg%2Favatars%2Fdefault-light.png)

[![](https://substackcdn.com/image/fetch/w_32,h_32,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3fc2c28-5d9e-49f1-a5cd-4c9b7aa92a17_144x144.png)](https://substack.com/profile/71642608-aj-sutter?utm_source=comment)

[A.J. Sutter](https://substack.com/profile/71642608-aj-sutter?utm_source=substack-feed-item)

[May 8](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comment/55829055 "May 8, 2024, 2:39 AM")

Liked by Cameron R. Wolfe, Ph.D.

What is the timeframe for something to be "modern," in this context? ChatGPT wasn't even released 18 months ago! Isn't it ALL "modern"?

Expand full comment

ReplyShare

[1 reply by Cameron R. Wolfe, Ph.D.](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comment/55829055)

[![](https://substackcdn.com/image/fetch/w_32,h_32,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d901c5d-3302-41b0-ae2b-355cc4847a12_144x144.png)](https://substack.com/profile/165373393-faraz-ansari?utm_source=comment)

[Faraz Ansari](https://substack.com/profile/165373393-faraz-ansari?utm_source=substack-feed-item)

[May 3](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comment/55457947 "May 3, 2024, 4:42 PM")

Liked by Cameron R. Wolfe, Ph.D.

This is really nice and detailed reference material for LLMs and prompt engineering. I really liked the images and illustrations. Which tool do you use to create these elegant workflow images?

Expand full comment

ReplyShare

[1 reply by Cameron R. Wolfe, Ph.D.](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comment/55457947)

[5 more comments...](https://cameronrwolfe.substack.com/p/modern-advances-in-prompt-engineering/comments)

TopLatestDiscussions

No posts

Ready for more?

Subscribe

© 2025 Cameron R. Wolfe

[Privacy](https://substack.com/privacy) ∙ [Terms](https://substack.com/tos) ∙ [Collection notice](https://substack.com/ccpa#personal-data-collected)

[ Start Writing](https://substack.com/signup?utm_source=substack&utm_medium=web&utm_content=footer)[Get the app](https://substack.com/app/app-store-redirect?utm_campaign=app-marketing&utm_content=web-footer-button)

[Substack](https://substack.com) is the home for great culture

#### Share

Copy linkFacebookEmailNotesMore

This site requires JavaScript to run correctly. Please [turn on JavaScript](https://enable-javascript.com/) or unblock scripts 


url: https://arxiv.org/html/2403.15886v1
title: Leveraging Zero-Shot Prompting for Efficient Language Model Distillation
scrape_date: 2025-03-17T12:18:26.264301
content_type: markdown
hash: e2b7c5bf37d006f796c7c34e868996161ad546092eaca042b84d9e7a2b3a9a25
content:
  1. [1 Introduction](https://arxiv.org/html/2403.15886v1#S1 "1 Introduction ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
  2. [2 Related Work](https://arxiv.org/html/2403.15886v1#S2 "2 Related Work ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
  3. [3 Methodology](https://arxiv.org/html/2403.15886v1#S3 "3 Methodology ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
  4. [4 Experimental Design](https://arxiv.org/html/2403.15886v1#S4 "4 Experimental Design ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    1. [4.1 Models](https://arxiv.org/html/2403.15886v1#S4.SS1 "4.1 Models ‣ 4 Experimental Design ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    2. [4.2 Datasets](https://arxiv.org/html/2403.15886v1#S4.SS2 "4.2 Datasets ‣ 4 Experimental Design ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
  5. [5 Results](https://arxiv.org/html/2403.15886v1#S5 "5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    1. [5.1 Prompt Optimization](https://arxiv.org/html/2403.15886v1#S5.SS1 "5.1 Prompt Optimization ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    2. [5.2 Finetuning and Distillation](https://arxiv.org/html/2403.15886v1#S5.SS2 "5.2 Finetuning and Distillation ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    3. [5.3 Cost Efficiency](https://arxiv.org/html/2403.15886v1#S5.SS3 "5.3 Cost Efficiency ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    4. [5.4 Effect of Explanation Rate on Student Accuracy](https://arxiv.org/html/2403.15886v1#S5.SS4 "5.4 Effect of Explanation Rate on Student Accuracy ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    5. [5.5 Effect of Explanation Length on Student Accuracy](https://arxiv.org/html/2403.15886v1#S5.SS5 "5.5 Effect of Explanation Length on Student Accuracy ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
  6. [6 Conclusion](https://arxiv.org/html/2403.15886v1#S6 "6 Conclusion ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")
    1. [6.0.1 \discintname](https://arxiv.org/html/2403.15886v1#S6.SS0.SSS1 "6.0.1 \\discintname ‣ 6 Conclusion ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation")



HTML conversions [sometimes display errors](https://info.dev.arxiv.org/about/accessibility_html_error_messages.html) due to content that did not convert correctly from the source. This paper uses the following packages that are not yet supported by the HTML conversion tool. Feedback on these issues are not necessary; they are known and are being worked on.

  * failed: acro



Authors: achieve the best HTML results from your LaTeX submissions by following these [best practices](https://info.arxiv.org/help/submit_latex_best_practices.html).

License: CC BY-NC-SA 4.0

arXiv:2403.15886v1 [cs.CL] 23 Mar 2024

\DeclareAcronym

OPRO short = OPRO, long = Optimization by Prompting, \DeclareAcronymLLM short = LLM, long = Large Language Model, \DeclareAcronymNLP short = NLP, long = Natural Language Processing, \DeclareAcronymNLI short = NLI, long = Natural Language Inference, \DeclareAcronymCoT short = CoT, long = Chain of Thought, \DeclareAcronymCQA short = CQA, long = Commonsense Question-Answering, 

11institutetext:  Humboldt-Universität zu Berlin, Unter den Linden 6, 10117 Berlin 22institutetext: Bucharest University of Economic Studies, Pia\textcommabelowta Romană 8, 010374 Bucharest

# Leveraging Zero-Shot Prompting for Efficient Language Model Distillation

Lukas Vöge 11 Vincent Gurgul (✉) 11 Stefan Lessmann 11 2 2

###### Abstract

This paper introduces a novel approach for efficiently distilling \acpLLM into smaller, application-specific models, significantly reducing operational costs and manual labor. Addressing the challenge of deploying computationally intensive \acpLLM in specific applications or edge devices, this technique utilizes \acpLLM’ reasoning capabilities to generate labels and natural language rationales for unlabeled data. Our approach enhances both finetuning and distillation by employing a multi-task training framework where student models mimic these rationales alongside teacher predictions. Key contributions include the employment of zero-shot prompting to elicit teacher model rationales, reducing the necessity for handcrafted few-shot examples and lowering the overall token count required, which directly translates to cost savings given the pay-per-token billing model of major tech companies’ \acLLM APIs. Additionally, the paper investigates the impact of explanation properties on distillation efficiency, demonstrating that minimal performance loss occurs even when rationale augmentation is not applied across the entire dataset, facilitating further reductions of tokens. This research marks a step toward the efficient training of task-specific models with minimal human intervention, offering substantial cost-savings while maintaining, or even enhancing, performance.

###### Keywords: 

Large Language Models Knowledge Distillation Zero-Short Learning Multi-task Training 

##  1 Introduction

The rapid advancement of \acpLLM such as ChatGPT has facilitated significant progress in \acNLP, offering unprecedented performance across a wide array of tasks. \acpLLM, by their nature, embody extensive knowledge bases and reasoning abilities but come with high computational and memory costs, making their direct application in specific real-world tasks inefficient. This challenge has catalyzed the exploration of techniques to distill the essence of \acpLLM into smaller, more manageable models through two primary methodologies: finetuning and distillation. Finetuning adjusts pre-trained models to specific tasks using human-labeled data, while distillation transfers knowledge from a large teacher model to a smaller student model, often leveraging the teacher’s outputs as training data. Both strategies conventionally require substantial volumes of high-quality data, with finetuning being limited by the availability and cost of human annotations, and distillation grappling with the inherent noise in \acLLM-generated labels. 

Addressing these limitations, our work builds upon the innovative approach proposed by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)], which utilizes LLMs to generate not only labels for unlabeled data but also natural language rationales that justify these labels. This method, termed step-by-step distillation by the authors, formulates finetuning and distillation as a multi-task process where the student model learns to replicate both the label and the rationale provided by the teacher, significantly enhancing the efficiency and performance of smaller models with less data.

This paper further advances step-by-step distillation by applying zero-shot prompting techniques to procure label-rationale pairs from teacher \acpLLM, eliminating the labor-intensive creation of few-shot examples as previously required by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)]. This approach, leveraging instruction-tuned models like GPT-3.5-turbo, presents a substantial reduction in operational costs, particularly for applications relying on pay-per-token APIs from major tech companies. This cost-efficiency improvement forms the cornerstone of our primary research goal: to enhance the economic viability of step-by-step distillation by minimizing the data queried from teacher \acpLLM.

Furthermore, we delve into the effects of rationale properties on the distillation process—a relatively underexplored area in current literature. Our investigations cover the optimal number of dataset instances requiring rationales, the impact of rationale accuracy, and how the length of explanations influences the performance of student models of varying sizes.

With these objectives, our paper contributes to the understanding and application of \acLLM distillation, providing insights into how to leverage \acLLM reasoning capabilities more efficiently. Through a structured exploration covering both the cost-efficient employment of zero-shot prompts and the strategic use of rationales, this study unveils practical strategies for enhancing the performance of task-specific models with minimal resource expenditure. Our work starts with an overview of related literature, followed by a presentation of our methodology and experimental design, and ends in a discussion of our findings and their implications for the field.

##  2 Related Work

Step-by-step distillation is a technique that leverages teacher LLMs to generate explanatory rationales alongside predictions, thereby enriching the data used for finetuning smaller models. Central to this methodology, pioneered by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)], is the application of \acCoT prompting, as proposed by [[16](https://arxiv.org/html/2403.15886v1#bib.bib16)]. This technique induces \acpLLM to generate intermediate reasoning steps in their answer, which is shown to greatly improve the quality of responses to questions that require multi-step logic. In this context there are two approaches: 1) zero-shot prompting, which involves guiding language models with a task description alone, requiring no previous examples, and 2) few-shot prompting, which involves providing a small number of example outputs to teach the model how to approach a task. Few-shot learning has shown superior performance on many tasks compared to zero-shot methods, though some studies present contrary findings, highlighting situations where zero-shot prompting is equally effective [[9](https://arxiv.org/html/2403.15886v1#bib.bib9)].

By employing few-shot \acCoT prompting and a 540B PaLM model as a teacher [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)] achieve enhanced student model performance with fewer data points compared to standard finetuning and distillation on various \acNLI tasks. They finetune T5 models of various sizes on a dual-task framework, optimizing both label accuracy and rationale coherence through a composite of cross-entropy losses. The process of step-by-step distillation is depicted in Fig. [1](https://arxiv.org/html/2403.15886v1#S2.F1 "Figure 1 ‣ 2 Related Work ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation").

![Refer to caption](extracted/5490966/step_by_step.png) Figure 1: Step-by-step distillation as proposed by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)]

A similar strategy is adopted by [[8](https://arxiv.org/html/2403.15886v1#bib.bib8)], focusing on enhancing T5 models for question answering with nuanced \acCoT prompting. However, their methodology necessitates access to ground truth labels for optimizing rationale quality, diverging from [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)] where direct access to labels is not a prerequisite.

[[3](https://arxiv.org/html/2403.15886v1#bib.bib3)] introduce a shift towards zero-shot \acCoT prompting as proposed by [[5](https://arxiv.org/html/2403.15886v1#bib.bib5)], eliminating the reliance on pre-crafted examples and instead exploring a broader interaction with the teacher model to collect a large sample of rationales per dataset instance. This approach, however, leads to increased token consumption due to extensive querying and once again requires access to ground truth labels for rationale pruning. Furthermore, they apply next token prediction, finetuning on complete prompt-rationale-label sequences, which differs from the segmented approach of separately predicting labels and rationales.

[[2](https://arxiv.org/html/2403.15886v1#bib.bib2)] explores the distillation of multi-step reasoning skills from \acpLLM into sub-10B parameter models, focusing on domain-specific capabilities. Utilizing tasks from the GSM8K [[1](https://arxiv.org/html/2403.15886v1#bib.bib1)] and BigBench Hard [[14](https://arxiv.org/html/2403.15886v1#bib.bib14)] datasets, they investigate the balance between reasoning abilities and model size. Their distillation process, capturing labels from a GPT-3 teacher model in a zero-shot manner, notably does not involve rationale extraction. Their objective centers on minimizing the Kullback-Leibler Divergence between teacher and student model outputs, in turn creating the challenge of accessing the teacher’s distribution over its vocabulary. This study validates the potential for smaller models to adopt \acCoT processes.

Unlike the above studies, [[7](https://arxiv.org/html/2403.15886v1#bib.bib7)] examine the effect of rationale properties on distillation efficiency. They compile a substantial rationale pool for each data point, selectively refining it by excluding inaccuracies, assuming ground-truth label availability. Their investigation into how rationale quantity and diversity influence student model performance underscores the importance of rationale construction for distillation success.

All rationale-based approaches either utilize big few-shot prompts to obtain the required label-rationale pairs or sample between many rationales for each data point. Both of these approaches imply large numbers of tokens that need to be sent and received from the teacher \acLLM and a lot of human labor. Building upon [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)], our study introduces a novel step-by-step distillation approach based around zero-shot prompting, which facilitates substantial cost-savings by lowering the token requirement and removes the need for any human input. Furthermore, our method does not presuppose access to ground truth labels for rationale validation. We extend the exploration into the impacts of rationale properties on distillation efficiency, by analyzing how rationale length, accuracy, and style affect distilled model performance. This provides several new insights into the efficient application of \acCoT prompting in \acLLM distillation.

##  3 Methodology

Our methodology advances the field of \acLLM distillation by leveraging zero-shot \acCoT prompting to efficiently distill \acpLLM into smaller, specialized models. This approach focuses on overcoming the inherent challenges associated with traditional few-shot \acCoT prompting, notably the extensive token usage and the need for elaborate prompt designs that can accurately convey task requirements, style, and formatting in a concise manner.

Our approach is based on instruction-tuned language models, which can generate detailed rationales and label responses even without explicit few-shot examples. While few-shot prompting has shown to effectively guide models to produce responses in a desired format, it often results in lengthy prompts that are counterproductive to our goal of reducing computational costs. Crafting a suitable zero-shot prompt which uses significantly fewer tokens while still eliciting high-quality rationale-label pairs presents a challenge. For example, we must ensure that the model’s responses adhere to a predictable format for easy downstream processing, a task complicated by the varied nature of model outputs, even to identical prompts.

To address these challenges, we develop a strategy that not only seeks to minimize the length and increase the efficiency of prompts but also ensures the quality of generated rationales and labels. Our method involves the optimization of zero-shot prompting to identify a template that maximizes the accuracy of generated labels and the inclusion rate of rationales, a critical factor given the sensitivity of models to slight variations in prompt wording and structure. Through this adaptation of step-by-step distillation, we address the main challenges of reducing token usage, minimizing human input and ensuring the generation of predictable, format-consistent model responses.

![Refer to caption](extracted/5490966/zero_shot_sbs.png) Figure 2: Overview of the proposed zero-shot step-by-step distillation

We try to find a zero-shot prompt template P𝑃Pitalic_P that maximizes the student model accuracy AS⁢(AT⁢(P),𝑋𝑅⁢(P),S⁢(P))subscript𝐴𝑆subscript𝐴𝑇𝑃𝑋𝑅𝑃𝑆𝑃A_{S}(A_{T}(P),\mathit{XR}(P),S(P))italic_A start_POSTSUBSCRIPT italic_S end_POSTSUBSCRIPT ( italic_A start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ( italic_P ) , italic_XR ( italic_P ) , italic_S ( italic_P ) ) via step-by-step distillation. Here, 𝑋𝑅𝑋𝑅\mathit{XR}italic_XR is the explanation rate, that is, the fraction of teacher responses that include a rationale, and S𝑆Sitalic_S is the style of the explanation, which includes formatting and length. Since this connection is extremely expensive to measure directly, we approximate the student model accuracy ASsubscript𝐴𝑆A_{S}italic_A start_POSTSUBSCRIPT italic_S end_POSTSUBSCRIPT with the teacher \acLLM accuracy AT⁢(P)subscript𝐴𝑇𝑃A_{T}(P)italic_A start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ( italic_P ) and explanation rate 𝑋𝑅⁢(P)𝑋𝑅𝑃\mathit{XR}(P)italic_XR ( italic_P ). This is feasible, as [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)] shows, due to the positive correlation between the accuracy of teacher label-rationale pairs and the student model accuracy.

Maximization for 𝑋𝑅⁢(P)𝑋𝑅𝑃\mathit{XR}(P)italic_XR ( italic_P ) and S⁢(P)𝑆𝑃S(P)italic_S ( italic_P ) happens implicitly, as [[16](https://arxiv.org/html/2403.15886v1#bib.bib16)] demonstrate in their \acCoT prompting research, since rationales improve the accuracy of \acLLM-predicted labels on tasks that require reasoning. The best performing prompt will therefore also have a high explanation rate. This assumption is additionally supported by our choice of teacher model, which has a very high explanation rate by default, and is confirmed in our experiments. No additional consideration is required to obtain high accuracy prompts with equally high explanation rates. Therefore, our optimization problem simplifies to:

| arg⁡maxP⁡AT⁢(P)subscript𝑃subscript𝐴𝑇𝑃\arg\max_{P}A_{T}(P)roman_arg roman_max start_POSTSUBSCRIPT italic_P end_POSTSUBSCRIPT italic_A start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ( italic_P ) |   
---|---|---  
  
The process of finding the optimal prompt template P𝑃Pitalic_P is constrained by two main challenges—the set of all possible prompt templates is infinite, and prompts are discrete. Additionally, the prompt must generate responses that can be parsed into distinct label and rationale parts and minimal human intervention should be required.

We address these challenges by applying the \acOPRO framework [[17](https://arxiv.org/html/2403.15886v1#bib.bib17)], which leverages \acpLLM themselves to generate and optimize candidate prompts. This approach allows for the optimization in scenarios where gradient-based techniques are not feasible and has been shown to outperform manual rewriting and few-shot prompting [[12](https://arxiv.org/html/2403.15886v1#bib.bib12), [18](https://arxiv.org/html/2403.15886v1#bib.bib18)]. By formulating our objectives in natural language, we leverage the \acLLM’s own capabilities to refine and propose prompts that are likely to yield more accurate and consistent label-rationale pairs.

![Refer to caption](extracted/5490966/opro.png) Figure 3: Overview of the OPRO framework by [[17](https://arxiv.org/html/2403.15886v1#bib.bib17)]

The \acOPRO mechanism functions by iterating over cycles of prompt generation and evaluation. Starting with a meta-prompt that includes a task description and examples of scored solutions from previous iterations, the language model generates new prompt candidates. These candidates are then evaluated based on their ability to elicit accurate labels and coherent rationales from a subset of data. The evaluation process involves parsing the model’s responses to separate labels from rationales and comparing these labels against a predefined set of ground truth labels to calculate accuracy. This iterative process encourages the generation of prompts that facilitate easy parsing into labels and rationales while minimizing the need for human intervention.

##  4 Experimental Design

Our experiment is designed to evaluate the efficacy of our zero-shot step-by-step distillation methodology. To this end, we outline the datasets employed to test the generalizability and robustness of our approach, as well as the specifics of the teacher and student models utilized in the distillation process.

###  4.1 Models

We utilize OpenAI’s ‘gpt-3.5-turbo’ as the teacher model, accessed through the OpenAI API on a pay-per-token basis. GPT 3.5 is trained to follow instructions and answer questions in a dialog manner [[11](https://arxiv.org/html/2403.15886v1#bib.bib11)]. It usually includes rationales in its responses by default, which we leverage for our distillation process. We conjecture that GPT’s optimization for following of zero-shot instructions gives it an edge over other \acpLLM in our application.

The student models employed in our study are T5 models of varying sizes (‘small’ with 77M parameters, ‘base’ with 250M parameters, ‘large’ with 800M parameters, and ‘XL’ with 3B parameters), which have proven their efficacy in transfer learning [[13](https://arxiv.org/html/2403.15886v1#bib.bib13)]. Specifically, we use the T5 v1.1 models which were only pretrained on the C4 Common Crawl dataset for general language understanding without additional task-specific finetuning. The use of text-to-text models allows for straightforward processing, as both the labels and rationales can be cast as text sequences, simplifying preprocessing and tokenization.

###  4.2 Datasets

Our main dataset is the first subset of the ANLI database, a collection of \acNLI tasks released by [[10](https://arxiv.org/html/2403.15886v1#bib.bib10)], henceforth referred to as ANLI1. It consists of premise-hypothesis pairs, where the hypothesis either entails, contradicts or is neutral towards the premise and is aimed to benchmark the natural language understanding of \acpLLM.

Table 1: Sample of the ANLI1 dataset Premise | Hypothesis | Label  
---|---|---  
The Parma trolleybus system (Italian: “Rete filoviaria di Parma”) forms part of the public transport network of the city and “comune” of Parma, in the region of Emilia-Romagna, northern Italy. In operation since 1953, the system presently comprises four urban routes. |  The trolleybus system has over 2 urban routes. | entailment  
Will Vodery (October 8, 1885 - November 18, 1951) was an African American composer, conductor, orchestrator, and arranger, and one of the few black Americans of his time to make a name for himself as a composer on Broadway, working largely for Florenz Ziegfeld. |  Will Vodery wrote a song in 1900. | neutral  
The Ten Commandments of Dog Ownership, also known as The Ten Commandments from a Pet’s Point of View, or simply Ten Commandments For Dog Owners is a set of pet ownership rules. It was created in 1993 by Stan Rawlinson, and is written from the point of view of a dog. |  The Ten Commandments of Dog Ownership were created after 1994. | contradiction  
  
The second dataset used in our experiment is the \acCQA database by [[15](https://arxiv.org/html/2403.15886v1#bib.bib15)], a question answering challenge designed to evaluate the ability to reason with commonsense knowledge. It is a collection of multiple-choice questions, that require some form of prior world knowledge to be answered. It therefore does not only test a machine’s ability to comprehend the natural language question and answer options, but also its ability to understand concepts that cannot be inferred from the question alone.

Table 2: Sample of the CQA dataset Question | Answer options | Label  
---|---|---  
“There are 10 apples on an apple tree. Three fall off. Now there are X apples.” What is this an example of? |  park, coloring book, garden center, math problem, gravity | math problem  
A bald eagle flies over St. Paul, where is it? |  texas, thermal, minnesota, canada, photograph | minnesota  
  
Dataset statistics are provided in Table [3](https://arxiv.org/html/2403.15886v1#S4.T3 "Table 3 ‣ 4.2 Datasets ‣ 4 Experimental Design ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation"). In the case of \acCQA, the validation split is a 10 % random subsample of the training split, since no dedicated validation split including ground truth labels is available. In both cases, we evaluate the performance of our \acpLLM using the accuracy metric.

Table 3: Dataset sizes Dataset | Train | Test | Eval  
---|---|---|---  
ANLI1 |  16,946 |  1,000 |  1,000  
CQA |  8,766 |  1,221 |  975  
  
##  5 Results

This section presents the findings from our experiments, with each subsection providing different insights into the advantages and implications of our distillation approach. We begin by detailing the results of the prompt optimization process using the \acOPRO mechanism. Following this, we explore the impact of our zero-shot step-by-step distillation approach on the finetuning and distillation accuracy of student models and compare it to few-shot step-by-step distillation. We also analyze the cost efficiency of our approach compared to few-shot methods, highlighting the cost-savings enabled by zero-shot prompting. Finally, we investigate the effects of explanation rates and rationale lengths on student model accuracy.

###  5.1 Prompt Optimization

We ran 22 iterations of \acOPRO in our setup, where each iteration consisted of 8 new candidate prompts being created (querying the meta-prompt 8 times) and evaluated on 25 dataset instances, yielding a total of 176 different prompt templates that have been evaluated. These numbers were chosen based on the results reported in the original paper [[17](https://arxiv.org/html/2403.15886v1#bib.bib17)]. The progression of the optimization on the ANLI1 dataset is displayed in Fig. [4](https://arxiv.org/html/2403.15886v1#S5.F4 "Figure 4 ‣ 5.1 Prompt Optimization ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation").

![Refer to caption](extracted/5490966/opro_results.png) Figure 4: \acOPRO progression on ANLI1

We cannot rule out that more iterations might give an even better prompt template, but the optimization curve is clearly flattening out and the best prompt found already has an accuracy of 71.0 %, which is better than any benchmark result available for the ANLI1 dataset in current research [[6](https://arxiv.org/html/2403.15886v1#bib.bib6)]. It is also better than the 540B PaLM few-shot accuracy of 70.9 % achieved by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)]. The final result of the prompt optimizations and their respective teacher label accuracy and explanation rate are found in Table [4](https://arxiv.org/html/2403.15886v1#S5.T4 "Table 4 ‣ 5.1 Prompt Optimization ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation").

Table 4: Prompts resulting from OPRO

Dataset | Final prompt | Teacher   
accuracy | Explanation rate*  
---|---|---|---  
ANLI1 |  Based on {premise}, determine whether the claim “{hypothesis}” is true, false, or inconclusive? |  70.98 % |  87.18 %  
CQA |  Given the following options, what do you think is the correct answer to the question below: {question} Options: a) {choice_a} b) {choice_b} c) {choice_c} d) {choice_d} e) {choice_e} Explain your answer with one sentence. |  72.40 % |  99.40 %  
  
* Percentage of teacher responses that included a rationale

###  5.2 Finetuning and Distillation

Our experiments assess the efficacy of finetuning and distillation processes on student models, using the ANLI1 and CQA benchmark datasets and the 250M T5-Base student model. Our aim is to validate the practical advantages of step-by-step distillation over established methods in general, and the robustness of zero-shot step-by-step learning in particular. We examine setups with access to ground truth labels (finetuning) and without access to ground truth labels (distillation). In either case, we investigate the standard approach (without rationales), the few-shot step-by-step method as per [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)], and our zero-shot step-by-step approach across different data availability scenarios, i.e., various subsample sizes of the training data.

![Refer to caption](extracted/5490966/results_finetune.png) Figure 5: Evaluation accuracy of finetuned student models on varying training set sizes

Fig. [5](https://arxiv.org/html/2403.15886v1#S5.F5 "Figure 5 ‣ 5.2 Finetuning and Distillation ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation") illustrates that our zero-shot methodology, marked in green, not only aligns with but also occasionally surpasses the performance of the few-shot approach by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)] in a finetuning scenario. Confidence bars depict the variation in performance across multiple runs with different random weight initializations. The baseline indicated as a dotted line in the plots is the 540B PaLM model finetuned on the entire dataset using only the ground truth labels.

Notably, with less than 25 % of training data, our method achieves higher accuracy than standard finetuning with the full ANLI1 dataset, indicating significant efficiency in training data utilization. Similarly, for the CQA dataset, our approach demonstrates an advantage over the standard baseline with approximately 75 % of training data.

An important observation to highlight is that not all generated rationales line up with the correct labeling—only about 71.0 % for ANLI1 and 72.4 % for CQA of the explanations are accurate. The remaining rationales, are explanations that lead to a wrong label, since the \acLLM will always produce a rationale that justifies its prediction, even if it is a wrong prediction. In addition, our optimal prompt has an explanation rate of around 87 %, meaning that 13 % of the rationales are mere empty strings.

To investigate if enhancing the explanation rate and accuracy could elevate the efficacy of step-by-step finetuning even further, we devised teacher prompts that incorporate the correct label directly, nudging the model to only generate rationales justifying why the given label is accurate. The outcomes of employing this revised prompting strategy on the ANLI1 dataset are depicted in Fig. [6](https://arxiv.org/html/2403.15886v1#S5.F6 "Figure 6 ‣ 5.2 Finetuning and Distillation ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation").

![Refer to caption](extracted/5490966/results_xr.png) Figure 6: Evaluation accuracy of finetuning with 100 % correct explanations on ANLI1

Surprisingly, increasing the explanation rate to 100 % with entirely accurate explanations does not enhance student model performance. Instead, performance slightly declines compared to rationales generated via few-shot prompting, particularly when the student model has access to only a limited portion of the data. It might be that the additional correct explanations display some detrimental intrinsic properties that result from the fact that the teacher model does not understand the reason for the ground truth label on its own.

![Refer to caption](extracted/5490966/results_distil.png) Figure 7: Evaluation accuracy of distilled student models on varying training set sizes

The distillation results, depicted in Fig. [7](https://arxiv.org/html/2403.15886v1#S5.F7 "Figure 7 ‣ 5.2 Finetuning and Distillation ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation"), align with the finetuning findings. Step-by-step distillation utilizing zero-shot prompts performs on par with few-shot prompting, affirming the robustness of our approach. Additionally, we observe that step-by-step distillation outperforms the baseline even more than under the assumption of available ground truth labels. Remarkably, with just 12.5 % of the ANLI1 training data, our approach surpasses the performance of conventional distillation techniques that use the full dataset. This highlights the efficiency of step-by-step learning, especially in contexts where no ground truth labels are available.

![Refer to caption](extracted/5490966/results_models.png) Figure 8: Evaluation accuracy for varying student model sizes

Lastly, Fig. [8](https://arxiv.org/html/2403.15886v1#S5.F8 "Figure 8 ‣ 5.2 Finetuning and Distillation ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation") explores the relationship between student model size and performance. We utilize 100 % of the available training data and evaluate four T5 model sizes, with 77M, 250M, 800M and 3B parameters. We observe that both few-shot and zero-shot step-by-step approaches improve upon the baseline across all model sizes. The red dotted line showcases the 540B PaLM Teacher \acLLM accuracy. In the case of finetuning, step-by-step learning allows much smaller models, such as the 800M T5-Large, to exceed the teacher \acLLM’s performance, showcasing significant efficiency gains. Notably, the 3B parameter student models sees their performance enhanced by over 9 %.

These results collectively underscore the effectiveness of zero-shot step-by-step distillation in not only matching but in some instances exceeding the benchmarks set by few-shot methods, while also highlighting the potential for substantial reductions in training data and computational costs.

###  5.3 Cost Efficiency

The results of Section [5.2](https://arxiv.org/html/2403.15886v1#S5.SS2 "5.2 Finetuning and Distillation ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation") further confirm the main findings of [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)]. Incorporating rationales and labels in step-by-step distillation and finetuning raises effectiveness and efficiency. Student models perform as good or better than the teacher while access to rationales reduces requirements for training data. Furthermore, the results show that our proposition of transitioning from few-shot prompts to more efficient zero-shot prompts does not hurt performance. Specifically, we do not observe a decrease in the quality of relevant properties of the generated explanations or labels.

The economic advantages of zero-shot prompting are however substantial as showcased in Fig. [9](https://arxiv.org/html/2403.15886v1#S5.F9 "Figure 9 ‣ 5.3 Cost Efficiency ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation"), which compares the annotation costs for the ANLI1 and CQA datasets when using our methodology against the few-shot method employed by [[4](https://arxiv.org/html/2403.15886v1#bib.bib4)], assuming they were both queried against the same pay-per-token API.

![Refer to caption](extracted/5490966/cost_to_data.png) Figure 9: Total costs to annotate the ANLI1 and CQA datasets by prompting approach

The cost reduction achieved through our zero-shot methodology represents the primary finding of our research and underscores the principal advantage of this approach over conventional few-shot step-by-step distillation. By achieving a tenfold decrease in annotation expenses, our method not only proves its financial efficiency but also its potential to facilitate large-scale \acLLM distillation in a more economically feasible manner.

The costs of the zero-shot approach include the expenditures associated with the \acOPRO prompt optimization process, which also necessitates interactions with the teacher \acLLM. It is important to note that the costs associated with \acOPRO are static, remaining constant regardless of the data volume. This aspect of our approach, especially in the context of growing datasets, positions it as a highly advantageous solution for deploying language models across a wide range of applications where cost and scalability are critical considerations.

###  5.4 Effect of Explanation Rate on Student Accuracy

This section examines how varying explanation rates influence the finetuning accuracy of a 250M T5-Base student model. Explanation rate, defined as the proportion of dataset instances accompanied by a rationale, can vary from 0 % (standard finetuning without explanations) to 100 % (each instance includes an explanation). Such analysis helps us understand the balance between rationale inclusion and student model performance. The results are shown in Fig. [10](https://arxiv.org/html/2403.15886v1#S5.F10 "Figure 10 ‣ 5.4 Effect of Explanation Rate on Student Accuracy ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation"), with confidence bars depicting the variation in performance across multiple runs with different random weight initializations.

![Refer to caption](extracted/5490966/results_xr2.png) Figure 10: Effect of explanation rate on student model finetuning accuracy

Our findings reveal a non-linear relationship between explanation rate and student accuracy. Interestingly, a rate of 85 % equals or surpasses the performance seen at 100 %, suggesting that beyond a certain threshold, additional rationales do not translate to increased accuracy. This observation underscores the potential for further cost savings without performance loss. Variations across datasets further suggest that optimal explanation rates might depend on specific task characteristics, emphasizing the importance of task-specific optimization in distillation processes.

###  5.5 Effect of Explanation Length on Student Accuracy

Following the analysis of the impact of the explanation rate on the accuracy of student models, we delve into the impact of the length of explanations. This part of our study is designed to identify the length of rationales that most effectively enhances student learning outcomes. To achieve variations in the length of explanations provided by the teacher \acLLM, we strategically modify the teacher prompt. Fig. [11](https://arxiv.org/html/2403.15886v1#S5.F11 "Figure 11 ‣ 5.5 Effect of Explanation Length on Student Accuracy ‣ 5 Results ‣ Leveraging Zero-Shot Prompting for Efficient Language Model Distillation") visualizes the accuracy of Small, Base and Large T5 models on the ANLI1 dataset across varying average explanation lengths.

![Refer to caption](extracted/5490966/results_length.png) Figure 11: Effect of explanation length and model size on student model accuracy

We observe that rationale length, quantified in words, is correlated with the performance of student models. Consistently, across all tested model sizes, we observe a decline in performance with increasing explanation length. The optimal length for the teacher rationale ranges from 20 to 40 words.

The smallest model shows peak accuracy with just 23 words per explanation, whereas the 250M Base model performs best with explanations around 33 words. Interestingly, even the largest model tested does not benefit from longer rationales, echoing the trend observed in smaller models. This pattern underscores a crucial aspect of effective distillation: succinct rationales tend to facilitate more efficient learning than their lengthier counterparts, likely due to the focused and concise transfer of knowledge they enable.

##  6 Conclusion

Our study introduces a novel approach to distilling \acpLLM, demonstrating the practicality and efficiency of zero-shot step-by-step distillation over traditional few-shot methods. By sidestepping the need for handcrafted few-shot examples, we cut down annotation costs by approximately 85 %. This cost reduction, achieved without sacrifices in performance, underscores the viability of zero-shot distillation for industrial applications, offering a scalable, cost-effective solution for deploying powerful, task-specific models with minimal human intervention.

Key findings reveal that annotating a dataset entirely with explanations is unnecessary for achieving near-optimal performance gains. Specifically, providing explanations for about a third of the dataset can secure over 90 % of the potential performance improvement, suggesting a cost-effective task-dependent optimization strategy. The negligible impact of incorrect explanations on model performance underlines the robustness of the zero-shot distillation process, attributed to the training’s design, which separates the predictions of labels and rationales. Emphasis on concise explanations can further enhance model performance and reduce costs.

This research confirms the potential for significant cost savings and operational efficiencies in the training of LLMs, thereby encouraging the adoption of zero-shot step-by-step distillation as a standard practice in the development of customized artificial intelligence models. By highlighting the effectiveness of selective rationale annotation and the benefits of concise explanations, it also sets the stage for further explorations into the optimization of distillation processes.

{credits}

####  6.0.1 \discintname

The authors have no competing interests to declare that are relevant to the content of this article.

## References

  * [1] Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., …: Training verifiers to solve math word problems (2021), <https://arxiv.org/abs/2110.14168>
  * [2] Fu, Y., Peng, H., Ou, L., Sabharwal, A., Khot, T.: Specializing smaller language models towards multi-step reasoning (2023), <https://arxiv.org/abs/2301.12726>
  * [3] Ho, N., Schmid, L., Yun, S.Y.: Large language models are reasoning teachers (2022), <https://arxiv.org/abs/2212.10071>
  * [4] Hsieh, C.Y., Li, C.L., Yeh, C.K., Nakhost, H., …: Distilling step-by-step! outperforming larger language models with less training data and smaller model sizes (2023), <https://arxiv.org/abs/2305.02301>
  * [5] Kojima, T., Gu, S.S., Reid, M., Matsuo, Y., Iwasawa, Y.: Large language models are zero-shot reasoners (2022), <https://arxiv.org/abs/2205.11916>
  * [6] Laskar, M.T.R., Saiful, B.M., Rahman, M., Bhuiyan, H., …: A systematic study and comprehensive evaluation of chatgpt on benchmark datasets (2023). https://doi.org/10.18653/v1/2023.findings-acl.29 
  * [7] Li, L.H., Hessel, J., Yu, Y., Ren, X., Chang, K.W., Choi, Y.: Symbolic chain-of-thought distillation: Small models can also "think" step-by-step (2023), <https://arxiv.org/abs/2306.14050>
  * [8] Li, S., Chen, J., Shen, Y., Chen, Z., …: Explanations from large language models make small reasoners better (2022), <https://arxiv.org/abs/2210.06726>
  * [9] Li, Y.: A practical survey on zero-shot prompt design for in-context learning (2023), <https://arxiv.org/abs/2309.13205>
  * [10] Nie, Y., Williams, A., Dinan, E., Bansal, M., …: Adversarial nli: A new benchmark for natural language understanding (2019), <https://arxiv.org/abs/1910.14599>
  * [11] OpenAI: Text generation models, <https://platform.openai.com/docs/guides/text-generation>
  * [12] Prasad, A., Hase, P., Zhou, X., Bansal, M.: Grips: Gradient-free, edit-based instruction search for prompting large language models (2022), <https://arxiv.org/abs/2203.07281>
  * [13] Raffel, C., Shazeer, N., Roberts, A., Lee, K., …: Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research 21, 1–67 (2020), <https://jmlr.org/papers/volume21/20-074/20-074.pdf>
  * [14] Srivastava, A., Rastogi, A., Rao, A., Shoeb, A.A.M., …: Beyond the imitation game: Quantifying and extrapolating the capabilities of language models (2022), <https://arxiv.org/abs/2206.04615>
  * [15] Talmor, A., Herzig, J., Lourie, N., Berant, J.: Commonsenseqa: A question answering challenge targeting commonsense knowledge (2019), <https://aclanthology.org/N19-1421/>
  * [16] Wei, J., Wang, X., Schuurmans, D., Bosma, M., …: Chain of thought prompting elicits reasoning in large language models (2022), <https://arxiv.org/abs/2201.11903>
  * [17] Yang, C., Wang, X., Lu, Y., Liu, H., …: Large language models as optimizers (2023), <https://arxiv.org/abs/2309.03409>
  * [18] Zhou, Y., Muresanu, A.I., Han, Z., Paster, K., …: Large language models are human-level prompt engineers (2022), <https://arxiv.org/abs/2211.01910>





