System prompt best practices for consistent output formatting

Emma Rodriguez
Emma RodriguezFeb 10, 2025

I've spent months refining system prompts for consistent outputs across GPT-4o. Here's what I've learned:

Do's

  • Put format instructions at the END of the system prompt
  • Use XML tags to delineate sections: ...
  • Provide 2-3 examples of desired output
  • Be explicit about what NOT to include
  • Don'ts

  • Don't rely on "be concise" — specify exact word/sentence counts
  • Don't mix formatting instructions with behavioral instructions
  • Don't assume the model remembers formatting from previous turns
  • Template I use

    You are a [role]. Your task is [task].

  • Rule 1
  • Rule 2
  • Always respond in this exact format: [example]

    What patterns have worked well for you?

    4.1k views24 replies56 likes
    3 Replies
    Ryan Mitchell

    This is incredibly helpful. How did you handle failures? Did you re-batch just the failed requests?

    Lucia Fernandez

    Yes, exactly. After each batch completes, I parse the output file and collect any failed request IDs, then create a new batch with just those. Usually only 1-2% fail so the retry batch is small.

    failed_ids = [r['custom_id'] for r in results if r['response']['status_code'] != 200]
    
    Robert Chang

    At our scale (500K+ docs/day), we've also found that splitting by document type gives better results since you can optimize the prompt per type.

    Log in to reply to this topic.