Prompt Architecture
Over the past year, discussions around prompting have revealed a common challenge: prompts are becoming excessively long, sometimes exceeding 1,000 words. This poses sustainability and manageability issues over time. This guide addresses these concerns by providing a structured approach to prompt creation and management.
You have learned to write prompts like “Acting as a [role], perform [task], in [format requirements], use [register/writing style] and use this context: [context].” This is great for writing quick prompts when you need fast results, but it becomes less effective when you want to share prompts within your organization. Why? The prompt is not structured, is crafted for a specific purpose, and is hard to extract.
In the Crafting AI Prompts Framework, "components" are mentioned. This involves using each letter of the framework as a component, which is more suitable for sharing and building a Prompt Library.
What is a Prompt library?
In short, it's a database of your prompts, presented in a user-friendly interface. This setup allows you to easily search through and select prompts, making it easy to copy, paste, and utilize the prompt you need.
Many organizations use this method to share prompts. This way, if you create a valuable prompt, others within the organization can use it, so they don’t have to write the complete prompt themselves. This is especially beneficial for large prompts.
There are quite a few tools on the market to help you with this, including version control, testing options, and user/cost management. Testing prompts can be costly, so gaining insights into where resources are spent is useful. These tools can help accelerate your prompting activities. However, most of them lack one important feature: components.
Learning from Software Engineering
These issues were tackled long ago in Software Engineering. In its early days, we encountered files bursting with lines of code. Nowadays, we embrace brevity, clarity, and sound architecture. Why not adopt these principles from the outset?
Consider this: when you craft a prompt, there's a high likelihood that components of that prompt can be repurposed. If we examine the Crafting AI Prompts Framework, nearly every building block can potentially be reused for other prompts, except perhaps the Context section (due to its specificity).
Now, imagine formatting the output as a table, equipped with unique IDs. This format could seamlessly align with numerous other prompts you draft in the future. As a result, you might find yourself repeatedly constructing the same frameworks for your prompts, which is not the ideal approach!
Or consider the register within your organization. If you clearly define it in one component and reuse it within other prompts, all outputs (e.g., for your social media content) will have the same writing style. This approach ensures consistency and coherence across various platforms, making your brand voice recognizable and reliable. By standardizing your format, you can save time and maintain quality, enhancing your overall communication strategy.
Additionally, reusing a defined format streamlines the creation process, allowing for easier collaboration among team members. This uniformity not only helps in brand recognition but also improves the efficiency of your content generation process.
Prompt component library
So, let’s move away from traditional “Prompt Libraries” and make them more maintainable by enhancing them to “Prompt Component Libraries.” Revisiting the Crafting AI Prompts Framework, the most efficient approach would be to treat the building blocks from the framework as "components." These can then be cataloged in a Prompt Component Library.
For instance, consider the "table format with unique IDs" scenario. This could be a prompt component housed in the "Format" section of the Prompt Component Library. Or the description of your register/writing style could be a prompt component housed in the “Register” section of the Prompt Component Library.
By adopting this method, you're cultivating a library of "components" that can be seamlessly integrated into subsequent Prompt Recipes.
If you also label each component with the model it was tested on and enhance it with other useful information, these components can be tested independently. This ensures that each component is up-to-date and ready to use. If new model updates break a component (e.g., the table format displays as plain text or in a code block instead of a real table), you can simply update the table component within your Format section. Consequently, all recipes that use this component will be updated with the latest version!
Prompt recipes
In Prompt Recipes, you combine the various parts from the Prompt Components to create the desired prompt. For instance, if you're crafting a LinkedIn post and want to incorporate specific hashtags, use emoticons instead of bullet points, and so on, you'd fetch those "Prompt Components" from the "Prompt Component Library" and incorporate them into your Prompt Recipe.
But that's just the beginning! As you construct a prompt, you'd likely want to append more details to it. This might include information like the model it was tested on (and its version), its creation date, the creator's name, and any recipe parameters that need to be inputted (more on this later). Additionally, a descriptive title and summary would be handy for easy retrieval later. You might also want to note requirements like the availability of specific plugins, especially if using platforms like ChatGPT or if any integration parameters were set to the API (for example, at OpenAI).
Additionally, you might want to incorporate "variables" or "parameters." In such cases, it's imperative to include these parameters in the Recipe. This ensures users are aware they must input these parameters before utilizing the prompt recipe.
For example, a variable could be the context of the prompt, such as specifying the topic of a LinkedIn post. This way, this part of the recipe is "variable," while all other components are sourced from the Component Library to maintain consistency in the output. This approach allows for flexibility in the prompt's application while ensuring uniformity in style and structure.
Lastly, if you're employing any API parameters (like adjusting the temperature, max_tokens, etc.), it's essential to include those details in the Prompt Recipe. This ensures that another user can replicate the exact output you achieved, maintaining the validity of your tests.
With the recipe and the component library established, how does the final product appear?
This illustrates how I've integrated various components into recipes. It would be even more advantageous if we had tools allowing for the simple drag-and-drop of these components into our recipes. In essence, crafting recipes would resemble a "no-code" or "no-prompt" platform for users, assisted by Prompt Engineers who add new components to the Component Library for users to use. Everything is readily available; the task is to assemble it cohesively within your Prompt Recipe.
This method truly adds value. The value isn't solely in the completed prompt but in its individual components. So, why not deconstruct them into reusable components, mirroring practices in Software Engineering?
Also, consider the numerous new opportunities that arise, such as labeling the components and identifying the strategies used, such as Chain-of-Thought Prompting, Set of Mark Prompting, and so on.
Components and recipes are not supported in my organisation
Actually you can even store components within files (like notepad files). Just simply create a file per component on a shared environment (like Onedrive so everyone can access them), and in for example Copilot you can then apply them using the "/" tag. For example you create a component called "LinkedInRegister.txt", add there the component in. And now in Copilot you just call it using:/LinkedInRegister.txt the rest of your prompt.
Workflow prompting
This introduces a fascinating perspective. In other blogs, I briefly discussed Zapier, a powerful automation tool that connects different applications and services to automate repetitive tasks. I believe its flow aligns perfectly with prompting! Essentially, you initiate a prompt, execute a specific action, and upon completion, potentially trigger subsequent prompts. This concept can be termed "workflow prompting." Instead of automating just one specific aspect of your workflow using prompts, you aim to automate the entire workflow!
To delve deeper into this concept: You initiate a task (a workflow task). Upon its completion, it instigates the succeeding task. Each task is aligned with a specific Prompt Recipe that it activates. Prompt Recipes, in turn, include various Prompt Components, making the process complete and cohesive.
For instance, a workflow task might be: "Create user stories and upload to Jira." Within the prompt Recipe, user stories are generated utilizing a tool like Microsoft Copilot (please keep the N-Non disclosure in mind!). It's essential to use tools that do not expose your company data and are GDPR compliant. Similarly, when leveraging tools like Zapier to automate the transfer to Jira, ensure these tools also adhere to non-disclosure and GDPR compliance. Once this is accomplished, the next workflow task is set in motion.
The beauty of it is that you can design a default workflow that's accessible to everyone in your organization. Additionally, users have the flexibility to customize and add their elements to the workflow, ensuring it aligns with their specific needs.
Skills
As mentioned in the workflow example above, multiple prompt recipes can be chained together to automate tasks, often using tools such as Zapier to trigger each step in sequence. While this approach already provides automation, skills take it a step further.
Skills can be seen as reusable prompt recipes that are built from the same individual components. This gives organizations greater control, consistency, and governance over how AI capabilities are created and used.
Instead of manually orchestrating a sequence of prompt recipes, you can package the functionality into a skill and make it available to an agent. The agent can then determine for itself when a particular skill is relevant and whether it should be used, enabling a more autonomous and intelligent workflow.
Crafting AI prompts framework integration
The entirety of this framework aligns seamlessly with the aforementioned strategy. Every component from the Crafting phase can be found in the Prompt Component Library. The Validation Phase components are vital and should be addressed individually:
- Workflows ought to be interactive (I), enabling them to consider input from preceding steps as they move forward.
- Prompt Recipes should be goal-driven (G) to ensure they maintain a singular focus and can be integrated effectively into the prompt workflow.
- Crucially, no component should contain any confidential or personal data (N). Thus, within the prompts component library, provisions for non-disclosure must be adhered to (N).
- Lastly, prompt recipes come with versions (history), model information, and all other needs to inform the user what has been used to achieve the desired goal (G) to facilitate the Adapt and Improve (AI) process.
The (G) and (AI) principles will also prove invaluable when using tools to test and manage your prompts. As LLMs (Large Language Models) evolve, it’s possible that outcomes may change. By having all the information available in the recipes, including the models they were tested on, it’s always clear which model gives the correct output. This transparency allows for easy updates to newer versions, ensuring consistent and reliable results.
By adopting a Prompt Component Library and integrating it with structured Prompt Recipes, organizations can create a sustainable and maintainable prompt architecture. This approach not only simplifies prompt management but also aligns with best practices from software engineering, enhancing overall efficiency and effectiveness.
Test it out!
On our website, we’ve built an example Prompt Library for you to explore. This library was created with all the above steps in mind. You can create components and drag and drop them into recipes. This way, if models are updated or you want to change a single component, the changes will automatically be reflected in all your recipes.
Recipes, in turn, can easily be copied and already include all the framework styles. The library even supports variables and templates, so you can predefine prompts and reuse them across different use cases. We’ve also added some example recipes, so you can see the library in action right away.
Read more
The three phases
CRAFT
Craft (write) the prompt with the following elements: Context, Register, Acting Role, Format, and Task.
ING
Validate the prompt and ensure it maintains an interactive approach. Keep in mind the importance of non-disclosure and staying goal-driven throughout the process.
AI
Continuously assess and refine the output based on the prompts output to improve the overall quality.