List of instructions in a system prompt

When I include a list of instructions in the prompt, what is the difference between using a bulleted list or a numbered list?

In the case of a numbered list, will the instructions be executed in sequence?

Thanks

2 Likes

Hi @lopry81 :wave:

Sequential Execution: If your goal is to have the model follow the instructions in a specific order, a numbered list is generally more effective. The numbering acts as a cue that the instructions should be executed in the order given.

Priority or Importance: If you want the model to consider all instructions equally and do not necessarily require them to be followed in order, a bulleted list is appropriate.

Numbered List

1.	Generate a summary of the provided text.
2.	Translate the summary into Spanish.
3.	Format the translation as a formal letter.

Bulleted Lists with Different Styles

•	Solid Circle (●)

● Generate a summary of the provided text.
● Translate the summary into Spanish.
● Format the translation as a formal letter.

•	Hollow Circle (○)

○ Analyze the data for any significant trends.
○ Create visualizations to represent the findings.
○ Write a brief report summarizing the results.

•	Square (■)

■ Identify the main topics in the article.
■ Find relevant references to support the main points.
■ Compile a list of key takeaways for further discussion.

•	Arrow (→)

→ List all action items for the project.
→ Assign tasks to team members.
→ Set deadlines for each task.

•	Dash (–)

– Gather all the necessary documents.
– Review the materials for accuracy.
– Submit the documents for approval.

•	Checkmark (✓)

✓ Confirm attendance for the meeting.
✓ Prepare the agenda in advance.
✓ Send out meeting reminders to participants.

6 Likes

Hi @polepole thanks for your answer.

I also agree with what you say about numbered or bulleted lists. However, I haven’t found any articles on the subject or any references in the “official literature.” Can you point me to some sources?

In the world of AI, unfortunately, there aren’t written rules for everything or “official literature”; it’s a developing field, and everyone can have a different experience due to its ‘natural language’ aspect. Below, I’m providing a simple example.

In the first example, I used ‘numbered’ and ChatGPT provided answers correctly according to the numerical order. In the second example, I used ‘bulleted,’ and as you can see, it didn’t follow the order, but arranged it from the first to the seventh day according to logical sequence, which is actually more accurate.

Also, the results are not always the same and can vary depending on the model and tool used, meaning GPT-4, GPT-4o, and GPT-4o mini, ChatGPT UI, or API might produce different results.

Here are the examples:


2 Likes

The other thing to note is that newlines and whitespace also give context to the instructions, and the number one mistake most devs make when prompt engineering (in python) is the misuse of multiline strings. To overcome the ugliness of left margin justified mutil-line strings, a lot of devs have taken to using textwrap.dedent and follow Google’s style guide to indent strings to the level of code. It’s important to note that the Google python style guide came out well before LLMs and it is not appropriate for prompt engineering as it will add unintended whitespace to the prompt when escaping newlines.

Example: you are trying to fit a sentence into the PEP-8 line length limits so you escape (\) the line and continue on the next line down.

from textwrap import dedent

system_message = dedent(
    """\
    You are a \
    helpful bot.
    """
)

In this example, the dev has unintentionally introduced indentation level whitespace into the prompt.
image
image

To overcome this you can combine re with textwrap.dedent to remove the code level indentation as well as the unintentional whitespace while preserving the intentional indentation.

def normalize_prompt(prompt: str, max_spaces: int = 3) -> str:
    """Helper function to dedent a multi-line prompt string and remove extra spaces."""
    prompt = "\n".join(
        re.sub(rf"(?<=\S)\s{{{max_spaces},}}", " ", line)
        for line in textwrap.dedent(prompt).split("\n")
    )
    return prompt

system_message = normalize_prompt(
    """\
    You are a \
    helpful bot.
    Example:
    ```
    def func():
        return "Hello, World!"
    ```
    """
)

print(system_message)
# You are a helpful bot.
# Example:
# ```
# def func():
#     return "Hello, World!"
# ```
2 Likes