Lesson_02_Optimizing_GenAI_Models
Lesson_02_Optimizing_GenAI_Models
Clarity
Specificity
Format
Context
Importance of Prompt Engineering
It is increasingly recognized as a crucial skill set in the realm of GenAI. Here are several key reasons why
prompt engineering is needed:
Maximize AI potential
Whenever you give a generic prompt, you'll get a random response each time, but engineered prompts
will bring back a relevant response.
Listed below are some advanced techniques for prompting GenAI models to achieve desired outcomes.
Tree-of-thought prompting
Zero-Shot Prompting
It is a technique that provides a quick response with minimal guidance, helps in setting the context, and
gives the desired output without any specific examples.
It is a style of guiding GenAI models with specific examples to achieve desired responses.
It is a method of providing sequential prompts to the GenAI model to generate sequential outputs,
rather than getting the entire output at once.
It ensures that a GenAI bot delivers reliable and similar responses when asked the same
questions repeatedly.
Example
This process makes the AI more reliable, reduces confusion, enhances the user experience,
and paves the way for efficient learning.
Do It on Your Own: Self-Consistency Prompting
It is useful for tasks that require strategic thinking or involve multiple steps.
ToT Prompting: Example
Note: The AI uses ToT to break down the problem into smaller steps, evaluate each
step, and arrive at the correct solution.
Best Practices for Creating Prompts
Best Practices: Prompt Creation
Dos
Dos
• Example: Your explanation of photosynthesis was helpful, but could you also briefly
explain how plants use the energy produced during that process?
• Example: For this blog post, I need around 500 words written in a conversational,
lighthearted tone with examples or analogies to explain complex concepts. Please use
headings to break it into 3-4 sections.
Best Practices: Prompt Creation
Don’ts
• Example: Just give me the ingredients list for a basic spaghetti recipe, nothing more. I
don't need details on preparation steps, cooking times, or serving suggestions.
• Example: First, draft an outline for the introduction section of the report. Then,
research and write the background information. After that, analyze the data and
summarize the key findings. Let's work on one component at a time.
Best Practices: Prompt Creation
Don’ts
• Example: Describe a utopian society where everyone lives in harmony, but also
include details about conflicts and divisions between different groups.
Note: Always validate the information given by the tool, as the GenAI model might
generate an inaccurate response.
Demo: Refining Prompts
Duration: 15 minutes
In this demo, we will continue iterating on the prompt, demonstrating techniques like:
• Asking clarifying questions about elements that are still vague or unclear
• Providing examples to illustrate the desired type of response
• Adding or removing specificity as needed
• Setting guidelines for length, tone, structure, and more
Note: Please download the demo documents from the LMS Reference Material Section for a
detailed explanation.
Introduction to Fine-Tuning
Pre-Training
Prompt
LLM
Generated output
Fine-Tuning
Fine-tuning involves taking pre-trained models and training them more on smaller, specific
datasets to enhance performance in a particular task or domain.
Why is network
traffic encrypted?
Enhanced performance
Fine-tuning GPTs on task-specific data helps them understand the subtle details and
complexities of the target domain.
Encrypted files with the .zzz Encrypted files with the .zzz
extension, ransom note extension, ransom note
demanding payment? demanding payment?
LLM LLM
Fine-tuning isn't always the best choice. Consider this scenario: You've fine-tuned a base model using
your Slack messages dataset.
Pre-trained LLMs may carry biases, which can worsen during fine-
Bias tuning. Bias mitigation measures should be in place before fine-
tuning.
In this activity, you will craft an effective prompt by applying advanced prompting techniques. This
activity will help you gain hands-on experience with writing prompts.
Note: Please download the demo documents from the LMS Reference Material Section for a
detailed explanation.
Key Takeaways