Bytes & Pixels
← BACK

What is prompt engineering?

20 May, 2025
9 MIN READ
AI
What is prompt engineering?

📚 Understanding Whats Behind AI Chatbot

Part of a 4-post series

All posts in this series:

  1. 1.What is a Large Language Model (LLM)?
  2. 2.What is prompt engineering? (Current)
  3. 3.What is RAG?
  4. 4.Designing an AI Chatbot

In our previous article, we explored what LLMs are and how they predict the next word (token) in a sequence. We learned that transformer architecture helps LLMs understand context through self-attention mechanisms. Now that we understand how LLMs work under the hood, let's focus on something equally important: how we communicate with them.

The inputs we provide to LLMs, combined with their training data, significantly influence the quality and relevance of their responses. This is where prompt engineering becomes crucial—it's the bridge between human intent and AI understanding.

Understanding LLM Inputs: The Foundation of Good Communication

Think of an LLM as an incredibly knowledgeable conversation partner who has read millions of books, articles, and websites. Just like with any expert, the quality of your questions and instructions directly impacts the usefulness of their responses.

There are two primary ways we communicate with LLMs:

1. Prompts: Your Direct Instructions

Prompts are the questions, instructions, or conversation starters you provide directly to an AI system. They're the visible part of your interaction—what you type into ChatGPT, Claude, or any other AI interface.

Example:

  • Basic prompt: "Explain machine learning"
  • Improved prompt: "Explain machine learning to a marketing professional who wants to understand how it could help personalize customer experiences"

The difference? Context, specificity, and clear intent.

2. System Messages: The Hidden Guidelines

System messages work behind the scenes to shape how an AI responds. You typically don't see them, but they act like an instruction manual that defines the AI's behavior, tone, and approach.

System messages might instruct an AI to:

  • Respond in a specific language or dialect
  • Maintain a particular tone (professional, casual, technical)
  • Focus on certain topics or avoid others
  • Structure responses in a specific format
  • Consider the user's expertise level

For example, a system message might tell the AI: "You are a patient coding tutor. Always provide step-by-step explanations with code examples. If the user makes an error, gently correct it and explain why."

What is Prompt Engineering?

Prompt engineering is the practice of crafting inputs that maximize the effectiveness of AI systems. It's both an art and a science—combining understanding of how LLMs work with practical techniques for clear communication.

As AI becomes more integrated into our daily workflows, prompt engineering is emerging as a valuable skill across industries. It's not just for developers; marketers, writers, researchers, and professionals in every field can benefit from learning how to communicate effectively with AI.

Core Principles of Effective Prompt Engineering

1. Be Specific and Contextual

Instead of vague requests, provide clear, detailed instructions with relevant context.

Poor Example:"Write about dogs"

Better Example:"Write a 500-word article about the three most family-friendly dog breeds for households with children under 10. Include information about temperament, exercise needs, and grooming requirements."

2. Define Your Desired Output Format

Specify exactly how you want the response structured.

Poor Example:"Tell me about healthy eating"

Better Example:"Create a 7-day meal plan for heart-healthy eating. Format it as a table with columns for Day, Breakfast, Lunch, Dinner, and Snack. Include calorie estimates for each meal."

3. Provide Role and Perspective

Give the AI a specific role or perspective to adopt.

Poor Example:"Explain blockchain"

Better Example:"You are a technology consultant explaining blockchain to a small business owner who is considering accepting cryptocurrency payments. Focus on practical benefits, risks, and implementation considerations."

4. Use Examples and Constraints

Show the AI what you want through examples, and set clear boundaries.

Example:"Generate 5 social media post ideas for a sustainable fashion brand. Each post should:

  • Be under 280 characters
  • Include a relevant hashtag
  • Focus on environmental impact
  • Have an engaging question or call-to-action

Example format: 🌱 Did you know fast fashion produces 10% of global carbon emissions? Choose quality over quantity. What's your favorite sustainable brand? #SlowFashion #EcoStyle"

Advanced Prompt Engineering Techniques

Chain of Thought Prompting

Encourage the AI to show its reasoning process by asking it to "think step by step."

Example:"A company's revenue increased by 25% in Q1 and decreased by 15% in Q2. If Q1 revenue was $400,000, what was the Q2 revenue? Please show your calculation step by step."

Few-Shot Learning

Provide examples of the desired input-output pattern before asking for your specific request.

Example: "Convert these technical terms into simple explanations:

API → A way for different software programs to talk to each other Database → A digital filing cabinet that stores organized information Cloud Computing → Using someone else's computers over the internet instead of your own

Now convert: Machine Learning → ?"

Iterative Refinement

Start with a basic prompt and refine based on the results.

Initial Prompt: "Write a product description for wireless headphones"

Refined Prompt: "Write a compelling 150-word product description for premium wireless noise-canceling headphones targeting remote workers. Emphasize comfort during long calls, battery life, and sound quality. Use a professional but approachable tone and include a call-to-action."

Common Prompt Engineering Pitfalls

1. Ambiguous Instructions

  • Problem: "Make this better"
  • Solution: "Improve this email's clarity by shortening sentences, using bullet points for key information, and adding a clear call-to-action"

2. Overloading with Information

  • Problem: Including too many requirements in a single prompt
  • Solution: Break complex tasks into smaller, focused prompts

3. Assuming Context

  • Problem: Referencing "this" or "that" without clear antecedents
  • Solution: Always provide complete context within each prompt

4. Ignoring Output Limitations

  • Problem: Asking for responses that exceed the AI's capabilities or context window
  • Solution: Understand your AI system's limitations and work within them

Real-World Applications

Content Creation

"Create a LinkedIn post announcing our company's new sustainability initiative. The post should:

  • Be professional yet engaging
  • Include relevant statistics about environmental impact
  • End with a question to encourage engagement
  • Use 2-3 relevant hashtags
  • Be suitable for a B2B audience"

Code Generation

"Write a Python function that:

  • Takes a list of dictionaries as input
  • Filters dictionaries where 'status' equals 'active'
  • Sorts the results by 'created_date' in descending order
  • Returns the top 10 results
  • Includes error handling for invalid inputs
  • Has clear docstring documentation"

Data Analysis

"Analyze this sales data and provide:

  1. Three key trends you observe
  2. Potential causes for any significant changes
  3. Two actionable recommendations for improvement
  4. Present findings in executive summary format (max 200 words)

[Include your data here]"

The Future of Prompt Engineering

As AI systems become more sophisticated, prompt engineering is evolving from simple question-asking to strategic communication design. We're seeing the emergence of:

  • Prompt libraries and templates for common use cases
  • Automated prompt optimization tools
  • Multi-modal prompting combining text, images, and other inputs
  • Collaborative prompting where multiple AI systems work together

Key Takeaways

  1. Clarity is king: Specific, well-structured prompts yield better results
  2. Context matters: Provide relevant background information and constraints
  3. Iterate and improve: Refine your prompts based on the responses you receive
  4. Understand limitations: Work within your AI system's capabilities
  5. Practice makes perfect: The more you experiment, the better you'll become

Resources?

You can find more resources to deepen your understanding here: Learn AI 🎁. I'll continue updating this page with valuable learning resources as I document my journey of building an AI agent.

Ready to put these techniques into practice? Start experimenting with your AI interactions today—you'll be amazed at how much better your results become with thoughtful prompt engineering!