|8. Prompt Engineering
Chapter 8Artificial Intelligence~1 min read

Prompt Engineering

AI ला चांगले Results मिळवा

Prompt Engineering म्हणजे AI models ला चांगले, accurate results मिळवण्यासाठी prompts effectively लिहणे. Same LLM, different prompt — results मध्ये रात-दिन फरक पडतो. हे एक new skill आहे जे developers ला खूप उपयोगी आहे.

Basic Prompting Principles

Bad vs Good prompts

text
❌ Bad: "Python code लिहा"
✅ Good: "Python मध्ये एक function लिहा जो list of numbers घेतो
         आणि सगळ्यात मोठा prime number return करतो.
         Edge cases handle करा (empty list, no primes).
         Type hints आणि docstring add करा."

❌ Bad: "Explain networking"
✅ Good: "मला 10th standard student साठी
         HTTP vs HTTPS चा फरक explain करा.
         Real-life analogy वापरा, maximum 200 words."

Principles:
1. Specific असा — vague prompts = vague answers
2. Context द्या — कोण आहात, काय हवे, format काय
3. Output format सांगा — bullet points, JSON, code
4. Constraints सांगा — word limit, language, audience

Advanced Techniques

  • Few-Shot Prompting: 2-3 examples दाखवा, pattern follow करतो
  • Chain of Thought (CoT): "Step by step think करा" — complex reasoning improve होतो
  • Role Prompting: "तुम्ही एक senior Python developer आहात..." — specific persona
  • System Prompt: AI चं behavior globally set करणे (API मध्ये)
  • RAG (Retrieval Augmented Generation): external knowledge documents feed करणे

Chain of Thought example

text
❌ Without CoT:
Prompt: "23 × 47 = ?"
Answer: "1071" (चुकीचे असू शकते)

✅ With CoT:
Prompt: "23 × 47 = ? Step by step calculate करा."
Answer: "23 × 47 = 23 × (40 + 7)
         = 23 × 40 + 23 × 7
         = 920 + 161
         = 1081"

Same for coding:
"या code मधला bug शोधा. आधी code explain करा,
मग potential issues list करा, मग solution द्या."

Structured Output prompt

text
Prompt:
"खालील product review चे sentiment analyze करा
आणि JSON format मध्ये output द्या:

Review: 'Camera excellent आहे पण battery life खराब आहे.'

Output format:
{
  "overall_sentiment": "positive/negative/mixed",
  "aspects": [
    {"feature": "...", "sentiment": "...", "score": 1-5}
  ],
  "summary": "..."
}"

Key Points — लक्षात ठेवा

  • Specific prompts = better outputs
  • Context + Role + Format + Constraints = great prompts
  • Chain of Thought: "step by step" — reasoning improve
  • Few-shot: examples दाखवा — pattern follow
  • System prompt: AI चं overall behavior set करतो
0/11 chapters पूर्ण