व्यवहार नियंत्रण के लिए सिस्टम मैसेज

Claude मॉडलों का परिचय

Nikhil Rangarajan

Data Scientist

सिस्टम मैसेज क्या हैं?

  • सपोर्ट बॉट
  • आवश्यकताएँ:
    • शिष्ट
    • संक्षिप्त
    • हर जवाब के अंत में यह लिखें: "Is there anything else I can help you with today?"

एक बॉट

Claude मॉडलों का परिचय

सिस्टम मैसेज क्या हैं?

  • सिस्टम मैसेज Claude के लिए वैश्विक व्यवहार नियम तय करते हैं
  • पूरी बातचीत पर लागू, सिर्फ एक-एक प्रतिक्रिया पर नहीं
  • टोन, सीमाएँ, आउटपुट फॉर्मेट और पर्सोना नियंत्रित करते हैं

एक बॉट पूछता हुआ "Is there anything else I can help you with today?"

Claude मॉडलों का परिचय

प्रभावी सिस्टम प्रॉम्प्ट लिखना

  • व्यवहार और सीमाओं पर स्पष्ट रहें
  • Claude की भूमिका तय करें
system_msg = "Be helpful." # Weak

system_msg = "You are a technical writer. Use active voice, under 100 words, actionable advice only." # Strong
messages = [{"role": "user", "content": "How do I improve documentation?"}] response = client.messages.create(model="claude-sonnet-4-6", max_tokens=150, system=system_msg, messages=messages)
Claude मॉडलों का परिचय

आम सिस्टम मैसेज पैटर्न

  • भूमिका-आधारित: Claude कौन हो, परिभाषित करें

$$

  • बाधा-आधारित: लंबाई या फॉर्मेट की सीमा तय करें

$$

  • टोन-आधारित: भावनात्मक शैली नियंत्रित करें

$$

  • कार्य-विशिष्ट: विशेष निर्देश दें
# Role-based
"You are a customer service rep."

# Constraint-based  
"Respond in exactly 3 bullet points,
max 50 words."

# Tone-based
"Use enthusiastic, encouraging tone."

# Task-specific
"Debug Python code. Always ask for 
error messages first."
Claude मॉडलों का परिचय

सिस्टम मैसेज का परीक्षण और सुधार

  • विविध यूज़र इनपुट से टेस्ट करें ताकि edge cases मिलें
  • अवांछित आउटपुट या व्यवहार drift पर नज़र रखें
  • ज़रूरत पड़ने पर भाषा और अधिक विशिष्ट करें
# System message causing issues
"Be concise and helpful."

# Problem: Responses too short, 
# missing context
"Provide helpful responses in 2-3 
sentences. Include relevant context 
but avoid unnecessary details."

# Test with various prompts 
Claude मॉडलों का परिचय

एडवांस्ड सिस्टम मैसेज तकनीकें

$$

  • स्पष्ट प्राथमिकताओं के साथ निर्देश जोड़ें
  • परिदृश्यों के लिए कंडीशनल लॉजिक का उपयोग करें
  • सिस्टम मैसेज में उदाहरण शामिल करें
  • few-shot प्रॉम्प्टिंग के साथ लेयर करें
system_msg = """Code reviewer. 
Priority: 1) Security 2) Performance 
3) Style
If no issues: "Code looks good" 
+ suggest improvement
Example: "Security: No issues. 
Performance: Consider caching here."
"""

messages = [{"role": "system", 
             "content": system_msg},
    {"role": "user", 
     "content": "Review: [code]"}]
Claude मॉडलों का परिचय

अभ्यास करते हैं!

Claude मॉडलों का परिचय

Preparing Video For Download...