Key points while writting prompt for AI

 

1️⃣ Be Clear & Specific

Don’t be vague. Say exactly what you want.

❌ “Extract details from this text”
✅ “Extract vehicle registration number, make, and damage details from the text and return JSON”

2️⃣ Define the Role of the AI

Tell the AI who it should act as.

✅ “You are a police incident data extractor”
✅ “Act as a senior Python developer reviewing extraction logic”

This sets context and improves accuracy.


3️⃣ Specify the Output Format

Always mention how the response should look.

  • JSON / Table / Bullet points

  • Field names

  • Yes/No instead of true/false

e.g: Return the output in strict JSON with no extra text.

4️⃣ Add Rules & Constraints

Very important for consistency.

  • What must be included

  • What must not be done

  • Edge cases

Example:

  • Do NOT merge vehicles

  • Capture vehicles even if repeated in different sections


5️⃣ Handle Edge Cases Explicitly

AI guesses if you don’t guide it.

✅ “If registration number is missing, set it to null”
✅ “If vehicle is mentioned indirectly, still extract it”

6️⃣ Use Step-by-Step Instructions

Helps reasoning and reduces mistakes.

Example:

Step 1: Identify all vehicle mentions Step 2: Validate registration number Step 3: Create separate entries for each occurrence

7️⃣ Provide Examples (Very Powerful 🔥)

Few-shot prompting improves accuracy a lot.

  • Input text

  • Expected output

Even one example can dramatically improve results.

8️⃣ Avoid Ambiguous Language

Words like maybe, probably, relevant confuse AI.


❌ “Extract important info”
✅ “Extract registration_number, make, and vehicle_description”


9️⃣ Control Verbosity

Tell the AI how much to talk.

  • “No explanation”

  • “Only output JSON”

  • “Explain reasoning briefly”

🔟 Test & Iterate

Prompt writing is iterative.

  • Test with real edge cases

  • Refine rules

  • Tighten wording

Comments

Popular posts from this blog

what are props and how use them in react js

Book teams appointment with email notification