4. Prompting

Prompt Engineering and Prompting Strategies 

 

With the increasing availability of generative AI applications, their effective use is becoming increasingly important. You have already learned how chatbots generate responses in the previous sections, so now the question arises: Which input produces the desired output?


 Prompt-Engineering is the art and science of designing effective prompts to interact with large language models (LLMs).
 

 

Why is prompt engineering important?

The quality of LLM responses depends directly on the quality of the prompts given. A well-formulated prompt can lead to a precise, accurate, and relevant response. Conversely, a poorly structured prompt can lead to a vague, incorrect, or irrelevant response.

Currently, the literature presents various strategies to support users of large language models (LLMs) in developing well-formulated prompts. In this chapter, we will get to know eight prompting strategies:

  1. Assign a role
  2. Provide relevant context
  3. Give detailed instructions
  4. Guide the model toward a solution
  5. Request multiple versions
  6. Do not just describe—provide examples
  7. Specify the format of the response
  8. Build chains of argumentation
!    Interact with the following story to see how the journalist Lucy uses these different prompting strategies to formulate questions for an interview.
 

These prompting strategies can help you create detailed and structured prompts that make it particularly effective to tackle specific tasks. However, it is not necessary to use all strategies at once in a single prompt—you can selectively choose some of them depending on the task. Therefore: Experiment, experiment, experiment!
Productive use of large language models (LLMs) requires continuous and creative experimentation. Among other things, you may consider the following:

• Vary wording, length, degree of specificity, and any constraints.

• Switch back and forth between different examples, contexts, and instructions.

• Test both dialogue-oriented and concise declarative prompts.

• Try the same prompts with different LLMs.

Use AI systems to create prompts for you.
Alternatively, you can ask the AI system to create a prompt that follows proven prompting strategies. You can do this in various ways. For example, for the scenario mentioned above, you could use the following prompt so that the AI system generates an appropriate prompt: “I need to prepare for an interview with Geoffrey Hinton about the risks of AI from his perspective. Formulate a prompt that enables the language model to support me in brainstorming thought-provoking, respectful, and well-researched potential interview questions. Follow established prompting strategies.”