🟢 Formalizing Prompts
- Understand the basic parts of a prompt
We have now covered multiple types of prompts, as well as ways to combine them. This lesson will provide you with terms to explain different types of prompts. Although there have been approaches to formalize discourse around prompt engineering1, the field is ever changing, so we will provide you with just enough information to get started.
Parts of a Prompt
There are a few different parts of a prompt that you will see over and over again. They are roughly:
- A role
- An instruction/task
- A question
- Examples (few-shot)
We have covered roles, instructions, and examples in previous lessons. A question is simply a question (E.g.
what is the capital of France?). Context is any relevant information that you want the model to use when answering the question/performing the instruction.
Not all of these occur in every prompt, and when some do occur, there is no standard order for them. For example, the following two prompts, which each contain a role, an instruction, and context, will do roughly the same thing:
However, we prefer the second prompt, since the instruction is the last part of the prompt. This is preferable, since with the first prompt, the LLM might just start writing more context instead of following the instruction; if given the first prompt, the LLM might add a new line:
March 15, 2022: Follow-up appointment scheduled with neurologist to assess concussion recovery progress.
Understanding the structure and components of a prompt is crucial in effectively utilizing language models. The key parts of a prompt include a role, an instruction or task, a question, context, and examples. Not all prompts will contain all these elements, and their order can vary. However, it's generally preferable to place the instruction last to ensure the model focuses on executing the task rather than extending the context. As the field of prompt engineering continues to evolve, these principles provide a solid foundation for crafting effective prompts.
- White, J., Fu, Q., Hays, S., Sandborn, M., Olea, C., Gilbert, H., Elnashar, A., Spencer-Smith, J., & Schmidt, D. C. (2023). A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT. ↩