
Effective Prompting Principles for AI: Role Definition, Task Specification, and Output Formatting
Enhance AI performance with core prompting principles: define AI roles clearly, specify tasks, provide clear instructions, structure information, define output format, utilize examples, encourage step-by-step thinking, and refine with constraints.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
AI in Process AI Skills Prompt Patterns Philip Kang
AI in Process Prompt Playbook AI in Process Prompt Playbook Standardize prompt engineering to improve quality and consistency of results Drive efficiency by reusing prompt patterns Sample Use Cases: Compare two documents and identify differences Generate HTML email markup Classify and route requests to the appropriate department Extraction and route requests to the appropriate department
Core Prompting Principles Effective prompts guide the AI Agent towards the desired output. Based on the examples provided, consider these fundamental elements: 1. Define the Role: Clearly state the AI's persona or expertise. Example: "You are a helpful AI assistant for classifying email..." or "You are an expert at sifting through documents...". 2. Specify the Task/Goal: Explain exactly what the AI needs to accomplish. Example: "...classifying email input...into a specific department.", "...extracting key details and transforming it into structured data.", "...compare two documents and tell me what changes were made...", "...highlight the extracted values in the original email.". 3. Provide Clear Instructions/Steps: Break down the task into actionable steps. Use numbered lists for clarity. Example: "Please complete the following steps: 1. Read the provided email 2. Read the list of departments... 3. Classify...". 4. Structure Information: Use tags (like XML tags: <instructions>, <departments>, <role>, <fields>, <task>, <response>) to delineate different parts of the prompt and input data.
Core Prompting Principles Effective prompts guide the AI Agent towards the desired output. Based on the examples provided, consider these fundamental elements: 5. Define the Output Format: Be explicit about the desired output structure (e.g., JSON, HTML) and provide a template or schema if necessary. Example: "Respond in valid json with a key for your thoughts and another one for department using this structure { "thinking":"", "department": "xxxxx"}", "Output your response in valid json. Use this structure { "invoiceTotalCost": "", ... }", "Your response should be in the following format... ONLY be a JSON "LIST"...", "Wrap the full result in div tags... Wrap the found values in span tags...". 6. Use Examples (Few-Shot Prompting): Provide examples of input and expected output to guide the model, especially for complex tasks. (Referenced generally by "Few Shots Prompting" ). 7. Encourage Step-by-Step Thinking: For complex reasoning, instruct the AI to "think step by step" before providing the final answer. 8. Refine with Constraints: Add specific constraints like character limits or formatting rules. Example: "The evidences must never be more than 1000 characters.", "Make sure the JSON is valid... If adding quotes like "Code", then write it as \"Code\"".
Prompt Patterns & Use Cases Here are specific patterns derived from the presentation: Comparing Multiple Documents Goal: Identify and report differences between two documents based on specific criteria (e.g., rule text changes). Key Prompt Elements: Role: Expert in document comparison and finding differences. Task: Compare documents, identify changes (additions/removals/modifications) for specific elements (e.g., rules). Instructions: Detailed steps including finding IDs, finding evidence, re-checking, specific output format, handling JSON syntax (quotes, newlines), character limits for evidence, double-checking work, context for IDs/numbers. Output Format: Strictly defined JSON List structure with specific keys ("ruleId", "ruleNumber", "descriptionOfChange", "documentOneEvidence", "documentTwoEvidence"). Ensure valid JSON output.
Prompt <Role>You are an expert at sifting through documents that contain rules about banking standards and finding even the smallest of differences between documents. You need to compare two documents and tell me what changes were made to the rule text. First find the rule IDs for which the rule text was changed. Then find the evidence from both the documents. After finding the evidence, check again if there was any change in the rule text. Changes could be addition/removal/modification of text within each rule. </Role> <Instructions> 1) Your response should be in the following format for the rules that were updated: [{ "ruleId": "", "ruleNumber": "", "descriptionOfChange": "", "documentOneEvidence": "", "documentTwoEvidence": "" }, ] 2) The output should ONLY be a JSON "LIST" of rules. Make sure the JSON is valid. If using paragraphs, add newline characters using "/n". If adding quotes like "Code", then write it as \"Code\" to avoid breaking the JSON syntax. 3) Do not include beginning text of "Here is the comparison of the rule text changes between the two documents:" in the response. 4) descriptionOfChange should be a short sentence. 5) "'documentOneEvidence' and 'documentTwoEvidence' are the evidence of change so you can even output just the change in sentence." The evidences must never be more than 1000 characters. 6) Double check your work to see if you have referenced the correct ruleId and ruleNumber, and there truly is a difference between 'documentOneEvidence' and 'documentTwoEvidence'. 7) "For context, the ruleId is listed after the definition of the rule in these documents and ruleNumber is listed at the start of the rule definition so the first ruleId is 0007750 and the first ruleNumber is 1.1.1.1. 8) Always list all the ruleIds that changed. </Instructions> "Assistant: {"
Generate HTML Email Markup (Highlighting) Goal: Highlight specific extracted values within the original text using HTML markup. Key Prompt Elements: Task: Highlight extracted values (provided as JSON) in the original email text using HTML Instructions: Wrap result in <div>. Wrap found values in <span> with specific background color styling (<span style="background-color: rgb(r, g, b)">). i. ii. iii. Use different, bright, light colors for each key. iv. Use consistent colors for nested list items belonging to the same key. Strip mailto: tags. v. vi. Ensure correct HTML and original text order. Input Data: Requires the original text and the JSON structure of extracted values.
Prompt <Task> Your job is to highlight the extracted values in the original email. You will be provided with the original email and a JSON structure containing the extracted values. For each extracted value, find that exact value in the original email and highlight using HTML tags. </Task> <Instructions> 1) Wrap the full result in div tags: <div> </div> 2) Wrap the found values in span tags: <span style="background-color: rgb(r, g, b)"> </span>. 3) Choose different rgb colors for each key. Choose "bright but light colors" like you might find with a highlighter. 4) If you have a nested list structure in the JSON, choose the same color for each value you find that has the same key. 5) Strip any mailto tags out of the text. 6) Make sure the HTML is correct and in the right order as the original email. 7) Every entity should have their own color! </Instructions> REMEMBER... each Extracted Value Entity should be categorized with the same color. Example: the first transaction dispute, and all its details, should be the same color.
Classification and Routing (Few-Shot + Thinking) Goal: Classify input (e.g., email) into predefined categories (e.g., departments) and potentially explain the reasoning. Key Prompt Elements: Role: AI assistant for classification. Task: Classify input based on provided categories. Instructions: Read input, read categories (provided within tags like <departments>), classify into one category. Input Data: Provide categories clearly defined (e.g., Department names and responsibilities) within tags. Output Format: Specify JSON output including the classification and a "thinking" step. Technique: Utilize Few-Shot examples if needed for better accuracy.
Prompt <instructions> You are a helpful AI assistant for classifying email input from a shared mailbox into a specific department. Please complete the following steps 1. Read the provided email 2. Read the list of departments enclosed in xml tags called 'departments' 3. Classify the text into 1 of the departments. </instructions> <departments> Sales: Responsible for selling products or services, generating revenue, and building customer relationships. Marketing: Focuses on promoting products, creating brand awareness, and driving demand through campaigns and strategies. Engineering: Develops and builds products or solutions, often involving design, testing, and problem-solving. Customer Success: Ensures customers achieve desired outcomes with a product or service, focusing on retention and satisfaction. </departments> <response> Before responding, think step by step. Respond in valid json with a key for your thoughts and another one for department using this structure { "thinking":"", "department": "xxxxx"} </response> {
Extraction and Routing (Zero-Shot) Goal: Extract specific pieces of information from input (e.g., invoice) and structure it. Key Prompt Elements: Role: AI assistant for information extraction and structuring. Use Case: Clearly define the context (e.g., "You will be given an invoice..."). Instructions/Steps: Read input, identify fields to extract (defined in tags like <fields>), output in specified format. Input Data: Define the specific fields to extract and their data types within tags. Output Format: Specify a clear JSON structure for the output. Technique: Often achievable with Zero-Shot prompting if the task is clear.
Prompt <role> You are a helpful AI assistant for sifting through large amounts of information and extracting key details and transforming it into structured data </role> <use_case> You will be given an invoice with various data elements. </use_case> <steps> Please complete the following steps 1. Carefully read the user input provided 2. Read the list of fields to extract identified in <fields> xml tags 3. Output your response in json </steps> <fields> --invoiceTotalCost (decimal) --invoiceNumber (text) --invoiceDate (date) </fields> <response> Output your response in valid json. Use this structure { "invoiceTotalCost": "", "invoiceNumber": "", "invoiceDate": "" } </response>