Principles of Prompting

Principle 1: Write clear and specific instructions

Tactic 1: Use delimiters:

Untitled

Tactic 2: Ask for structured output (HTML/JSON)

prompt = f"""
Generate a list of three made-up book titles along \\ 
with their authors and genres. 
Provide them in JSON format with the following keys: 
book_id, title, author, genre.
"""

Tactic 3: Check whether conditions are satisfied / Check assumptions required to do the task

prompt = f"""
You will be provided with text delimited by triple quotes. 
If it contains a sequence of instructions, \\ 
re-write those instructions in the following format:

Step 1 - ...
Step 2 - …
…
Step N - …

If the text does not contain a sequence of instructions, \\ 
then simply write \\"No steps provided.\\"

\\"\\"\\"{text_1}\\"\\"\\"
"""

Tactic 4: Few-shot Prompting

Give successful examples of completing tasks, then ask the model to perform the task

prompt = f"""
Your task is to answer in a consistent style.

<child>: Teach me about patience.

<grandparent>: The river that carves the deepest \\ 
valley flows from a modest spring; the \\ 
grandest symphony originates from a single note; \\ 
the most intricate tapestry begins with a solitary thread.

<child>: Teach me about resilience.
"""

Principle 2: Give the model time to think

Tactic 1: Specify the steps required to complete the task