Update docs/llm/Effective-LLM-Prompting.md
This commit is contained in:
@@ -1,67 +1,71 @@
|
|||||||
# 📘 Ultimate Guide to Prompt Crafting for LLMs
|
# 📘 Ultimate Guide to Prompt Crafting for LLMs
|
||||||
|
|
||||||
## 🎯 Overview
|
## 🎯 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
|
## 🛠 Best Practices
|
||||||
|
|
||||||
### ✏️ Grammar Fundamentals
|
### ✏️ Grammar Fundamentals
|
||||||
- **Consistency**: Use a consistent tense and person to maintain clarity.
|
- **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**: Avoid ambiguous pronouns; always clarify the noun they refer to.
|
- **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**: Use modifiers directly next to the word or phrase they modify to avoid dangling modifiers.
|
- **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
|
### 📍 Punctuation Essentials
|
||||||
- **Periods**: End declarative sentences with periods for straightforward communication.
|
- **Periods**: Use periods to end statements, making your prompts clear and decisive.
|
||||||
- **Commas**: Use the Oxford comma in lists to prevent misinterpretation.
|
- **Commas**: Employ the Oxford comma to clarify lists, as in "We need bread, milk, and butter."
|
||||||
- **Quotation Marks**: Apply quotation marks correctly for direct speech and citations.
|
- **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
|
### 📝 Style Considerations
|
||||||
- **Active Voice**: Utilize active voice to make prompts more direct and powerful.
|
- **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**: Eliminate redundant words; make every word convey meaning.
|
- **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**: Employ transitional phrases to create a smooth flow between thoughts.
|
- **Transitions**: Use transitional words to link ideas smoothly, aiding the LLM in following the logical progression of the prompt.
|
||||||
|
|
||||||
### 📚 Vocabulary Choices
|
### 📚 Vocabulary Choices
|
||||||
- **Specificity**: Choose precise words for accuracy and to reduce ambiguity.
|
- **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**: Use diverse vocabulary to keep prompts engaging and to avoid repetitiveness.
|
- **Variety**: Incorporate a range of vocabulary to maintain the LLM's engagement and prevent monotonous responses.
|
||||||
|
|
||||||
## 🤔 Prompt Types & Strategies
|
## 🤔 Prompt Types & Strategies
|
||||||
|
|
||||||
### 🛠 Instructional Prompts
|
### 🛠 Instructional Prompts
|
||||||
- **Clarity**: Be explicit about the task and expected outcome.
|
- **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**: Outline the desired format and structure when necessary.
|
- **Structure**: Specify the format, such as "Present the information as an FAQ list with no more than five questions."
|
||||||
|
|
||||||
### 🎨 Creative Prompts
|
### 🎨 Creative Prompts
|
||||||
- **Flexibility**: Give a clear direction but leave space for creative freedom.
|
- **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**: Provide a theme or a concept to spark creativity.
|
- **Inspiration**: Stimulate creativity by providing a concept, like "Imagine a dialogue between two planets."
|
||||||
|
|
||||||
### 🗣 Conversational Prompts
|
### 🗣 Conversational Prompts
|
||||||
- **Tone**: Set the desired tone to guide the LLM's language style.
|
- **Tone**: Determine the desired tone upfront, such as friendly, professional, or humorous, to shape the LLM's response style.
|
||||||
- **Engagement**: Phrase prompts to encourage a two-way interaction.
|
- **Engagement**: Craft prompts that invite dialogue, such as "What questions would you ask a historical figure if you could interview them?"
|
||||||
|
|
||||||
## 🔄 Iterative Prompt Refinement
|
## 🔄 Iterative Prompt Refinement
|
||||||
|
|
||||||
### 🔍 Output Evaluation Criteria
|
### 🔍 Output Evaluation Criteria
|
||||||
- **Alignment**: Ensure the output aligns with the prompt's intent.
|
- **Alignment**: Match the output with the prompt's intent, and if it diverges, refine the prompt for better alignment.
|
||||||
- **Depth**: Check for the depth of response and detail.
|
- **Depth**: Assess the level of detail in the response, ensuring it meets the requirements specified in the prompt.
|
||||||
- **Structure**: Evaluate the logical structure and coherence of the response.
|
- **Structure**: Check the response for logical consistency and coherence, ensuring it follows the structured guidance provided in the prompt.
|
||||||
|
|
||||||
### 💡 Constructive Feedback
|
### 💡 Constructive Feedback
|
||||||
- **Specificity**: Point out exact areas for improvement.
|
- **Specificity**: Give precise feedback about which parts of the output can be improved.
|
||||||
- **Guidance**: Offer clear direction on how to adjust the output.
|
- **Guidance**: Offer actionable advice on how to enhance the response, such as asking for more examples or a clearer explanation.
|
||||||
|
|
||||||
## 🚫 Pitfalls to Avoid
|
## 🚫 Pitfalls to Avoid
|
||||||
|
|
||||||
- **Overcomplexity**: Steer clear of overly complex sentence constructions.
|
- **Overcomplexity**: Simplify complex sentence structures to make prompts more accessible to the LLM.
|
||||||
- **Ambiguity**: Avoid vague references that can lead to ambiguous interpretations.
|
- **Ambiguity**: Eliminate vague terms and phrases that might lead to misinterpretation by the LLM.
|
||||||
|
|
||||||
## 📌 Rich Example Prompts
|
## 📌 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."
|
- ❌ "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."
|
- ✅ "Create a categorized to-do list for a software project, with tasks organized by priority and estimated time for completion."
|
||||||
|
|
||||||
- ❌ "Explain machine learning."
|
- ❌ "Explain machine learning."
|
||||||
- ✅ "Write a comprehensive explanation of machine learning for a layman, including practical examples, without using jargon."
|
- ✅ "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
|
## 💡 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.
|
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