How to Format Prompts for OpenAI API - Best Practices
Style & Format
Section titled Style & FormatWhen creating prompts, adopting a specific style is essential for several reasons. A well-defined style helps in the following ways:
-
Consistency: A consistent style makes your prompts more predictable and easier to understand for the AI model. It ensures that the model receives clear instructions and produces the desired output across multiple prompts.
-
Clarity: A well-defined style ensures that your instructions are clear and unambiguous. This reduces the chances of the AI model misunderstanding your prompt or generating irrelevant or undesired responses.
-
Efficiency: A good style allows you to communicate your requirements effectively, reducing the need for multiple iterations or adjustments to the prompt. This saves time and resources.
-
Customization: By adopting a specific style, you can tailor the output to match your desired tone, format, and level of detail. This is particularly useful when trying to generate content that adheres to a particular brand voice, industry standard, or target audience.
When choosing a style for your prompts, consider the following factors:
-
Detail and specificity: Be as specific and detailed as possible about the desired context, outcome, length, format, and style.
-
Instruction placement: Put instructions at the beginning of the prompt, and use separators like ### or """ to separate the instruction and context.
-
Examples: Provide examples of the desired output format, which helps the model understand your expectations better.
-
Avoid fluff: Use concise and precise language to minimize ambiguity and confusion.
-
Positive instructions: Instead of just saying what not to do, say what to do instead.
By carefully considering the style and crafting your prompts accordingly, you can improve the quality and relevance of the AI model’s responses, ultimately making your interactions with the AI more efficient and effective. read more
Bad : Analyze the customer review.
Good:
Bad: Compare the two ideas presented in the following text
Good:
Bad: Extract the key information from the following paragraph
Good:
Bad: Extract the important entities mentioned in the article below.
Good:
Bad : Extract keywords from the text
Good: