新しいコンテンツの生成

Claude モデル入門

Nikhil Rangarajan

Data Scientist

クリエイティブなコンテンツ生成

  • テキスト変換を超えた独自コンテンツの生成
    • ストーリー

開いた本

Claude モデル入門

クリエイティブなコンテンツ生成

  • テキスト変換を超えた独自コンテンツの生成
    • ストーリー
    • マーケティングコピー

開いた本とマーケティングコピーを表示するウェブページ

Claude モデル入門

クリエイティブなコンテンツ生成

  • テキスト変換を超えた独自コンテンツの生成
    • ストーリー
    • マーケティングコピー
    • コード

開いた本、マーケティング文とコードスニペットを表示するウェブページ

Claude モデル入門

クリエイティブなコンテンツ生成

  • テキスト変換を超えた独自コンテンツの生成
    • ストーリー
    • マーケティングコピー
    • コード
    • メール

開いた本、マーケティングコピーを表示したウェブページ、コードスニペット、メール

Claude モデル入門

クリエイティブなコンテンツ生成

  • テキスト変換を超えた独自コンテンツの生成
    • ストーリー
    • マーケティングコピー
    • コード
    • メール
    • スクリプト

開いた本、マーケティングコピーを表示したウェブページ、コードスニペット、メール、スクリプト

Claude モデル入門

効果的な生成プロンプト

$$

  • 具体性
  • 曖昧なプロンプト: ありきたりな結果
  • 具体的なプロンプト: 的を得た内容
# 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."""
Claude モデル入門

効果的な生成プロンプト

$$

  • Claude の最も一般的な利用: コード
  • 具体的なプロンプトで、的確なコードを出力
    • プログラミング言語
    • 特定の機能
    • エラー処理の要件
    • 期待される出力
# 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."""
Claude モデル入門

Temperature 設定

  • Temperature 範囲: 0.0(予測可能)から 1.0(非常に創造的)まで
    • 低(0.1~0.3): 一貫性が保たれ、予測可能な出力
    • 中(0.4~0.7): バランスの取れた創造性と一貫性
    • 高(0.8~1.0): 創造性を最大限発揮、出力は予測しにくい場合も

Temperature パラメータ:0 ~ 1

Claude モデル入門

モデル呼び出しにおける Temperature

# Conservative generation
response1 = client.messages.create(
    model="claude-sonnet-4-6",
    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)
Claude モデル入門

モデル呼び出しにおける Temperature

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...
Claude モデル入門

top_p パラメータの使用

$$

  • top_p(核サンプリング): Temperature の 代替えとして創造性を管理
  • 一般的な値: 0.1(集中)から 0.9(多様)
  • 組み合わせて管理: Temperature と top_p を併用して、より的確に制御

$$

client.messages.create(
model="claude-sonnet-4-6",
temperature=0.7,
top_p=0.3, #Likely words
messages=[{"role":"user", 
           "content":prompt}])
Claude モデル入門

Claude の安全機能

$$

  • 📝 コンテンツの強み: ライティング、分析、コーディング、創造的なタスク
  • 🚫 組み込みの安全機能: 有害なコンテンツを拒否し、倫理指針を維持
  • ✅ ベストプラクティス: 明確なプロンプト、パラメータを試行、出力を確認
Claude モデル入門

練習しましょう!

Claude モデル入門

Preparing Video For Download...