# Overview The approach for creating effective instructions (i.e., 'prompts') for [[Large Language Models (LLMs)]]. There are two primary principles: - Write clear and specific instructions - Give the model time to think More broadly, prompt engineering is a discipline within [[Context Engineering]]. # Key Considerations ## Core Principles ### Write Clear and Specific Instructions - Use delimiters to clearly notate different portions of the prompt (``, ', |, etc.) - This can also help prevent prompt injection - Ask for structured output (e.g., ask for the response in JSON) - Ask the model to check whether certain conditions are met - Few-shot prompting - provide examples of a successful reply to the prompt ### Give the Model Time to Think - Divide the prompts into linear steps for the model to complete - Instruct the model to work out its own solution before rushing to a conclusion ## Reducing [[hallucinations]] Ask the model to first find relevant information from an article, then answer the question based on the relevant information. # Implementation Details ## General Tips and Tricks - [Build the perfect prompt every time. Prompt Included : r/ChatGPTCoding](https://www.reddit.com/r/ChatGPTCoding/comments/1h8jozp/build_the_perfect_prompt_every_time_prompt/) - **Prompt Chain:** - Analyze the following prompt idea: *insert prompt idea* ~Rewrite the prompt for clarity and effectiveness ~Identify potential improvements or additions ~Refine the prompt based on identified improvements ~Present the final optimized prompt (Each prompt is separated by ~, you can pass that prompt chain directly into the [Agentic Worker](https://www.agenticworkers.com/library/esmo-kmwed-optimize-and-refine-a-custom-prompt) to automatically queue it all together) - [[Zero-shot Classification]] vs. [[Few-shot Classification]] - **Put longform data at the top**: Place your long documents and inputs near the top of your prompt, above your query, instructions, and examples. This can significantly improve performance across all models. - **Ground responses in quotes**: For long document tasks, ask Claude to quote relevant parts of the documents first before carrying out its task. This helps Claude cut through the noise of the rest of the document's contents. - [Prompting best practices - Claude API Docs](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#overthinking-and-excessive-thoroughness) ### Tool Calling - <default_to_action> By default, implement changes rather than only suggesting them. If the user's intent is unclear, infer the most useful likely action and proceed, using tools to discover any missing details instead of guessing. Try to infer the user's intent about whether a tool call (e.g., file edit or read) is intended or not, and act accordingly. </default_to_action> ## Types of Prompts to use for Agentic Prompts - The Workflow Prompt - Metadata - Workflow - Instructions - Variables - Reports - Relevant Files - Codebase Structure - The Control Flow Prompt - The Delegate Prompt ## Prompts for Summarizing Can use word, sentence, or character counts to limit the length of the summary. ## Prompts for Inferring Inferring covers tasks that require the model to understand the context of a text, such as sentiment, named entity recognition, zero shot learning ## Prompts for Transforming Transformations include: - Addressing spelling mistakes - Changing languages - Changing tone of the message ## Prompts for Expanding For example, turning reviews into customer service e-mails. ## Prompts for Chatbots Use the 'roles' concept to tell the system what it is. # Useful Links # Related Topics ## Reference #### Working Notes #### Sources - [ChatGPT Prompt Engineering for Developers - DeepLearning.AI](https://learn.deeplearning.ai/courses/chatgpt-prompt-eng/lesson/1/introduction) - [Prompt Engineering Guide | Prompt Engineering Guide\<!-- --\>](https://www.promptingguide.ai/) - [Prompting best practices - Claude API Docs](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices)