Better ChatGPT Prompts

The Guiding Principles to Prompt Engineering

Mansoor Aldosari
3 min readMay 21


Photo by Jonathan Kemper on Unsplash

Prompting plays a crucial role in effectively utilizing language models like ChatGPT. By providing clear and specific instructions, we can guide the model toward generating desired outputs while reducing the chances of irrelevant or incorrect responses. Moreover, giving the model time to think and reason can help avoid rushed or erroneous conclusions. We will explore two guiding principles for effective prompting.

Principle 1:

Clear and Specific Instructions When crafting prompts, it is to express the desired task with clarity and specificity. Longer prompts often provide more context, enabling the model to generate more detailed and relevant outputs. Here are some tactics to achieve clear instructions:

  • Delimiters: Using delimiters like triple backticks, quotes, XML tags, or section titles can indicate distinct parts of the input. Delimiters help avoid prompt injections and allow the model to focus on the intended section.
# Don't
summarize this text ... don't summarize this text ...

# Do
summarize the text delimited in square brackets
[... don't summarize this text ...]
  • Structured Output: Requesting structured outputs (JSON) can facilitate parsing.
# Don't
top ai books

# Do
generate a json for the top ai books
  • Checking Conditions: If a task assumes certain conditions, instructing the model to check these assumptions first can prevent irrelevant or incorrect responses. Considering potential edge cases and guiding the model helps avoid unexpected errors.
# Don't
find x

# Do
find x, if x doesn't exist find y
  • Few-Shot Prompting: Providing examples of successful task executions before requesting the actual task can help the model generate responses in a consistent style. Few-shot guides the model’s tone and output based on the provided examples.
Pirate: Avast, matey! What be ye doin' on me ship?

Shakespeare: Good morrow, my friend! I have happened upon this vessel by chance. Pray tell, what brings you upon these treacherous waters?

Principle 2:

Giving the Model Time to Think Allowing the model sufficient time to think and reason is crucial, especially when dealing with complex tasks. Here are some tactics to ensure the model has ample time for reasoning:

  • Specify Steps: Specify the steps required to complete a task. It helps the model understand the sequence of actions and generate outputs accordingly.
Perform the following tasks:
- task 1
- task 2
- task 3
  • Instruct Reasoning: Let the model analyze the problem thoroughly. The explicit guidance allows the model to engage in logical thinking, which can yield accurate responses.
# Don't
is this text correct?

# Do
check part 1, then part 2, and finally part 3

Prompt Engineering is essential for obtaining desired outputs from language models. Clear and specific instructions can guide the models toward generating relevant and accurate responses. Additionally, giving the models sufficient time to think and reason ensures better results, especially for complex tasks. By applying the principles of clear instructions and time to think, we can enhance the performance and reliability of language models like ChatGPT, opening up possibilities for various applications in natural language processing.



Recommended from Medium


See more recommendations