Temperature से क्रिएटिविटी नियंत्रित करना
आप Luna Gear में प्रोडक्ट लीड हैं और पर्यावरण-हितैषी TerraPack बैकपैक लॉन्च कर रहे हैं. टीम को A/B कैप्शन्स चाहिए: एक सधी हुई और जानकारीपूर्ण, तथा दूसरी चुलबुली और हाइप-बेस्ड.
anthropic लाइब्रेरी, client और product_info स्ट्रिंग पहले से लोड हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Claude मॉडलों का परिचय
अभ्यास निर्देश
- एकसमान और प्रोफेशनल आउटपुट के लिए
temperatureको कम रखें (0.1-0.3). - रचनात्मक और विविध आउटपुट के लिए
temperatureको ज़्यादा रखें (0.7-0.9). - संकोची और क्रिएटिव दोनों प्रतिक्रियाओं का कंटेंट प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
conservative_response = client.messages.create(
# Conservative caption with low temperature
model="claude-sonnet-4-6", temperature=____, max_tokens=150,
messages=[{"role": "user",
"content": f"Write a professional caption for this product: {product_info}"}])
creative_response = client.messages.create(
# Creative caption with high temperature
model="claude-sonnet-4-6", temperature=____, max_tokens=150,
messages=[{"role": "user",
"content": f"Write a fun, engaging caption for this product: {product_info}"}])
# Print the Conservative and Creative Responses
print("Conservative caption:", ____)
print("\nCreative caption:", ____)