Yashotantra Academy logo
level 1
Curious · 0 XP
streak
0d
perfect
0
badges
0

100 XP to Apprentice

Prompting · medium

7. Prompt engineering patterns that actually work

Role, task, constraints, examples, and output contract.

1 min read3 questionsup to 50 XPtopic 7/12

Read in another language

AI translates the explanation and quiz text while preserving code and answer scoring.

A reliable prompt is a small specification. The pattern that survives production:

1. Role and objective — who the model is and what success means. 2. Context — only the evidence needed, clearly delimited. 3. Constraints — length, tone, banned behaviours, what to do when unsure. 4. Few-shot examples — 2-5 examples pin down format far better than adjectives. 5. Output contract — an exact schema, ideally enforced by structured output.

text
You are a support triage assistant.
Classify the ticket using ONLY the evidence between <ticket> tags.
If the category is unclear, return "unknown" — never guess.

Return JSON: {"category": "...", "severity": 1|2|3, "reason": "<=20 words"}

<ticket>
{{ticket_text}}
</ticket>

Techniques worth knowing: chain-of-thought ("think step by step") for reasoning-light models, self-consistency (sample k answers, take the majority), and decomposition (split one hard prompt into several small verifiable ones).

Gotcha: with modern reasoning models, verbose "think step by step" scaffolding can *hurt* — they already reason internally. Prompt for the contract, not the process.

How to study this topic

  1. 1. Read the explanation once end to end, skipping the code.
  2. 2. Re-read the code snippets and say out loud what each line does.
  3. 3. Answer the quiz without scrolling back — that is the real check.
  4. 4. Read every explanation, even for the answers you got right.

Scoring

  • · Up to 30 XP from quiz accuracy.
  • · +15 XP for a perfect first attempt.
  • · +5 XP while a 3-day streak is running.
  • · 75% or higher marks the topic complete.

Check your understanding

  1. 1. What most reliably fixes inconsistent output formatting?

  2. 2. What is self-consistency decoding?

  3. 3. What should a prompt specify for uncertain cases?

Badges

First light
Pass your first topic
Sharp shooter
3 perfect first-try quizzes
On a roll
Study 3 days in a row
Week warrior
Study 7 days in a row
Grinder
Earn 500 XP
Deep diver
Earn 1500 XP