AI Prompt Engineering · レッスン

曖昧なプロンプトと具体的なプロンプトの比較

具体性によって生じる大きな違いを、左右に並べた例で確認します。

レッスン 4/413 ステップ

「曖昧なプロンプトと具体的なプロンプトの比較」はCoddyKit上の無料AI Prompt Engineeringレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはAI Prompt Engineering学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 AI Prompt Engineeringコースには全4レッスンが含まれています。

並べて比較する方法

プロンプトの質を身につける最も速い方法は、具体的な書き直しの前後を並べて学び、それぞれの改善がなぜ効果的なのかを分析することです。

このレッスンでは、5つの曖昧なプロンプトと、それを具体化した書き直しを確認します。それぞれの組み合わせについて、行われた変更の内容と、各改善がモデルをより良い出力へ導く仕組みを特定します。

組み合わせ1:ブログ記事

曖昧:「リモートワークについてブログ記事を書いてください。」

具体的:「中堅ソフトウェア開発者を対象に、600語のブログ記事を書いてください。タイトルは『生産性を台無しにしたリモートワークの3つの習慣(そして今の私の対策)』とします。一人称の語り口で、会話調のトーンにしてください。構成:導入の段落1つ、H2見出し付きの3セクション、無料テンプレートのダウンロードを促す最後のCTA 1つ。」

効果的な理由:文字数、タイトル(ひいては記事の切り口)、対象読者、語り口、トーン、構成、具体的な結末の要素を追加しています。偶然に委ねる要素がありません。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=800,
    messages=[{
        'role': 'user',
        'content': (
            'Write a 600-word blog post titled '
            '"The 3 Remote Work Habits That Killed My Productivity (And What I Do Now)" '
            'for an audience of mid-level software developers. '
            'First-person voice, conversational tone. '
            'Structure: 1-paragraph intro, 3 H2 sections (one per habit), '
            '1 closing paragraph with a CTA to download a free productivity template.'
        )
    }]
)
print(response.content[0].text[:400], '...')

組み合わせ2:コードレビュー

曖昧:「私のコードをレビューしてください。」

具体的:「次のPython関数をレビューしてください。次の点だけに注目してください:1)正しさに関するバグ、2)処理されていないエッジケース。スタイル、命名、フォーマットについてはコメントしないでください。出力形式:問題の番号付きリスト。各項目には、問題の説明(1文)、該当する行、推奨される修正(コードスニペット)を含めてください。」

効果的な理由:レビューの範囲(正しさとエッジケース)を定義し、対象外の要素(スタイルと命名)を明示的に除外し、各指摘に3つの項目を含める正確な出力構造を指定しています。

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

code = (
    'def get_user(users, user_id):\n'
    '    for user in users:\n'
    '        if user["id"] == user_id:\n'
    '            return user["name"]\n'
    '    return users[0]["name"]\n'
)

response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'Review the following Python function.\n'
            'Focus ONLY on: 1) correctness bugs, 2) unhandled edge cases.\n'
            'Do NOT comment on style, naming conventions, or formatting.\n'
            'Output format: numbered list. Each item: issue (1 sentence), '
            'affected line, suggested fix as a code snippet.\n\n'
            + code
        )
    }]
)
print(response.choices[0].message.content)

組み合わせ3:メールの件名

曖昧:「ニュースレターのメール件名を書いてください。」

具体的:「データサイエンティスト向けのPythonに関する週刊ニュースレターのメール件名を10個書いてください。各件名は50文字未満とし、開封率を高めるフック(好奇心のギャップ、番号付きリスト、意外な主張のいずれか)を含め、FREEやURGENTのようなスパム判定のトリガーとなる単語は避けてください。フックの種類を角括弧内に示した番号付きリストとして出力してください。」

効果的な理由:個数、長さの制約、フックの要件、除外リスト、ラベル付きの出力形式を指定し、曖昧な創作作業をルールベースの生成タスクに変えています。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=400,
    messages=[{
        'role': 'user',
        'content': (
            'Write 10 email subject lines for a weekly newsletter '
            'about Python tips for data scientists. '
            'Requirements:\n'
            '- Each under 50 characters\n'
            '- Must use one of these hooks: [CURIOSITY GAP], [NUMBER], or [SURPRISING CLAIM]\n'
            '- No spam words: FREE, URGENT, ACT NOW, LIMITED TIME\n'
            '- Output as numbered list with hook type in brackets at the end of each line'
        )
    }]
)
print(response.content[0].text)

組み合わせ4:会議の要約

曖昧:「この会議の議事録を要約してください。」

具体的:「次の形式でこの会議の議事録を要約してください:1)会議の目的(1文)、2)主な決定事項(箇条書き、最大5項目)、3)アクションアイテム(Task、Owner、Deadlineの列を持つ表)、4)未解決の質問(番号付きリスト)。項目に必要な情報がない場合は、N/Aと書いてください。意見は含めず、事実と約束事項だけにしてください。」

効果的な理由:正確なテンプレートを示し、セクションごとの上限を指定し、表のスキーマを定義し、情報がない場合の代替表記を設定し、トーンの制約(事実のみ)を加えています。

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

transcript = (
    'John: We need to decide on the launch date. '
    'Sarah: I think Q3 works. We need the API done first. '
    'John: Agreed. Sarah, can you own the API? '
    'Sarah: Yes, I can have it by July 15th. '
    'John: Great. Who handles marketing? '
    'Mike: I will, but I need the feature list first. '
    'John: We still need to confirm pricing — tabled for next week.'
)

response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'Summarize this meeting transcript in this exact format:\n'
            '1. Meeting Purpose: (1 sentence)\n'
            '2. Key Decisions: (bullet list, max 5)\n'
            '3. Action Items: (markdown table: Task | Owner | Deadline)\n'
            '4. Open Questions: (numbered list)\n'
            'Missing info: write N/A. Facts only, no opinions.\n\n'
            'Transcript:\n' + transcript
        )
    }]
)
print(response.choices[0].message.content)

組み合わせ5:説明

曖昧:「機械学習を説明してください。」

具体的:「統計は理解しているものの、コードを書いたことがない医療系企業のプロダクトマネージャー向けに、機械学習を3段落で説明してください。第1段落:機械学習とは何か、従来のプログラミングとどう異なるか。第2段落:実際の医療分野の例(診断または創薬)。第3段落:避けるべき一般的な誤解を1つ。全体で最大200語。」

効果的な理由:構成(テーマを割り当てた3段落)、対象読者(具体的な役割、分野、背景知識)、段落ごとの内容要件、全体の文字数制限を定義しています。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=350,
    messages=[{
        'role': 'user',
        'content': (
            'Explain machine learning in exactly 3 paragraphs. '
            'Audience: a product manager at a healthcare company who understands statistics '
            'but has never written code.\n'
            'Paragraph 1: what ML is and how it differs from traditional programming.\n'
            'Paragraph 2: a specific real-world healthcare example (diagnosis or drug discovery).\n'
            'Paragraph 3: one common misconception non-technical people have about ML.\n'
            'Max 200 words total. No bullet points — flowing prose only.'
        )
    }]
)
print(response.content[0].text)

効果的な書き直しの構造

5つの組み合わせを通して見ると、効果的な書き直しにはすべて共通する点があります:

  1. 曖昧な動詞を置き換える(「書く」「レビューする」「説明する」を構造化されたタスクに置き換える)
  2. 出力形式を明示する(リスト、表、内容を割り当てた段落など)
  3. 測定可能な制約を追加する(文字数、項目数、文字数上限)
  4. 対象読者を指定する(役割+背景+文脈)
  5. 少なくとも1つの除外ルールを追加する(含めないもの)
# Pattern extractor: identify improvements between two prompts
def analyze_improvement(vague, specific):
    improvements = []
    words = specific.lower()
    if any(str(n) in words for n in range(10, 10000)):
        improvements.append('Quantitative constraint added')
    if 'do not' in words or 'exclude' in words or 'avoid' in words or 'no ' in words:
        improvements.append('Negative constraint added')
    if 'audience' in words or 'for a' in words or 'targeting' in words:
        improvements.append('Audience specified')
    if 'format:' in words or 'table' in words or 'list' in words or 'paragraph' in words:
        improvements.append('Output format defined')
    if 'example' in words or 'such as' in words or 'like:' in words:
        improvements.append('Example provided')
    print('Improvements detected:')
    for i in improvements:
        print(f'  + {i}')

vague = 'Write a blog post about remote work.'
specific = 'Write a 600-word blog post for mid-level developers with 3 H2 sections and a closing CTA. No bullet points. Avoid generic productivity advice.'
analyze_improvement(vague, specific)

1つの要素だけを追加するとどうなるか

改善を1つ加えるだけでも効果はありますが、具体化が不十分だと大きな空白が残ります。比較してみましょう:

  • 「リモートワークについてブログ記事を書いてください」— 制約なし
  • 「リモートワークについて600語のブログ記事を書いてください」— 長さだけを指定しており、切り口、対象読者、構成はまだ曖昧
  • 「開発者向けに、会話調のトーンでリモートワークについて600語のブログ記事を書いてください」— 長さ+対象読者+トーンを指定しているが、構成、CTA、見出しのスタイルはまだ曖昧

指定しない要素は、一つひとつが運任せになります。情報がある要素は、できるだけ追加してください。

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

# Progressively more specific prompts
prompts = [
    'Write about Python.',
    'Write a 200-word article about Python.',
    'Write a 200-word article about Python for beginners who know no programming.',
    (
        'Write a 200-word article about Python for beginners who know no programming. '
        'Start with a real-world analogy. Use 3 short paragraphs. '
        'End with one actionable first step they can take today.'
    )
]

for i, p in enumerate(prompts, 1):
    print(f'Prompt {i} ({len(p)} chars): {p[:80]}...' if len(p) > 80 else f'Prompt {i}: {p}')
    print()

比較ペアの手法を実践で使う

比較ペアの手法は、強力なデバッグツールです。悪い出力が得られたときは、次の手順を実行してください:

  1. 悪い出力を生んだ曖昧なプロンプトを保存する
  2. 問題の原因となった要素を1つ特定する
  3. その要素だけを対象に、具体的な書き直しを作成する
  4. 両方のプロンプトを実行して、出力を比較する
  5. まだ修正が必要な点を特定し、次の制約を追加する

この科学的なアプローチによって、自分の利用場面でどの制約が最も重要なのかをすばやく学べます。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

def compare_prompts(prompt_a, prompt_b, label_a='A', label_b='B'):
    client_ref = anthropic.Anthropic(api_key='sk-ant-your-key-here')
    for label, prompt in [(label_a, prompt_a), (label_b, prompt_b)]:
        response = client_ref.messages.create(
            model='claude-opus-4-5',
            max_tokens=150,
            messages=[{'role': 'user', 'content': prompt}]
        )
        print(f'=== {label} ===')
        print(prompt)
        print('--- OUTPUT ---')
        print(response.content[0].text)
        print()

compare_prompts(
    prompt_a='Explain APIs.',
    prompt_b='Explain APIs in 3 sentences for a non-technical startup founder. Analogy required.',
    label_a='VAGUE',
    label_b='SPECIFIC'
)

2分間のプロンプト監査

重要なプロンプトを送信する前に、この2分間の監査を行ってください。各質問の答えが「いいえ」なら、不足している情報を追加します:

  • 形式が明示されていますか?(リスト/表/段落/JSON)
  • 長さが指定されていますか?(文字数/項目数)
  • 対象読者が説明されていますか?(役割+背景)
  • 目的が明確ですか?(出力を何に使うのか)
  • 除外指定が少なくとも1つありますか?(含めないもの)
  • 例またはテンプレートがありますか?(スタイルが重要な場合)
def two_minute_audit(prompt):
    score = 0
    checks = {
        'Format specified': any(w in prompt.lower() for w in
            ['list', 'table', 'paragraph', 'json', 'bullet', 'sentence', 'word']),
        'Length given': any(c.isdigit() for c in prompt),
        'Audience named': any(w in prompt.lower() for w in
            ['for a', 'audience', 'targeting', 'developer', 'manager', 'beginner']),
        'Exclusion added': any(w in prompt.lower() for w in
            ['do not', 'avoid', 'exclude', 'no ', 'without', 'never']),
        'Goal stated': any(w in prompt.lower() for w in
            ['goal', 'purpose', 'so that', 'in order to', 'will be used']),
    }
    print('Prompt Audit:')
    for check, passed in checks.items():
        icon = 'PASS' if passed else 'FAIL'
        print(f'  [{icon}] {check}')
        if passed: score += 1
    print(f'Score: {score}/{len(checks)}')

two_minute_audit(
    'Write 5 bullet-point suggestions for improving user onboarding '
    'for a B2B SaaS app targeting first-time non-technical users. '
    'Avoid suggestions that require engineering work. Each bullet: max 25 words.'
)

プロンプトライブラリを構築する

優れた出力を生み出すプロンプトを書くたびに、それを保存してください。タスクの種類ごとに整理して、自分専用のプロンプトライブラリを構築しましょう。

優れたプロンプトライブラリの項目には、次のものが含まれます:

  • [AUDIENCE]や[WORD_COUNT]のようなプレースホルダーを含むプロンプトテンプレート
  • そのテンプレートが想定する利用場面
  • 使用したモデルと設定
  • 効果的である理由についてのメモ

時間が経つにつれて、ライブラリはAIによる生産性向上のための最も価値ある資産になります。

# Example prompt library entry
prompt_library = {
    'meeting_summary': {
        'template': (
            'Summarize the following meeting transcript in this format:\n'
            '1. Purpose: (1 sentence)\n'
            '2. Decisions: (bullet list, max 5)\n'
            '3. Action Items: (table: Task | Owner | Deadline)\n'
            '4. Open Questions: (numbered list)\n'
            'Missing info: N/A. Facts only.\n\nTranscript:\n[TRANSCRIPT]'
        ),
        'use_case': 'Post-meeting automation for Slack or Notion',
        'model': 'claude-opus-4-5',
        'temperature': 0,
        'notes': 'Works best with verbatim transcripts, not paraphrased notes'
    }
}

# Use the template
def run_meeting_summary(transcript):
    template = prompt_library['meeting_summary']['template']
    return template.replace('[TRANSCRIPT]', transcript)

print(run_meeting_summary('Alice: We decided to ship v2 next Friday...')[:200])

理解度チェック

このレッスンの5つの比較ペアを見ると、5つすべての例でプロンプトの質を最も一貫して向上させた単一の変更は何でしょうか?

曖昧なプロンプトと具体的なプロンプト — まとめ

5つの比較ペアから、プロンプトの書き直しを効果的にする要素には一貫したパターンがあることが分かります:

  • 出力構造は投資対効果が最も高い改善です。必ず定義してください
  • 文字数/項目数を指定すると、長さについてのやり取りを完全になくせます
  • 対象読者の説明によって、語彙と深さが自動的に調整されます
  • 除外ルールによって、ありがちな一般的な内容を防げます
  • 部分的な具体化ではまだ空白が残ります。指定していない要素はすべて推測になります
  • プロンプトライブラリによって、うまくいったテンプレートを繰り返し使えるように保存できます
無料で開始

AI チューターと学ぶ AI Prompt Engineering — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
53
レッスン
199

よくある質問

「曖昧なプロンプトと具体的なプロンプトの比較」レッスンは無料ですか?

はい。「曖昧なプロンプトと具体的なプロンプトの比較」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、AI Prompt Engineeringコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 AI Prompt Engineeringコースには全4レッスンが含まれています。

「曖昧なプロンプトと具体的なプロンプトの比較」で何を学びますか?

具体性によって生じる大きな違いを、左右に並べた例で確認します。 ブラウザで直接実行するハンズオンコードでAI Prompt Engineeringを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

AI Prompt Engineeringを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのAI Prompt Engineeringは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「曖昧なプロンプトと具体的なプロンプトの比較」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このAI Prompt Engineeringレッスンでコードを書いて実行できますか?

はい。すべてのAI Prompt Engineeringレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 具体性が重要な理由
  2. プロンプトから曖昧さを取り除く
  3. 具体的な詳細を加える
  4. 曖昧なプロンプトと具体的なプロンプトの比較
← AI Prompt Engineeringに戻る