In this lesson, we are going to explore the importance of consistent formatting and organization when crafting prompts for Large Language Models (LLMs). You might wonder how something as seemingly simple as prompt formatting can significantly impact the responses you receive from an AI. Just as in human communication, clarity and structure play crucial roles in ensuring that your requests are understood and accurately fulfilled. Let's dive into how you can apply these principles to make your interactions with LLMs more effective and predictable.
Formatting your prompts consistently is not just about making them look neat; it means making your intentions clear to the AI. Imagine you are giving someone instructions for baking a cake, but instead of listing the steps in order, you jumble them all up. The result? Confusion and, likely, a not very tasty cake. The same principle applies to LLMs. By presenting your prompts in a clear, structured manner, you greatly increase the chances of receiving the desired output.
While there are many approaches to structuring your prompts, in this course, we'll teach you the Markdown Prompts Framework (MPF) developed by Prompt Engineers and AI experts at CodeSignal.
MPF is a very effective approach to creating highly readable, maintainable, and effective prompts and is at the core of many aspects of Cosmo.
Before we delve into the Markdown Prompts Framework, it's essential to understand the basics of Markdown itself. Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Here are some basic elements:
- Headings: Use
#for headings. More#symbols indicate smaller headings. - Bold Text: Use
**or__to make text bold. - Italic Text: Use
*or_to italicize text. - Lists: Use
-for bullet points or numbers for ordered lists. - Code Blocks: Use triple backticks (```) to create code blocks.
Understanding these basics will help you effectively use the Markdown Prompts Framework.
Throughout this course, we'll see many examples of the application of MPF, but for now, here is a high-level summary:
- Split your prompts into Markdown sections like this:
__SECTION__- This not only helps LLMs better understand your prompts but makes your prompts very easily skimmable (especially when rendered in Markdown since these show up in bold) allowing your fellow AI engineers to easily find and read relevant sections when your prompts get large.
- Begin with your
__ASK__section at the top of your prompt- This allows you and your collaborators to quickly understand the goal of the prompt from the very onset.
- Format each section as a list of Markdown bullet points to make them easier to read and understand.
- Bulleted lists are much easier to skim, and they tend to lead to better instruction following by LLMs.
- While trying to minimize the number of sections, for complex prompts, include the following key sections:
__ASK__- what are we asking the LLM to do?__CONTEXT__- what does the LLM need to know to be able to respond accurately?__CONSTRAINTS__- what constraints need to be followed when responding?__EXAMPLE__- what's a good example of an output that you'd be happy with?
