What is Prompting?
Prompting means giving an AI clear instructions to achieve the desired result – much like guiding a helpful assistant. The more precise the instruction, the better the outcome. Prompt engineering involves crafting these instructions to maximize the quality, relevance, and usefulness of the AI’s responses.
Goal
Clearly state the specific information you need.
Context
Explain why you need the information or how you will use it.
Expectations
Specify the format, style, tone, and target audience of the output.
Source
Indicate any specific data sources or plugins the AI should use.
Tips and Tricks for Effective Prompting
1. Clarity and Specificity
-
Be intentional: Clearly understand your task and the desired outcome before writing the prompt.
-
Use clear language: Avoid jargon, complex sentences, and ambiguity.
-
Break down complex questions: Split them into simpler, individual prompts for focused interaction.
-
Specify constraints: State any limitations like word count or specific themes.
-
Avoid vagueness: Use precise language for higher-quality responses.
Examples:
-
Less Effective: Tell me about the solar system.
-
More Effective: Describe the order of the planets in the solar system from closest to farthest from the Sun.
-
Less Effective: Summarize incident 15134.
-
More Effective: Summarize incident 15134 in Microsoft Defender XDR into a paragraph that I can submit to my manager and create a list of entities involved.
2. Formatting and Structure
-
Instructions First: Place clear and detailed instructions at the beginning of the prompt.
-
Separate instructions and context: Place instructions at the beginning, using "###" or """"" as separators.
-
Define the desired output format: Clearly indicate if you need paragraphs, bullet points, lists, tables, or specific data formats like JSON or XML.
-
Provide examples: Show the AI the specific format and structure you want.
Examples:
-
Less Effective: Extract the entities mentioned in the text below. Extract the following 4 entity types: company names, people names, specific topics, and themes. Text: {text}
-
More Effective: Extract the important entities mentioned in the text below. First, extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes. Desired format: Company names: <comma_separated_list_of_company_names> People names: -||- Specific topics: -||- General themes: -||- Text: {text}
3. Context and Examples
-
Provide relevant context: Help the AI narrow down its search and understand the specific situation.
-
Use few-shot learning: Include examples in the prompt to guide the AI's approach, especially for creative or analytical tasks.
Examples:
-
Less Effective: Write a poem about OpenAI.
-
More Effective: Write a short inspiring poem about OpenAI, focusing on the recent DALL-E product launch (DALL-E is a text-to image ML model) in the style of [famous poet].
-
Example of few-shot learning: Provide a bullet point list of all authors and works cited in this paper, formatted as 'Author's Last Name (Year): Title of publication.' For instance, "Fitzgerald (1925): The Great Gatsby".
4. Iteration and Refinement
-
Iterate on prompts: Experiment with different versions and clarify as needed to get closer to the desired result.
-
Use previous responses: Build on them for further interactions and refine prompts based on the AI's output.
5. Positive Instructions
-
Focus on what to do: Instead of what not to do, provide positive instructions and specific exceptions.●
-
Address the AI directly as "You": Use phrases like "You should..." or "You must..." for more effective communication.
Examples:
-
Less Effective: DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT. Customer: I can't log in to my account. Agent:
-
More Effective: The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article www.panta-rh.ai/help/faq Customer: I can't log in to my account. Agent:
-
Less Effective: Give me a list of unmanaged devices in my network.
-
More Effective: Give me a list of high-risk unmanaged devices in my network. If they're named "test," remove them from the list.
6. Model Selection and Parameters
-
Use the latest model: Newer models tend to be easier to prompt and provide better results.
-
Adjust parameters: Experiment with "model" and "temperature" to influence the output.
-
Model: Higher-performance models offer better results but might be more expensive and slower.
-
Temperature: A higher value leads to more creative but potentially less accurate results. A value of 0 is best for factual tasks.
7. Advanced Techniques
-
Chain-of-thought prompting: Outline steps for sequential reasoning, mimicking human logic to solve problems or answer complex questions.
-
Prompt chaining: Use a series of prompts, each building on the previous response, for creative tasks like narrative generation or brainstorming.
-
Code generation: Use "leading words" to nudge the model toward a specific programming language. (e.g., "import" for Python, "SELECT" for SQL).
Examples:
-
Chain-of-thought prompting: Given a customer [complaint] about the issues in the installation steps of the build. First, identify possible reasons for the issues based on our [installation steps]. Next, outline appropriate reasons we can offer the customer, including steps they have to do to remove the software. Lastly, draft a final response incorporating these elements.
-
Prompt chaining: What strategic drivers does [company] have that our business unit for enterprise could solve for? Write me some discovery-based questions based on these identified strategic drivers. <Type this after you get a response to the above request> Share more about how [X] questions should be asked about the healthcare industry. <Type this after you get a response to the above request>
8. Additional Considerations
-
Check for accuracy: Double-check the AI's responses, as it may make mistakes.
-
Avoid slang, jargon, and informal language: Stick to clear and professional language for better results.
-
Don't overcomplicate prompts: Keep them simple and focused on tasks the AI can handle effectively.
-
Ensure ethical usage: Avoid prompts that may lead to biased or inappropriate content.