Elements of a Prompt
When prompting a language model, it can predict what's to come next, it doesn’t matter whether the prompt is grammatically correct or riddled with typos, it can figure out what you mean to type. When creating prompts, certain factors determine how well the model performs.
There are means of creating an effective prompt, including;
Content: The model needs the right information about a task before it completes it. Information can be in form of instructions, context, examples, etc.
Structure: The information provided matters. Models deliver more accurate and better results when the task is well-structured.
Components of Prompt engineering include:
Objective: The content should have an objective (mission or goal), providing the model with specific information about what needs to be achieved.
Instruction: It should include step-by-step instructions on how to perform the task. This is also called "task", "direction", or "steps"
Additional components of a prompt include;
System Instructions: Instructions that tell the model how to behave
Persona: Defines the role or persona the model should adopt
Constraints: The rules the output must follow
Tone: Describes the style of response
Context: The information the model needs to understand the question.
Few-shot examples: Sample inputs and outputs to guide the model's response
Reasoning steps: Reasoning steps guide the model to show how it thinks or processes information
Response Format: The form of response, which can be in form of a table, paragraph, bulleted list, pitch, etc.
Recap: Repeating important points of the prompt
Safeguard: Measures to ensure safety and ethical use
These components vary by task and can be structured based on how you want the model to respond.
Example of an engineered prompt versus a normal user prompt:
Typical Prompt: Write an email to schedule a meeting
Better Prompt: Write a polite and professional email to schedule a general meeting on July 13, 2025. This email should include a request for confirmation of attendance. Mention that the meeting memo will be disclosed during the meeting.
No prompt is considered wrong; however, these strategies can optimize the model's performance. By refining prompts continuously, the model's capabilities are maximized, enabling it to deliver more intelligent and efficient responses.
How LLMs and Generative AI Impact Prompt Engineering
Gen AI and LLMs are considered the foundation of prompt engineering.
Generative AI is a broader concept, and it focuses on AI generating content that's not text only, but images, videos, 3D models, code, music, etc It learns from patterns gotten from training data sets and then uses them to generate new outputs.
LLMS is a subset of Generative AI trained on large data to understand and generate natural language. They perform numerous tasks like text generation, translation, reasoning, and summarization. Examples include OpenAI's GPT, Meta's LLaMa, Anthropic's Claude, and Google PaLM.
LLMs and GenAI (e.g., GPT-4, DALL-E) can respond to questions, solve problems, write code, create images, etc, but their response depends on how well the input or prompt is written.
Prompt engineers can create templates or scripts to help users get high-quality results. They are employed by companies to optimize AI-powered systems like chatbot content generators and virtual assistants, ensuring they are efficient and effective.
A prompt engineer's workflow includes defining the task, writing prompts, and testing prompts. Prompt engineering makes responses from AI models more accurate and relevant. The process is as follows;
Prompt Creation: When writing prompts, having an unambiguous context is necessary. Role-playing can also be used to assist the models to assume a specific role in order to deliver a tailored response. Additionally, setting constraints can guide the model in delivering a desired output, while avoiding leading questions can prevent the model's output from becoming biased.
Iteration and evaluation: The process of refining prompts by iteration. A typical prompt engineering workflow includes:
Draft prompts: AI produces accurate, structured, and useful responses when the prompts are carefully drafted.
Test prompts: Using AI model to produce a response.
Evaluate prompt output: This involves checking if the response matches what you asked for.
Refine the prompt: Modifying the prompt based on its response.
Repeat: Continuing the process until the desired output is achieved.
Fine-tuning: Involves adjusting the model's parameters to align with specific tasks. This technique is advanced, and it improves the model's performance based on specialised applications.
Techniques of Prompt Engineering
Some examples of techniques used by prompt engineers to improve the AI model include;
Chain-of-thought prompting: This technique breaks down complex questions into smaller and logical parts, mimicking how the train of thought works. This process helps models solve problems in steps instead of answering questions directly, enhancing reasoning.
Example: Start by explaining what an API in programming is in simple terms. Then explain how the API can be used in a function.
Tree-of-thought prompting:
The tree-of-thought techniques help language models solve problems by examining different possible solutions or breaking problems down into steps and exploring multiple possible reasoning paths before giving a final answer.
Example: Think step-by-step and consider different possible ways to solve the cryptogram. Explain the reasoning behind each option and choose the best solution.
Generated Knowledge prompting: This is a prompting technique where a language model is first asked to generate relevant information related to a task. The response returned is added to a second prompt, along with a specific question or task description.
First prompt to generate relevant information: This is the first prompt used to generate relevant information. For example: Retrieve current statistics on the number of active computers on the Internet.
Final prompt: The final prompt combines the knowledge generated in the first prompt by the model and the question or actual task you want the model to perform
Least-to-most prompting: This prompting involves breaking down a problem into sub-problems so the model can solve them in sequence. It starts with a basic prompt, if the model fails, re-prompt with clarification, and then increase levels of guidance as needed until the problem is solved.
This is used in tutoring scenarios or tasks involving independent reasoning, offering support without answering immediately.
Self-refine prompting: This technique prompts the model to generate an initial response, evaluate, and revise it. The process involves:
Prompt the model to complete a task
Prompt the model to review and identify issues in its response.
Instruct it to rewrite the answer based on its review
This technique improves accuracy, clarity, and quality of the model's responses.
Benefits of Prompt Engineering
Control: Developers can control interactions with AI by providing effective prompts and establishing context to large language models, which helps AI refine responses.
User Experience: Engineered prompts make AI tools easier and intuitive for users, making it possible for users to get the results they desire.
Flexibility: Prompt engineering enables you to adapt prompts for different tasks, allowing fine-tuning of outputs without retraining the model.
Faster Iterations: Prompts can be adjusted to improve results for quick testing and development, eliminating long development cycles.
Better Output Quality: Prompts that are well crafted help guide the model to deliver structured and specific results, producing more accurate and relevant results.
Best Practice for Prompt Engineering
Natural Language Models like Claude, Gemini, and ChatGPT are designed to mimic human language. They follow and respond to different types of instructions; however, some models perform better with more direct and structured prompts.
Here are a few tips that work across the board;
Remove all Fluff: Phrases like, can you please? Do you mind? What do you think about? AI doesn't care about politeness like humans because it doesn't have feelings.
These words, like "please," are extra tokens the model has to process. According to OpenAI, it spends millions to process polite phrases such as "Thank You" and "Please"
Instead of: Can you please write a short story?
Say: Write a short story ....
This reduces processing effort and helps the model focus on the actual task.
Be descriptive: AI thrives on clear instructions about what you want, the length, the tone, and the context.
Example: Write a one-paragraph message to a friend, in a casual and friendly tone, letting them know that I’ll be running late and will arrive at the event by 2:30 PM
Provide Context and Specifics: Specifics tell the model what to write about, and Context helps it understand how to write.
Instead of:
Write a blog post about digital technology
Say:
Write a 2000-word blog post about digital technology for beginners. Use a conversational tone. Target people in the early stages of learning, include facts, and end with thought-provoking questions for learners.
Role-Playing: This technique involves instructing the model about the specific role to play. It acts as a filter that guides the model's tone, response style, and helps produce results in more relevant and context-aware outputs.
Example: You are a computer science teacher. Explain how data structure and algorithms works in simple terms for beginners. Use relatable examples and keep the explanation beginner-friendly.
Use Limitations: AI might overexplain or generate more content than you need. That's why you should limit the response and narrow the focus to only what's necessary. To keep response or output manageable and relevant, use directive words like" only, "focus on", or “avoid." These words guide the model on what and how to write.
In the case of image generation, you need to clearly describe what you want to see. Providing detailed and structured instructions helps the model generate more accurate results.
Key components of a good image prompt include;
Subject: Define the main character of your image story or object. This is usually a noun, e.g., House, A cup with eyes, nose, and mouth
Description: Include specific details. Be as descriptive as you can be. Example: A whimsical ceramic teacup with large cartoon eyes, a tiny nose, and a smiling mouth, sitting on a ceramic table in a moonlit kitchen.
Style/ Aesthetic: Indicate the art style, mood, or atmosphere. Include if you want minimalist, dramatic, cartoonish images, etc Include if you want a wide-shot or full shots, etc
Prompting Techniques for Image Generation
You can follow prompting techniques such as;
Be Very Descriptive: Be vivid and specific. Write your prompts like a storyteller. Include descriptions like scene, colours, objects, emotions, etc
Prompt Length Matters: The length of the prompt influences how elements appear. Some AI models give more accurate descriptions when prompt is very detailed, while some respond better to short and focused prompts.
Include Negative Prompt (What you don't want): List elements you want to avoid. Be specific as well because it helps the model avoid unwanted elements.
Include Resolution and Quality: This impacts image generation significantly. Understand how resolution and layout work, use terms like:
High resolutions
3k or 4k
3D rendering
For aspect ratio/ layout:
This varies across image generation platforms.