Lesson 03 Prompt Engineering
Lesson 03 Prompt Engineering
Prompt engineering refers to the process of crafting and designing effective prompts or instructions to
guide language models, such as ChatGPT, in generating desired outputs.
Prompt engineering plays a critical role in optimizing the performance of language models, leading to
several key advantages:
Improved user
experience
Bias
mitigation
Task-specific
optimization
Control and
customization
Accuracy and
relevance
Prompt Engineering: Example
Prompt:
Prompt response:
Prompt:
Prompt response:
Prompt:
Translate the following English text into French: The cat is sitting on
the mat.
Prompt response:
The model accurately translates the English text into French, ensuring
an effective and reliable communication tool for users.
Language translation
Basic Architecture and Components of a Prompt
Basic Architecture and Components of a Prompt
The basic architecture of a prompt consists of several key components that work together to guide the
behavior and output of a language model.
Basic Architecture and Components of a Prompt
Context:
• The context provides background information or preceding dialogue that helps
set the stage for the model's response.
• It helps the model understand the conversation or the specific task at hand,
ensuring continuity and coherence in the generated output.
Instructions:
• Instructions are explicit guidelines or directives given to the model to guide its
behavior.
• They specify the desired outcome, format, or constraints for the response.
• Clear and specific instructions help shape the model's understanding and generate
more relevant and accurate outputs.
Basic Architecture and Components of a Prompt
Formulating effective prompts is essential for guiding language models to generate accurate
and relevant responses.
Use examples Consider length and detail Control style and tone
Various techniques that can be employed to create prompts that guide model
behavior are:
Manual prompt crafting involves the manual creation of prompts by domain experts or researchers.
The system applies the rules to generate prompts based on certain criteria or
guidelines.
• In this example, rule-based prompt generation relies on predefined rules or criteria for
prompt structure based on input text characteristics.
• A rule is set to determine the appropriate prompt structure based on word count.
• If input text exceeds a specific word count (in this case, 100 words), key sentences are
extracted for the summary.
• For shorter texts, the main points are condensed into a concise paragraph for the summary.
Prompting ChatGPT
Prompting ChatGPT: Q&A
The following provides instructions for how to prompt ChatGPT in a Q&A format:
Assistant: The main factors influencing climate change include many reasons.
Prompting ChatGPT: Q&A
Inaccurate prompt
Clarity
Clarity:
Maintain clarity in the summary by using simple, direct language
Conciseness:
Keep the summary concise by capturing the principal ideas or crucial information succinctly
Logical coherence:
Structure the summary logically, ensuring a smooth flow and easy comprehension for the reader
• Capture the essence and context of the original content in the summary
• Preserve the overall meaning and purpose during the condensation of information
Maintain accuracy:
• Retain the accuracy and integrity of the original content when condensing
• Avoid distortion or misrepresentation of facts or ideas
• Identify and prioritize the most crucial concepts, events, or arguments in the summary.
• Exclude minor details or peripheral information
Prompting ChatGPT: Summarize
Prompt: Please summarize the main events Prompt: Please summarize the entire field of
of the American Revolutionary War. quantum physics in one sentence.
Structure Context
Start from a foundational level and build Verify information from reliable sources
up the explanation, ensuring the and double-check technical details or
coverage of all essential information factual claims before the presentation
Answer potential
Provide depth
questions
Tailor the depth of the explanation to Anticipate common questions or points
the intended audience or context, of confusion and proactively address
avoiding unnecessary complexity or them in the explanation, clarifying
oversimplification potential areas of uncertainty
Prompting ChatGPT: Explain
Inaccurate
Prompt: Please explain the entire field of mathematics in one sentence.
prompt
Prompting ChatGPT: Completion
Prompt Style or
length tone
Iterative
Constraints
prompts
Supply ample context for
completion tasks, incorporating
necessary information or
• Use iterative prompts for preceding text Define constraints or
desired outcomes requirements clearly,
• Adjust prompt wording or instructing the model on
context, as necessary topics, themes, or narrative
Context direction
Prompting ChatGPT: Completion
The right prompt precisely conveys what needs to be done, while the wrong prompt tends to be
generalized and fails to provide proper instruction.
Inaccurate prompt Prompt: Write a novel about a detective solving a mysterious crime.
Prompting ChatGPT: Translation
2 Clarity Include all relevant context and information to facilitate the translation process
4 Accuracy Specify both the source language and the target language clearly
Prompting ChatGPT: Translation
Inaccurate prompt: Prompt: Please translate the entire document from English to French.
Best Practices, Considerations, and Limitations
Best Practices and Considerations
Verify information
independently
Always verify critical information
from reliable sources even though
ChatGPT provides useful insights
Limitations of ChatGPT
It is important to be aware of the limitations and exercise critical thinking and caution when
interpreting and relying on ChatGPT's responses.
• It may generate responses that sound plausible but are factually incorrect
or lack common sense reasoning.
Lack of common
sense • It does not possess inherent knowledge or understanding beyond what it
has been trained on.
Remember: Your aim is to see how your descriptive prompts influence the AI's
visual output.
Key Takeaways
The right prompt precisely conveys what needs to be done, while the
wrong prompt tends to be generalized and fails to provide proper
instruction.
A. Context
B. Instructions
C. Examples
D. Output generation
Knowledge
Check
Which component is NOT a part of the basic architecture of a prompt-based system?
2
A. Context
B. Instructions
C. Examples
D. Output generation
Clear and specific instructions help achieve accurate and relevant outputs.
Knowledge
Check
Which task can be accomplished through prompt engineering with ChatGPT?
4
A. Image classification
B. Sentiment analysis
C. Language translation
D. Speech recognition
Knowledge
Check
Which task can be accomplished through prompt engineering with ChatGPT?
4
A. Image classification
B. Sentiment analysis
C. Language translation
D. Speech recognition