Proper formatting of prompts is crucial for effective communication with AI models. Here are some tips and tricks on using the formatting languages of the GPT models in markdown and the anthropic models in xml.
Here is everything you need to craft effective prompts in markdown and xml formatting:
Markdown
XML
Basic Formatting
Copy
*Italic text* for mild emphasis**Bold text** for strong emphasis***Bold and italic*** for extra strong emphasis`Code-style text` for technical terms or commands
Headings and Structure
Copy
# Main Prompt Title## Section 1: Context### Background Information### Current Situation## Section 2: Task Description
Lists and Steps
Copy
1. First step2. Second step3. Third step- Bullet point 1- Bullet point 2- Sub-point A- Sub-point B
Code Blocks
Copy
```pythondef example_function(): return "This is an example"
Copy
```json{ "key": "value", "array": [1, 2, 3]}
Basic Structure
Copy
<prompt> <context>This is the context</context> <instruction>This is the main instruction</instruction> <important>This is crucial information</important> <example>This is an example</example> </prompt>
Roles and Dialogue
Copy
<conversation> <human>What's the weather like today?</human> <assistant>I don't have real-time weather data. Please check a reliable weather website or app for your location.</assistant></conversation>
Nested Structures
Copy
<prompt> <context> <background>Relevant background information goes here.</background> <current_situation>Description of the current scenario.</current_situation> </context> <task> <primary_objective>Main goal of the task</primary_objective> <secondary_objectives> <objective1>First secondary objective</objective1> <objective2>Second secondary objective</objective2> </secondary_objectives> </task></prompt>
Attributes and CDATA
Copy
<instruction type="main" priority="high" tone="professional"> Craft a response addressing the user's concern.</instruction><example_code><![CDATA[def complex_function(x, y): return x * y + (x / y) if y != 0 else "Error: Division by zero"]]></example_code>
By mastering these formatting techniques and utilizing appropriate structures, you can create highly effective prompts that clearly communicate your intentions to AI models, resulting in more accurate and useful responses.Now that you know the proper formatting, read our comprehensive guide on how to write your system prompt.