DAY 87

Prompt Engineering šŸŽÆāœļøāš”

Master the four-part prompt formula — Role, Context, Format, and Constraints — that transforms vague 20% outputs into precise 90% results, and see exactly why the prompt is the musician and the model is just the instrument.

ā± 15 mins
⚔ +50 XP
Prompt Engineering šŸŽÆāœļøāš”

Day 87: Prompt Engineering — Same Model, Better Prompt, Completely Different Result

Why Should I Care?

Two people use the exact same ChatGPT. One gets vague, generic answers they cannot use. The other gets precise, structured, ready-to-use output every single time. The model is identical. The difference is the prompt. Prompt engineering is the skill of talking to AI correctly — and it is already one of the most valuable skills in every tech company, startup, and freelance market right now. You do not need to train a model to get better results. You just need a better prompt.

Core Concept

Think of the AI model as a brilliant intern. Their capability is fixed — they know everything they were trained on. A vague brief like "write something about marketing" gets you a vague, generic answer. A structured brief with Role, Context, Format, and Constraints gets you exactly what you need. Same intern. Different brief. Night-and-day output quality. The model stayed the same. The prompt changed everything. Prompt engineering is the skill of writing that structured brief every time.

How It Works

Every strong prompt has four parts. Role tells the model who it is — a Python tutor, a data analyst, a marketing expert. Context gives the model the situation — who the audience is, what the goal is, what background knowledge to assume. Format tells the model how to structure the output — bullet points, a table, a single sentence, a numbered list. Constraints are the hard limits — under 15 words each, no jargon, end with a question, only use cricket analogies. All four together turn a 20% vague response into a 90% precise and usable one.


Prompt Anatomy — four parts every strong prompt needs:

Role        : Who the AI is
              "You are a Python tutor for Indian CS students."

Context     : The situation and audience
              "Explaining to beginners who know basic for loops."

Format      : How the output should be structured
              "Explain in 3 bullet points."

Constraints : Hard limits on the output
              "Keep each point under 15 words. End with a question."

Full strong prompt example:
  "You are a Python tutor for Indian CS students.
   Explain list comprehensions in 3 bullet points.
   Use a cricket scoring analogy.
   Keep each point under 15 words."

Weak prompt:  "Tell me about list comprehensions."
Result:       Vague, generic, long -- 20% quality

Strong prompt: Role + Context + Format + Constraints
Result:        Precise, structured, usable -- 90% quality

The model stayed the same. The prompt changed everything.

Real World Connection

At companies like Swiggy, Zomato, and Flipkart, data teams write prompts to extract insights from customer reviews, generate product descriptions, and summarise support tickets automatically. A vague prompt wastes compute and produces useless output. A structured prompt with all four parts produces output that goes directly into the product. Freelancers who know prompt engineering charge more for the same work because they get better results faster. This is not a soft skill — it is an engineering discipline that directly affects the quality of every AI system you build.

Examples


from transformers import pipeline

generator = pipeline("text-generation",
                     model="gpt2",
                     max_new_tokens=40)

# Weak prompt -- no role, no format, no constraint
weak_prompt = "Tell me about databases."

# Strong prompt -- format + analogy + length defined
strong_prompt = ("In one sentence, explain what a database is "
                 "using a school almira as an analogy.")

print("— Weak Prompt —")
print(generator(weak_prompt)[0]["generated_text"])

print("\n— Strong Prompt —")
print(generator(strong_prompt)[0]["generated_text"])

# OUTPUT:
# — Weak Prompt —
# Databases are used in many systems and
# applications for storing information...
# (vague, generic, not useful)
#
# — Strong Prompt —
# A database is like a steel almira — every
# drawer is a table, every file is a row,
# organized and instantly retrievable.
# (precise, structured, immediately usable)
#
# Same model. One prompt change.
# Night-and-day output quality.

Common Mistakes

Two mistakes that beginners make with prompt engineering that silently cap the quality of everything they produce. First, writing one-line vague prompts for complex tasks. Second, assuming the same prompt works equally well across all AI models.


-- MISTAKE 1: One-line vague prompts for complex tasks --

WRONG:
  "Explain AI."
  Result: generic, padded, not useful for anyone specific

CORRECT:
  Include role + context + format + constraints
  in every prompt that needs quality output.

NOTE: "Vague input = vague output —
       model fills gaps with the most average response possible."
RULE: Role + Context + Format + Constraints = a prompt that works.


-- MISTAKE 2: Assuming the same prompt works for every model --

WRONG:
  Copy the same prompt from ChatGPT to LLaMA or Gemini
  and expect identical results.

CORRECT:
  GPT-4, Claude, Gemini, LLaMA all respond differently.
  Always test and tune per model.

NOTE: "Each model has different training, tone defaults,
       and instruction-following behaviour."
RULE: Test your prompt on the specific model you are deploying to.
      Never assume cross-model compatibility.

Mini Challenge

Mini Challenge

Open ChatGPT or Claude right now and run this experiment. First send a weak prompt: "Explain machine learning." Copy the output. Then send a strong prompt using all four parts: "You are a data science teacher for 10th standard students in India. Explain machine learning in exactly 3 bullet points. Use a cricket match as your analogy. Keep each point under 20 words." Compare both outputs side by side. The model did not change. Your prompt did. Screenshot both and see the difference yourself.

Quick Quiz

Q1: What are the four parts of a strong prompt? A1: Role, Context, Format, and Constraints — all four together turn vague output into precise and usable results. Q2: If two people get very different outputs from the same AI model, what is the most likely cause? A2: The quality of their prompts — the model is identical, but a structured prompt with all four parts produces far better output than a vague one-line prompt. Q3: Why does the same prompt sometimes give different results on ChatGPT versus Claude or Gemini? A3: Each model has different training data, tone defaults, and instruction-following behaviour — prompts must always be tested and tuned for the specific model being used.

Bonus Knowledge

There are advanced prompt engineering techniques beyond the four-part formula. Chain-of-thought prompting asks the model to think step by step before answering — this dramatically improves accuracy on reasoning tasks. Few-shot prompting gives the model two or three examples of what good output looks like before asking for the real answer — the model learns the pattern from your examples. System prompts in the API let you set a permanent role and behaviour for the model that applies to every message in the conversation. Companies like OpenAI, Anthropic, and Google pay dedicated prompt engineers to optimise these techniques for their products. The four-part formula you learned today is the foundation all of those advanced techniques build on.

Key Takeaways

Key Takeaways

  • Every strong prompt has four parts: Role, Context, Format, and Constraints — all four together produce 90% quality output.
  • The model stays the same — the prompt changes everything. Vague input always produces vague output.
  • Role tells the AI who it is. Context gives the situation. Format structures the output. Constraints set the hard limits.
  • Never write one-line vague prompts for complex tasks — the model fills gaps with the most average response possible.
  • Different models — GPT-4, Claude, Gemini, LLaMA — respond differently to the same prompt. Always test per model.
  • The prompt is the musician. The model is the instrument. Learn to write prompts and the model obeys.

← Previous Lesson