Principles of Prompt Engineering – Specify Format

Continuing from the last post, the next principle is “specify format” to get a reliable result. Specifying format is really defining what rules to follow, and what response structure is required

Again, using the same simple prompt to generate 10 product names for a backpack for men

Instead, you can specify which format the GPT should follow for the response

I want to brainstorm a list of product names for a backpack for men, in the style of Steve Jobs

// this specifies format of the response
Return the top 3 results as a table (or comma separated list, JSON, YAML), in this format: 
product name, product description, rating 

ratings should be based on the coolness, catchiness, and uniqueness, scaling from 1 to 5
// retunred as JSON
[
  {
    "product_name": "AirPack",
    "product_description": "Ultra-lightweight, minimalist backpack that feels like carrying nothing at all.",
    "rating": 5
  },
  {
    "product_name": "VisionPack",
    "product_description": "A sleek, future-forward pack designed for thinkers, creators, and innovators.",
    "rating": 5
  },
  {
    "product_name": "Element",
    "product_description": "Pure, essential design — a backpack reduced to its most timeless form.",
    "rating": 5
  }
]

The result from the prompt should be consistent because it could be used as the input to another task. A consistent result is key.

Leave a Reply

Your email address will not be published. Required fields are marked *