Prompt engineering
Prompt engineering is the art of crafting effective instructions for AI models. Lleverage's prompt engineering interface helps you write, test, and refine your prompts to get the best possible results. To support you in engineering the perfect prompt, you can access the Prompt Engineering screen for your Prompt action by clicking the "Engineer Prompt" button.
Structure of a prompt
Every prompt starts with a System message that sets the context for the AI. This message defines the AI's role and any high-level rules or constraints it should follow. Think of it as setting up the AI's mindset - whether it should act as a content writer, data analyzer, or any other specific role.
After the System message, you can build your conversation with User and Assistant messages. User messages contain your specific instructions or questions, along with any data you want the AI to process. This is also where you can include images for the AI to analyze. Assistant messages show example responses you want the AI to emulate, helping guide its output style and format.
Generating prompts
Writing effective prompts from scratch can be challenging. The "Generate" button helps you create prompts based on your description of what you need. Simply describe your use case, and Lleverage will suggest a prompt structure. You can then refine this generated prompt to better match your specific needs.
Testing with data
To ensure your prompt works well with different inputs, you can test it with sample data. Toggle "Test with mock data" to try your prompt with generated examples, or use your own test data to verify behavior. This is particularly useful when your prompt includes variables - you can see exactly how different inputs affect the output.
Comparing variants
The Compare view lets you test different versions of your prompt side by side. You can create multiple variants with different:
System and User messages
Model settings like temperature
Output formats
Model selections
Each variant runs with the same input, letting you easily compare results, performance, and costs to find the best approach for your needs.
Structured output
While prompts can generate plain text responses, you often need structured data that can be processed by other actions. You can guide the AI to produce specific formats by:
Setting the output format to JSON and describing the structure you need in your prompt. The AI will then format its response accordingly, making it easy to process the data in subsequent actions.
For example, when analyzing a document, you might want the AI to return a structured analysis with specific fields for title, summary, and key points. The JSON output format ensures this data comes back in a consistent, usable structure.
Best practices
When engineering your prompts, consider:
The System message should be clear about the AI's role and any absolute constraints it needs to follow.
User messages should provide specific instructions and any relevant data. When including images, add them here rather than in the System message.
Test your prompt with various inputs to ensure it handles edge cases appropriately.
Use structured output when you need to process the results programmatically.
Keep your prompts focused on a single task for better results.
Last updated