Home »
AI Prompts Tutorial
Instruction-Based Prompts
Instruction-based prompting is a technique in which an AI model is given a clear instruction describing the task it needs to perform. The prompt focuses on telling the AI what action to take and may include additional context, requirements, constraints, or output formats.
Instruction-based prompts are among the most common types of AI prompts because they can be used for writing, programming, analysis, summarization, translation, research, and many other tasks.
In this chapter, you will learn what instruction-based prompts are, how they work, different types of instruction prompts, practical examples, advantages, limitations, and best practices.
What Is an Instruction-Based Prompt?
An instruction-based prompt directly tells the AI model what you want it to do.
For example:
Write a short introduction to artificial intelligence.
The instruction "Write a short introduction" tells the AI model what action it should perform.
Another example is:
Summarize the following article in 100 words.
Here, the instruction tells the AI model to summarize the provided content and specifies the desired length.
How Do Instruction-Based Prompts Work?
An instruction-based prompt provides a task that the AI model interprets and uses to generate a response.
Instruction
|
v
AI Model
|
v
Generated Output
For more complex tasks, additional information can be added to the instruction.
Instruction:
Explain cloud computing to beginners.
Requirements:
Use simple English.
Include three practical examples.
Output:
Use headings and bullet points.
The AI model uses the instruction and additional requirements to generate the requested response.
Simple Instruction-Based Prompts
A simple instruction-based prompt may contain only a short command.
For example:
Explain machine learning.
Another example is:
List five programming languages.
These prompts are useful when the task is simple and does not require additional context.
Writing Instruction Prompts
Instruction-based prompts can be used to create different types of written content.
For example:
Write a 500-word article about cybersecurity for beginners.
Use simple English and include five common cybersecurity threats.
The instruction specifies the content type, topic, length, audience, language, and required information.
Summarization Instruction Prompts
Instruction prompts can tell an AI model to summarize information.
For example:
Summarize the following article in five bullet points:
Artificial intelligence is being used across healthcare,
education, finance, manufacturing, and many other industries.
The prompt clearly defines the summarization task and the desired output format.
Translation Instruction Prompts
Instruction-based prompts can be used to translate text between languages.
For example:
Translate the following sentence into French:
"Welcome to our website."
The instruction tells the AI model what language to translate the input into.
Rewriting Instruction Prompts
Instruction prompts can be used to rewrite existing content.
For example:
Rewrite the following paragraph in simple English.
Keep the original meaning and remove unnecessary technical terms.
This type of prompt is useful for improving readability and adapting content for different audiences.
Classification Instruction Prompts
Classification prompts provide an instruction that tells the AI model to assign information to a category.
For example:
Classify the following customer review as Positive, Negative, or Neutral:
"The product is easy to use, but the battery life is short."
The categories are explicitly provided as part of the instruction.
Analysis Instruction Prompts
Instruction-based prompts can ask an AI model to analyze information and provide insights.
For example:
Analyze the following sales data and identify the three products
with the highest revenue.
Present the results in a table.
The prompt defines both the analytical task and the expected output format.
Code Generation Instruction Prompts
Instruction prompts are widely used for programming tasks.
For example:
Write a Python program that checks whether a number is prime.
Include comments explaining the main steps.
Another example is:
Write a JavaScript function that calculates the factorial of a number.
Return the result and include one example function call.
The AI model generates code based on the provided instructions.
Data Extraction Instruction Prompts
Instruction-based prompts can also be used to extract specific information from text.
For example:
Extract the person's name, email address, and phone number
from the following text and present the result as a table.
The instruction identifies both the information to extract and the desired format.
Formatting Instruction Prompts
An instruction can specify how the AI model should format the response.
For example:
List the five advantages of cloud computing.
Use a numbered list.
For each advantage, provide a one-sentence explanation.
The prompt specifies the structure that should be followed.
Instruction Prompts With Constraints
Constraints can be added to instruction-based prompts to control the response.
For example:
Write an introduction to artificial intelligence.
Keep it under 200 words.
Use simple English.
Do not use technical jargon.
Include one practical example.
The main instruction is supported by several constraints.
Instruction Prompts With Context
Additional context can make an instruction more precise.
For example:
I am preparing a programming tutorial for college students.
Explain object-oriented programming.
Assume that the readers understand basic programming concepts.
Use simple English and include practical examples.
The context helps the AI model understand the intended audience and purpose.
Instruction Prompts With Role
An instruction-based prompt can also include a role to provide additional perspective.
For example:
Act as a senior Python developer.
Review the following Python code.
Identify errors, performance issues, and possible improvements.
Explain each issue in simple English.
The role provides additional context, while the instruction defines the task.
Instruction-Based Prompt Structure
A simple instruction prompt can contain only a task. More complex prompts can combine several components.
Role:
Act as a technical writer.
Context:
The content is intended for beginner programmers.
Instruction:
Explain REST APIs.
Requirements:
Explain REST, HTTP methods, and status codes.
Include one practical example.
Output:
Use headings and short paragraphs.
Not every instruction-based prompt needs all these components. The structure should depend on the complexity of the task.
Instruction-Based Prompts vs Question Prompts
A question prompt asks the AI model for information, while an instruction-based prompt tells the AI model to perform a specific task.
| Feature |
Question Prompt |
Instruction-Based Prompt |
| Purpose |
Requests an answer or explanation. |
Requests the AI to perform a task. |
| Example |
What is cloud computing? |
Explain cloud computing to beginners. |
| Common Uses |
Questions, learning, and information gathering. |
Writing, rewriting, coding, analysis, summarization, and formatting. |
When to Use Instruction-Based Prompts?
Instruction-based prompts are useful whenever you want an AI model to perform a specific action.
Common applications include:
- Writing content
- Summarizing documents
- Translating text
- Rewriting content
- Generating code
- Analyzing information
- Classifying text
- Extracting information
- Creating lists
- Formatting content
- Generating ideas
- Creating marketing content
Advantages of Instruction-Based Prompts
Instruction-based prompts provide several advantages.
- Easy to understand: The task is directly communicated to the AI model.
- Flexible: Instructions can be used for many different types of tasks.
- Easy to customize: Context, constraints, examples, and output formats can be added when needed.
- Suitable for automation: Clear instructions can be incorporated into repeatable AI workflows.
- Useful for complex tasks: Multiple instructions can be combined to describe detailed requirements.
Limitations of Instruction-Based Prompts
Instruction-based prompts may not always produce the expected result if the instructions are vague, incomplete, or contradictory.
Some limitations include:
- Vague instructions can produce general responses.
- Complex tasks may require additional examples or context.
- Conflicting instructions can lead to inconsistent results.
- The AI model may not always follow every requirement.
- Important information generated by the AI model may still require verification.
How to Write Effective Instruction-Based Prompts
Start by clearly defining the action you want the AI model to perform.
For example, instead of:
Python article.
Use:
Write a beginner-friendly article about Python programming.
Explain what Python is, its main features, common uses, and advantages.
Use simple English and include three practical examples.
The improved prompt clearly communicates the task and expected content.
Use Action Words
Instruction-based prompts often work well when they use clear action words.
Common action words include:
- Write
- Explain
- Summarize
- Analyze
- Compare
- Translate
- Rewrite
- Classify
- Extract
- Generate
- Convert
- List
- Review
- Identify
For example:
Compare Python and Java based on performance, syntax, learning curve,
and common use cases. Present the result in a table.
Break Complex Instructions Into Steps
When a task contains several requirements, organize the instructions into steps.
For example:
Analyze the following article.
1. Summarize the article.
2. Identify the main points.
3. List the advantages and disadvantages.
4. Identify any unclear statements.
5. Provide three suggestions for improvement.
This structure makes each requirement clear.
Best Practices for Instruction-Based Prompts
Follow these practices when creating instruction-based prompts:
- Clearly define the task.
- Use direct and specific language.
- Use appropriate action words.
- Provide relevant context.
- Specify the target audience when necessary.
- Define the expected output format.
- Add important constraints.
- Break complex tasks into smaller steps.
- Avoid contradictory instructions.
- Review the generated response.
- Refine the prompt when the output does not meet the requirements.
Example of an Effective Instruction-Based Prompt
The following prompt combines a clear instruction with context, requirements, and an output format:
Write a beginner-friendly tutorial about REST APIs.
Audience:
Students with basic programming knowledge.
Requirements:
Explain what REST APIs are, how they work, HTTP methods,
status codes, and one practical example.
Style:
Use simple English and short paragraphs.
Output:
Use headings, bullet points, and code examples.
This prompt clearly communicates what the AI model should do and provides the information needed to produce a structured response.
Advertisement
Advertisement