Prompt Engineering Guide

Basic Principles

  • Write clear and specific instructions (AS CLEAR AS POSSIBLE)
    • Use delimiters to clearly indicate different parts of input (quotations, tags, etc) - this also helps with prompt injection
    • Ask For a structured Output (like HTML/JSON possibly)
    • Check whether conditions are satisfied
    • Few Shot Prompting
  • Give model time to think
    • Make the model work out the answer first, specify the steps required to complete the tasks
    • Instruct the model to work out on its own solution before rushing to conclusion

Iterative Prompt Development

  • Idea
  • Implementation
  • Experimental result -> Idea again

Dealing with Hallucinations

  • First find relevant information then answe the question based on relevant information using tools like langchain / crewAI

Settings

  • Temparature - (0 - 2) - determines confidence of the model in it’s top prediction. 0 means full confidence, ensuring predictability of the model.
  • Top P
  • Stop Sequence
  • Frequency Penalty
  • Presence Penalty

Resources