Blog 28.11.2024

Subtle art of prompting

Competence

Data & AI

Prompting is a skill that everyone needs today. Prompt is an input given to a generative AI model to guide its output. Prompting is the act of feeding a prompt to generative AI, which then generates a response.

(Schulhoff et al., 2024).

Six key points to successful prompting

(Losey, 2024 & Prompt Engineering, 2024)

  1. Clear instructions 
  2. Time to think 
  3. Task breakdown 
  4. Reference text 
  5. Experiment with changes  
  6. Tools  
Graphic element that includes the six points to successful prompting mentioned in the text.,

1.    Clear instructions

Describe precisely what you want the model to produce. If a short response is desired, you should specify that. Conversely, requesting a professional and lengthy explanation will yield such a result. A language model cannot guess the type of response you want without context.

2.    Time to think

Ask the model first to generate a chain of thought before reaching a conclusion. This means not asking directly for the answer but prompting the model to form a reasoning path that leads to the answer, then requesting the answer itself. This approach causes the neural network to process the response multiple times, often resulting in a better outcome. For example if you want model to give tenth decimal of approximation of pi. You need to ask it first define what is a pi, approximation of pi and decimal and then give tenth decimal of pi.

3.    Task breakdown

Like in software development, when prompting, a complex task should be broken down into parts and then assembled. You can ask the model to split the task into smaller parts and then generate a solution from those parts. This guideline also works well when asking questions from an actual person.

4.    Reference text

Provide reliable information as a reference for the model to use. This often helps, as the model has a limited window of context, and the provided information assists in bringing related knowledge to the surface.

5.    Experiment with changes

Evaluate prompt modifications against real data in a systematic way. Some instructions given to the model might work in specific instances but may not be generally applicable. Try small changes on prompt and generate several outputs and keep track of their quality. This is valuable especially when prompt is used to generate several answers automatically.

6.    Tools

Generative models are not always the best tools for certain types of information retrieval. If another tool can reliably provide an answer, it is worth using. In example generative language models are not good doing arithmetics. They can form input for some tool to calculate results and interpret answer tool gives. 

References

Data and AI

Timo Pitkänen

Senior Software Developer

Timo is an experienced software developer with diverse expertise in mobile, desktop, IoT, cloud, and embedded development. He is particularly interested in projects utilizing machine learning and artificial intelligence, which he implements using Python, Kotlin, and Rust. He graduated from the University of Jyväskylä with a major in computer science. In his free time, he enjoys board games, beers, the demoscene, and programming.

Back to top