Contents
Prompt Engineering
What Is Prompt Engineering?
Prompt engineering is the practice of designing and refining instructions to help an AI model produce more useful and relevant outputs.
A prompt can include a task, context, constraints, examples, and the desired output format.
A well-designed prompt reduces ambiguity and makes the expected result easier to understand.
Components of an Effective Prompt
A useful prompt often contains:
- Role or perspective: The type of expertise or viewpoint required.
- Task: What the model must do.
- Context: Relevant background information.
- Constraints: Rules, limits, or requirements.
- Output format: How the answer should be structured.
Example: Improving a Prompt
Weak prompt:
"Explain APIs."
This does not specify the audience, scope, or desired format.
Improved prompt:
"Explain REST APIs to a beginner learning Node.js. Cover endpoints, HTTP methods, request bodies, and status codes. Provide a small Express.js example and explain the code in simple language. Keep the explanation under 500 words."
The improved prompt defines the audience, topics, example requirements, and length.
Common Prompting Techniques
Zero-shot prompting: Ask the model to complete a task without providing examples.
Few-shot prompting: Provide a few examples demonstrating the expected behavior.
Role prompting: Specify a perspective, such as asking the model to act as a technical interviewer.
Structured prompting: Define sections, constraints, or an output schema.
Iterative prompting: Refine the prompt based on the model's previous output.
For complex tasks, splitting the request into smaller steps can make the result easier to review and improve.
Artificial Intelligence Tutorial
Vishalini A








