How to Get the Best Results from AI with Smart Prompt Engineering

Nipuni Premadasa
6 min readJan 21, 2025

--

Hey there! 👋 Recently, I took a deep dive into the fascinating world of Prompt Engineering, and let me tell you, it’s both an art and a science. Whether you’re using ChatGPT, Bard, Claude, or any other large language model (LLM), crafting the perfect prompt can make all the difference in getting great results.

So, let me take you on a journey through what I’ve learned! 🚀

What is Prompt Engineering? 🤔

Before jumping in, let’s break it down:

  • Prompt — A detailed guideline you give to an LLM to accomplish a specific task. Think of it as giving clear instructions to a helpful assistant.
  • Engineering — The iterative process of refining and improving that prompt to get the perfect output. This involves experimenting and tweaking to achieve optimal results.

In short, prompt engineering is all about developing task-specific prompts that enable an AI model to deliver the best results. 💡

The Iterative Process 🔄

Creating a good prompt isn’t a one-shot deal. It’s an iterative process where you start with an idea, test it, refine it, and repeat until you get the desired output.

The process

  1. Idea - Think about what you want the AI to do.
  2. Give Prompt - Provide your initial prompt to the AI.
  3. Get Results - Observe the AI’s response.
  4. Feedback - Improve the prompt based on the results.

Example: You might ask ChatGPT “Summarize this report.” But the response may be too broad. So, you refine your prompt by saying “Focus only on the financial aspects from 2020 to 2023.” Now, the AI produces a more targeted summary.

Always remember to start a conversation with the AI! The more feedback you provide, the better it gets. 🎯

https://www.decipherzone.com/blog-detail/chat-gpt-memes
Photo by https://www.decipherzone.com/blog-detail/chat-gpt-memes

Why Prompting is an Art & Science 🎨🔬

Writing a good prompt taps into your creative side, where you carefully phrase what you want. But at the same time, the AI works with billions of parameters behind the scenes to process your input scientifically.

Prompts have two key elements

1. Parameters — These settings control how the AI responds.

  • Temperature - Controls randomness. Lower values produce more focused results; higher values make responses more creative.
  • Top-p - Adjusts the probability of selecting high-likelihood words.
  • Max length - Defines the response length.

2. Structure — The way the prompt is framed to guide the AI effectively.

Components of a Good Prompt 🏗️

A well-structured prompt consists of four essential components.

  1. Context -This provides background information to guide the AI.
  • Example: “Imagine you are a customer experience analyst at ABC Corp., a well-known company specializing in consumer products such as household items and personal care goods. Your role is to analyze customer feedback collected from various sources such as product reviews, social media comments, and customer support inquiries. The goal is to identify trends, sentiments, and areas for improvement that can enhance the customer experience and improve product offerings.”

2. Instructions - Clearly define what task the AI should perform.

  • Example: “Carefully read and analyze each customer feedback entry provided. Based on the tone, language, and context of the feedback, classify it into one of the following categories. Positive -If the feedback expresses satisfaction, praise, or appreciation for the product or service. Negative - If the feedback indicates dissatisfaction, complaints, or issues with the product or service. Neutral - If the feedback does not express strong opinions, is factual in nature, or contains both positive and negative aspects equally.”

3. Input Data - Specify the data the AI should analyze.

  • Example: “Below is an example of customer feedback extracted from our online review portal. Please analyze and classify it appropriately based on the provided instructions. Feedback: ‘The service was slow but friendly.’”

4. Output Indicator - Define the desired format of the output.

  • Example: “Provide the final sentiment classification in a single-word response that clearly indicates the overall tone of the feedback.”

🔹 Example Prompt

Imagine you are a customer experience analyst at ABC Corp., 
a well-known company specializing in consumer products such as household
items and personal care goods. Your primary responsibility is to analyze
customer feedback received through various channels, including online reviews,
emails, and support tickets. The goal is to classify the feedback based on
sentiment to help the company improve product quality and customer
satisfaction.

Task Instructions:

Carefully read and analyze each customer feedback entry provided. Based on
the tone, language, and context of the feedback, classify it into one of the
following categories.
1. Positive -If the feedback expresses satisfaction, praise,
or appreciation for the product or service.
2. Negative - If the feedback
indicates dissatisfaction, complaints, or issues with the product or service.
3. Neutral - If the feedback does not express strong opinions, is factual in
nature, or contains both positive and negative aspects equally.

Below is an example of customer feedback extracted from our online review
portal. Please analyze and classify it appropriately based on the provided
instructions.
Customer Feedback - "The bottle is made of cheap plastic."

Expected Output:
Provide the sentiment classification as a single word response.
1. Positive
2. Negative
3. Neutral

Example Output Format:
Sentiment - Negative

How to Write a Great Prompt ✍️

Want better results? Follow these golden rules with explanations.

  1. Define the Goal - Be specific about what you want to achieve.
  • Example — “Summarize this report by highlighting financial trends.”

2. Specify the Format - Indicate how the response should be structured.

  • Example — “Provide the summary in bullet points.”

3. Create a Role - Assign a persona to the AI to guide responses.

  • Example — “Act as a business analyst.”

4. Clarify the Audience - Let the AI know who will read the output.

  • Example — “Explain for a non-technical audience.”

5. Provide Context - Give all relevant details.

  • Example: “This report focuses on sales growth.”

6. Give Examples - Show the AI what you expect.

  • Example: “Previous responses used concise summaries.”

7. Specify the Style - Define the tone and manner.

  • Example: “Write in a formal business style.”

8. Set Boundaries - Restrict the scope.

  • Example: “Only focus on Q1 data.”

Common Prompting Patterns 🧩

Here are some useful patterns to help you structure your prompts:

  1. Persona Pattern
  • “Act as X and do Y.”
  • Example - “Act as a teacher and explain Newton’s laws to a 5-year-old.”

2. Audience Persona Pattern

  • “Explain X to me as if I’m Y.”
  • Example - “Explain blockchain to me as if I were a beginner.”

3. Visualization Generator Pattern

  • “Generate X for Y tool.”
  • Example - “Generate a pie chart description for Excel based on sales data.”

4. Recipe Pattern

  • “Provide a step-by-step guide.”
  • Example - “In order to do X I need to perform a,b,c. Guide me through setting up a website while filling in any missing steps and removing redundant steps.”

5. Template Pattern

  • “Fill in placeholders.”
  • Example -“Here’s a blog outline; fill in the content.”

Common Prompting Mistakes ❌

Avoid these common errors to get better AI responses.

  1. Vague Prompts - AI won’t understand unclear instructions.
  2. Biased Prompts - Avoid leading the AI to certain conclusions.
  3. Lack of Context - Provide background to avoid confusion.
  4. Insufficient Examples - Examples help AI learn your preferences.
  5. Overly Complex Prompts - Keep it simple and clear.
  6. Skipping Testing - Always test and refine your prompts.

Limitations of Generative Models ⚠️

AI isn’t perfect! Some key limitations include,

  • Hallucinations - AI can generate incorrect or misleading content.
  • Token Limits - It can only handle a certain amount of input/output.
  • Cost & Resources - Running AI models requires computational resources.

Advanced Prompting Strategies 🚀

Want to level up? Try these advanced techniques.

  1. Zero-shot Learning - Directly instructing without examples.

Ex: “Translate this text into Spanish.”

2. Few-shot Learning - Providing examples for better results.

Ex: Translate: ‘Hello’ -> ‘Hola’, ‘Thank you’ -> ‘Gracias’. Now, translate ‘Good morning.’

3. Chain of Thought Process - Asking AI to explain its reasoning step by step.

Ex: “Solve this math problem step by step - 25 + 30 / 5.”

I will write another blog with a more detailed discussion of these advanced prompt strategies.

Prompt engineering is a powerful skill that can help you unlock AI’s full potential. Whether you’re writing reports, summarizing content, or brainstorming ideas, mastering prompts can make your interactions with AI more productive and fun!

Give it a try, experiment, and refine! 🚀 Let me know how your prompting journey goes! 😊

Reference

--

--

Nipuni Premadasa
Nipuni Premadasa

Written by Nipuni Premadasa

AI/ML researcher | University of Moratuwa, Sri Lanka | Former Trainee Software Engineer at Embla Software Innovation(PVT) Ltd.

No responses yet