screenager.dev

Prompt Engineering: The Art of Sweet-Talking AI Models

Tejas Mahajan
Tejas Mahajan
@the_screenager

Ever tried asking ChatGPT something and got a completely bizarre answer? Or maybe you've spent hours trying to get that perfect response? Yeah, been there, done that. Let me spill the tea on how to become a prompt engineering wizard!

Prompt Engineering Banner

The "Duh" Moment 🤯

So here's the thing - AI models are like that smart friend who takes everything way too literally. You know the type. The one who, when you say "grab a bite," asks "bite of what?"

I learned this the hard way when I asked ChatGPT to "write code." Just that. "Write code." And boy, did it write code... for printing "Hello World" in COBOL. In 2024. Thanks, but no thanks!

The Secret Sauce 🥫

Here's what actually works (tested on my countless late-night AI adventures):

1. Be That Annoying Detail Person

Instead of: "Write a function" Try: "Write a Python function that takes two integers and returns their sum, with type hints and docstring"

The difference? Night and day, folks!

2. Set the Stage 🎭

Before diving in, tell the AI who it's supposed to be. It's like method acting, but for robots!

You are a senior Python developer with 10 years of experience in writing clean, maintainable code.
Your task is to review my code and suggest improvements...

(Trust me, it works way better than "fix my code pls")

3. Show, Don't Tell 👀

Want the AI to write in a specific style? Give it an example!

Bad: "Write in a funny style" Good: "Write like this: 'Hey there, code wizards! Ready to turn some coffee into code? Let's dive into this crazy world of loops and variables!'"

Epic Fails and Wins 🎮

Let me share my favorite prompt engineering disaster:

Me: "Write better code" AI: proceeds to write a philosophical essay about what makes code "better"

After learning my lesson:

Me: "You are a Python expert. Review this code focusing on performance optimization. Identify bottlenecks, suggest improvements, and provide code examples. Format your response with emojis for readability."

AI: Actually useful response with performance tips, code samples, and cute emojis

The Real MVP Tips 🏆

  1. Be Specific AF: "Write a blog post" vs "Write a 500-word blog post about prompt engineering, using casual language, metaphors, and including code examples"

  2. Chain That Thought: Make the AI show its work!

    Let's solve this step by step:
    1. First, we'll...
    2. Then...
    
  3. Test Drive: Start small, iterate, and refine. It's like tuning a guitar - you gotta find that sweet spot!

Wrapping Up 🎁

Prompt engineering isn't rocket science (though you could probably use it FOR rocket science 🚀). It's about being clear, specific, and sometimes a bit creative with how you talk to AI.

Remember: These AI models are like super-smart toddlers - they know a lot, but you gotta be really clear about what you want!