Generating new content

Introduction to Claude Models

Nikhil Rangarajan

Data Scientist

Creative content generation

  • Beyond text transformation to original creation
    • Stories

An open book

Introduction to Claude Models

Creative content generation

  • Beyond text transformation to original creation
    • Stories
    • Marketing copy

An open book and a webpage showing marketing copy

Introduction to Claude Models

Creative content generation

  • Beyond text transformation to original creation
    • Stories
    • Marketing copy
    • Code

An open book, a webpage showing marketing copy and a code snippet

Introduction to Claude Models

Creative content generation

  • Beyond text transformation to original creation
    • Stories
    • Marketing copy
    • Code
    • Emails

An open book, a webpage showing marketing copy, a code snippet and an email

Introduction to Claude Models

Creative content generation

  • Beyond text transformation to original creation
    • Stories
    • Marketing copy
    • Code
    • Emails
    • Scripts

An open book, a webpage showing marketing copy, a code snippet, an email, and a script

Introduction to Claude Models

Crafting effective generation prompts

$$

  • Specificity
  • Vague prompt: Generic results
  • Detailed prompt: Targeted content
# Vague prompt
prompt = "Write a product description"

# Specific prompt prompt = """Write a 150-word product description for a wireless bluetooth speaker targeting college students. Use an energetic, casual tone and highlight portability, battery life, and sound quality."""
Introduction to Claude Models

Crafting effective generation prompts

$$

  • Most common Claude use case: code
  • Specific prompts drive targeted code outputs
    • Programming language
    • Specific functionality
    • Error handling requirements
    • Expected outputs
# Vague prompt
prompt = "Write some code"

# Specific prompt  
prompt = """Write a Python function 
that validates email addresses 
using regex. 
Include error handling for invalid 
inputs and return both boolean result 
and descriptive error message."""
Introduction to Claude Models

Understanding temperature

  • Temperature range: 0.0 (deterministic) to 1.0 (highly creative)
    • Low temperature (0.1-0.3): Consistent, predictable outputs
    • Medium temperature (0.4-0.7): Balanced creativity and coherence
    • High temperature (0.8-1.0): Maximum creativity, less predictable

Temperature ranging from 0 to 1

Introduction to Claude Models

Temperature in the model call

# Conservative generation
response1 = client.messages.create(
    model="claude-sonnet-4-20250514",
    temperature=0.2,
    messages=[{"role": "user", "content": prompt}])

# Creative generation response2 = client.messages.create( temperature=0.8, messages=[{"role": "user", "content": prompt}])
print("Temperature 0.2 Response (Conservative)") print(response1.content[0].text)
print("Temperature 0.8 Response (Creative)") print(response2.content[0].text)
Introduction to Claude Models

Temperature in the model call

Temperature 0.2 Response (Conservative)
A rainbow is an optical phenomenon that occurs when sunlight and rain are present 
simultaneously. It forms when white light from the sun passes through water 
droplets in the atmosphere, causing the light to refract, reflect, and disperse 
into its component colors...

Temperature 0.8 Response (Creative)
Ah, rainbows! Those magical bridges painted across stormy skies that never fail 
to make us pause and wonder. Picture this: millions of tiny water droplets hanging 
in the air after a rainfall, each one acting like a miniature crystal ball. When 
sunlight hits these droplets, something absolutely enchanting happens...
Introduction to Claude Models

Using top_p parameter

$$

  • top_p (nucleus sampling): Alternative to temperature for creativity control
  • Typical values: 0.1 (focused) to 0.9 (diverse)
  • Combined use: Can use temperature and top_p together for precise control

$$

client.messages.create(
model="claude-sonnet-4-20250514",
temperature=0.7,
top_p=0.3, #Likely words
messages=[{"role":"user", 
           "content":prompt}])
Introduction to Claude Models

Claude's safety features

$$

  • 📝 Content strengths: Writing, analysis, coding, creative tasks
  • 🚫 Built-in safety: Refuses harmful content, maintains ethical guidelines
  • ✅ Best practices: Clear prompts, experiment with parameters, review outputs
Introduction to Claude Models

Let's practice!

Introduction to Claude Models

Preparing Video For Download...