Update docs/llm/Effective-LLM-Prompting.md
This commit is contained in:
@@ -1,67 +1,71 @@
|
||||
# 📘 Ultimate Guide to Prompt Crafting for LLMs
|
||||
|
||||
## 🎯 Overview
|
||||
This guide is crafted to empower developers and enthusiasts in creating effective prompts for Language Learning Models (LLMs), streamlining the process to elicit the best possible responses for various tasks.
|
||||
This comprehensive guide provides detailed strategies for crafting prompts that effectively communicate with Language Learning Models (LLMs). It aims to facilitate the creation of prompts that yield precise and contextually relevant responses across a variety of applications.
|
||||
|
||||
## 🛠 Best Practices
|
||||
|
||||
### ✏️ Grammar Fundamentals
|
||||
- **Consistency**: Use a consistent tense and person to maintain clarity.
|
||||
- **Clarity**: Avoid ambiguous pronouns; always clarify the noun they refer to.
|
||||
- **Modifiers**: Use modifiers directly next to the word or phrase they modify to avoid dangling modifiers.
|
||||
- **Consistency**: Maintain the same tense and person throughout your prompt to avoid confusion. For instance, if you begin in the second person present tense, continue with that choice unless a change is necessary for clarity.
|
||||
- **Clarity**: Replace ambiguous pronouns with clear nouns whenever possible to ensure the LLM understands the reference. For example, instead of saying "It is on the table," specify what "it" refers to.
|
||||
- **Modifiers**: Place descriptive words and phrases next to the words they modify to prevent confusion. For instance, "The dog, which was brown and furry, barked loudly," ensures that the description clearly pertains to the dog.
|
||||
|
||||
### 📍 Punctuation Essentials
|
||||
- **Periods**: End declarative sentences with periods for straightforward communication.
|
||||
- **Commas**: Use the Oxford comma in lists to prevent misinterpretation.
|
||||
- **Quotation Marks**: Apply quotation marks correctly for direct speech and citations.
|
||||
- **Periods**: Use periods to end statements, making your prompts clear and decisive.
|
||||
- **Commas**: Employ the Oxford comma to clarify lists, as in "We need bread, milk, and butter."
|
||||
- **Quotation Marks**: Use quotation marks to indicate speech or quoted text, ensuring that the LLM distinguishes between its own language generation and pre-existing text.
|
||||
|
||||
### 📝 Style Considerations
|
||||
- **Active Voice**: Utilize active voice to make prompts more direct and powerful.
|
||||
- **Conciseness**: Eliminate redundant words; make every word convey meaning.
|
||||
- **Transitions**: Employ transitional phrases to create a smooth flow between thoughts.
|
||||
- **Active Voice**: Write prompts in the active voice to make commands clear and engaging. For example, "Describe the process of photosynthesis" is more direct than "The process of photosynthesis should be described."
|
||||
- **Conciseness**: Remove unnecessary words from prompts to enhance understanding. Instead of "I would like you to make an attempt to explain," use "Please explain."
|
||||
- **Transitions**: Use transitional words to link ideas smoothly, aiding the LLM in following the logical progression of the prompt.
|
||||
|
||||
### 📚 Vocabulary Choices
|
||||
- **Specificity**: Choose precise words for accuracy and to reduce ambiguity.
|
||||
- **Variety**: Use diverse vocabulary to keep prompts engaging and to avoid repetitiveness.
|
||||
- **Specificity**: Select precise terminology to minimize confusion. For instance, request "Write a summary of the latest IPCC report on climate change" rather than "Talk about the environment."
|
||||
- **Variety**: Incorporate a range of vocabulary to maintain the LLM's engagement and prevent monotonous responses.
|
||||
|
||||
## 🤔 Prompt Types & Strategies
|
||||
|
||||
### 🛠 Instructional Prompts
|
||||
- **Clarity**: Be explicit about the task and expected outcome.
|
||||
- **Structure**: Outline the desired format and structure when necessary.
|
||||
- **Clarity**: Clearly define the task and the desired outcome to guide the LLM. For example, "List the steps required to encrypt a file using AES-256."
|
||||
- **Structure**: Specify the format, such as "Present the information as an FAQ list with no more than five questions."
|
||||
|
||||
### 🎨 Creative Prompts
|
||||
- **Flexibility**: Give a clear direction but leave space for creative freedom.
|
||||
- **Inspiration**: Provide a theme or a concept to spark creativity.
|
||||
- **Flexibility**: Offer a clear direction while allowing for imaginative interpretation. For example, "Write a short story set in a world where water is the most valuable currency."
|
||||
- **Inspiration**: Stimulate creativity by providing a concept, like "Imagine a dialogue between two planets."
|
||||
|
||||
### 🗣 Conversational Prompts
|
||||
- **Tone**: Set the desired tone to guide the LLM's language style.
|
||||
- **Engagement**: Phrase prompts to encourage a two-way interaction.
|
||||
- **Tone**: Determine the desired tone upfront, such as friendly, professional, or humorous, to shape the LLM's response style.
|
||||
- **Engagement**: Craft prompts that invite dialogue, such as "What questions would you ask a historical figure if you could interview them?"
|
||||
|
||||
## 🔄 Iterative Prompt Refinement
|
||||
|
||||
### 🔍 Output Evaluation Criteria
|
||||
- **Alignment**: Ensure the output aligns with the prompt's intent.
|
||||
- **Depth**: Check for the depth of response and detail.
|
||||
- **Structure**: Evaluate the logical structure and coherence of the response.
|
||||
- **Alignment**: Match the output with the prompt's intent, and if it diverges, refine the prompt for better alignment.
|
||||
- **Depth**: Assess the level of detail in the response, ensuring it meets the requirements specified in the prompt.
|
||||
- **Structure**: Check the response for logical consistency and coherence, ensuring it follows the structured guidance provided in the prompt.
|
||||
|
||||
### 💡 Constructive Feedback
|
||||
- **Specificity**: Point out exact areas for improvement.
|
||||
- **Guidance**: Offer clear direction on how to adjust the output.
|
||||
- **Specificity**: Give precise feedback about which parts of the output can be improved.
|
||||
- **Guidance**: Offer actionable advice on how to enhance the response, such as asking for more examples or a clearer explanation.
|
||||
|
||||
## 🚫 Pitfalls to Avoid
|
||||
|
||||
- **Overcomplexity**: Steer clear of overly complex sentence constructions.
|
||||
- **Ambiguity**: Avoid vague references that can lead to ambiguous interpretations.
|
||||
- **Overcomplexity**: Simplify complex sentence structures to make prompts more accessible to the LLM.
|
||||
- **Ambiguity**: Eliminate vague terms and phrases that might lead to misinterpretation by the LLM.
|
||||
|
||||
## 📌 Rich Example Prompts
|
||||
|
||||
To illustrate the practical application of these best practices, here are examples of poor and improved prompts, showcasing the transformation from a basic request to a well-structured prompt:
|
||||
|
||||
- ❌ "Make a to-do list."
|
||||
- ✅ "Create a categorized to-do list for a software project, with tasks organized by priority and estimated time for completion."
|
||||
|
||||
- ❌ "Explain machine learning."
|
||||
- ✅ "Write a comprehensive explanation of machine learning for a layman, including practical examples, without using jargon."
|
||||
|
||||
By adhering to these best practices, developers and enthusiasts can craft prompts that are optimized for clarity, engagement, and specificity, leading to improved interaction with LLMs and more refined outputs.
|
||||
|
||||
## 💡 Practical Application: Iterating on Prompts Based on LLM Responses
|
||||
|
||||
This section offers practical strategies for refining prompts based on the responses from Language Learning Models (LLMs), which is crucial for achieving the most accurate and relevant outputs.
|
||||
|
||||
Reference in New Issue
Block a user