title={Connecting large language models with evolutionary algorithms yields powerful prompt optimizers},
author={Guo, Qingyan and Wang, Rui and Guo, Junliang and Li, Bei and Song, Kaitao and Tan, Xu and Liu, Guoqing and Bian, Jiang and Yang, Yujiu},
booktitle={International Conference on Learning Representations},
volume={2024},
pages={34133--34156},
year={2024}
}
@inproceedings{deng-etal:rlprompt,
title={Rlprompt: Optimizing discrete text prompts with reinforcement learning},
author={Deng, Mingkai and Wang, Jianyu and Hsieh, Cheng-Ping and Wang, Yihan and Guo, Han and Shu, Tianmin and Song, Meng and Xing, Eric and Hu, Zhiting},
booktitle={Proceedings of the 2022 conference on empirical methods in natural language processing},
pages={3369--3391},
year={2022}
}
@article{holtzman-etal:curious,
@article{holtzman-etal:curious,
title={The curious case of neural text degeneration},
title={The curious case of neural text degeneration},
@@ -50,7 +50,7 @@ However, pre-training primarily teaches the model to perform language modeling r
...
@@ -50,7 +50,7 @@ However, pre-training primarily teaches the model to perform language modeling r
\subsubsection{Prompting}
\subsubsection{Prompting}
Prompting is a simple and lightweight way to adapt an LLM to different tasks without updating its parameters. In the context of LLMs, a \textit{prompt} refers to the input text provided to guide the model toward a desired task or output. It may contain an instruction, user-provided content, output requirements, or demonstrations. For example, if we want an LLM to act as a homework assistant and answer a student's question, we can provide the following prompt:
Prompting is a simple and lightweight way to adapt an LLM to different tasks without updating its parameters. A \textit{prompt} is the input text used to guide the model toward a desired task or output. It may contain an instruction, user-provided content, output requirements, or demonstrations. For example, if we want an LLM to act as a homework assistant and answer a student's question, we can provide the following prompt:
\vspace{0.1cm}
\vspace{0.1cm}
...
@@ -76,7 +76,7 @@ Please make the response clear, practical, and easy to follow. \\[1mm]
...
@@ -76,7 +76,7 @@ Please make the response clear, practical, and easy to follow. \\[1mm]
\vspace{0.5em}
\vspace{0.5em}
In this example, the prompt itself specifies the task, and the LLM generates the answer by continuing the sequence. A prompt can also be obtained from a prompt template. A prompt template is a piece of text containing placeholders, where each placeholder is filled with concrete information before being sent to the LLM. For example, we can use the following template to construct prompts for a homework assistant:
In this example, the input itself specifies the task, and the LLM generates the answer by continuing the sequence. Prompts can also be constructed from templates. A prompt template is a piece of text containing placeholders, where each placeholder is filled with concrete information before being sent to the LLM. For example, we can use the following template to construct prompts for a homework assistant:
\vspace{0.1cm}
\vspace{0.1cm}
...
@@ -103,7 +103,7 @@ Please make the response clear, practical, and easy to follow. \\[1mm]
...
@@ -103,7 +103,7 @@ Please make the response clear, practical, and easy to follow. \\[1mm]
\vspace{0.5em}
\vspace{0.5em}
If we set \{*subject*\} to ``math'', the template becomes the prompt used above. In this way, users can easily construct different prompts by changing the placeholder while keeping the main task description unchanged.
If we set \{*subject*\} to ``math'', the template becomes the prompt used above. In this way, users can construct different prompts by changing the placeholder while keeping the main task description unchanged.
Another important concept related to prompting is in-context learning. When prompting an LLM, we can add demonstrations to the context and let the model infer the desired input-output pattern from these examples. For instance, we can show the model how to answer similar student questions before asking it to respond to a new one:
Another important concept related to prompting is in-context learning. When prompting an LLM, we can add demonstrations to the context and let the model infer the desired input-output pattern from these examples. For instance, we can show the model how to answer similar student questions before asking it to respond to a new one:
...
@@ -124,15 +124,8 @@ Another important concept related to prompting is in-context learning. When prom
...
@@ -124,15 +124,8 @@ Another important concept related to prompting is in-context learning. When prom
\end{tcolorbox}
\end{tcolorbox}
\vspace{0.5em}
\vspace{0.5em}
Prompting is crucial because it directly influences how the LLM understands the task and generates the output. A well-designed prompt can guide the model to produce more accurate, relevant, and appropriately formatted responses. However, since the model parameters are unchanged, the result can also be sensitive to the wording, structure, and demonstrations provided in the prompt.
Prompting adapts an LLM by changing the context used for generation. Therefore, prompt quality can strongly affect model performance. Even for the same task, we can write the prompt in many different ways. For example, ``Give me two tips to improve my English writing.'' can also be written as ``What are two simple ways to improve my English writing skills?''. The two prompts express nearly the same intent, but they may lead to noticeably different outputs. In practice, we often refine prompts through repeated trial and error for a given LLM. More advanced methods automate this process and search for better prompts using techniques such as RL \citep{deng-etal:rlprompt} or evolutionary algorithms \citep{guo-etal:connecting}.
Following the notation used above, we denote the entire prompt by $\mathbf{x}=x_1...x_m$. Prompting asks the LLM to generate an output $\mathbf{y}=y_1...y_T$ according to the conditional distribution $\mathrm{Pr}_{\theta}(\mathbf{y}|\mathbf{x})$. The probability of the output is factorized as
where $\mathbf{y}_{<t}=y_1...y_{t-1}$ denotes the tokens that have already been generated. This conditional generation formulation will be repeatedly used in the following sections. From this perspective, a prompt mainly changes the condition under which the same language model distribution is used.