具体的な詳細を加える
AI の出力の方向性を定める数字、名前、形式、例について学びます。
「具体的な詳細を加える」はCoddyKit上の無料AI Prompt Engineeringレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはAI Prompt Engineering学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 AI Prompt Engineeringコースには全4レッスンが含まれています。
具体的な情報はアンカーになる
具体的な情報とは、特定可能で、測定・検証できる情報です。具体的な情報は、モデルの出力を一般的な解釈ではなく、実際の状況に固定します。
アンカーがなければ、モデルは想像上の平均的なユーザー向けに出力を生成します。アンカーがあれば、あなた向けに生成します。
具体的な制約としての語数
語数は、追加できる具体的な情報の中でも、最も簡単で効果的なものの1つです。次の2つを比べてみましょう。
- 曖昧:「短い説明を書いてください」
- 具体的:「75語の説明を書いてください」
モデルはトークンを数え、指定された目標に近づけます。少し外れた場合は、正確に数え直すよう依頼できます。語数を指定すれば、書き直しが必要になるケースを丸ごと減らせます。
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-your-key-here')
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=200,
messages=[{
'role': 'user',
'content': (
'Write a product description for a noise-cancelling travel pillow in exactly 60 words. '
'After the description, output the word count in parentheses on a new line.'
)
}]
)
print(response.content[0].text)具体的な情報としての対象読者
具体的で明確な対象読者を指定すると、出力の語彙、例、深さが大きく変わります。
- 曖昧:「ニューラルネットワークについて説明してください」
- 具体的:「コーディング経験はないもののExcelのピボットテーブルを理解している、Fortune 500企業のマーケティングマネージャーに向けて、ニューラルネットワークを説明してください」
2つ目のプロンプトによって、モデルは実在する読者像を思い描けるため、複雑さを適切に調整できます。
import openai
client = openai.OpenAI(api_key='sk-your-key-here')
concrete_audience_prompt = (
'Explain what a REST API is.\n\n'
'Audience: a non-technical product manager who uses Salesforce daily '
'and understands the concept of a form submission on a website. '
'They will use this explanation to brief their engineering team tomorrow. '
'Use one real-world analogy. Max 100 words.'
)
response = client.chat.completions.create(
model='gpt-4o',
messages=[{'role': 'user', 'content': concrete_audience_prompt}]
)
print(response.choices[0].message.content)一般化より固有表現
固有表現、つまり実在する製品名、企業名、人名、テクノロジー、日付を使うと、モデルを一般的な領域から引き出せます。
- 曖昧:「競合分析を書いてください」
- 具体的:「10人のリモートチームを管理し、毎日執筆し、オフラインアクセスを必要とするパワーユーザー向けに、Notion、Obsidian、Roam Researchを比較する競合分析を書いてください」
固有表現によって、モデルが学習時に得た現実世界の知識に出力を結び付けられます。
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': (
'Compare FastAPI vs Flask vs Django REST Framework '
'for building a production API that will serve a React frontend. '
'Context: 2-person startup team, Python 3.11, needs async support, '
'expects < 50 ms response time, and will deploy on AWS Lambda. '
'Format: 3-column markdown table with rows: setup complexity, '
'async support, performance, learning curve, community size.'
)
}]
)
print(response.content[0].text)数量的な制約
数値は曖昧になりません。数値による要件がある場合は、必ずプロンプトに記載してください。
- 正確にN個の項目を列挙する(「いくつか」や「複数」ではなく)
- 語数または文字数の上限/下限
- 具体的な割合や比率(「実践70%、理論30%」)
- 時間の制約(「3分で読める内容として説明してください」)
- パフォーマンス目標(「時間計算量O(n)を達成する方法を提案してください」)
import openai
client = openai.OpenAI(api_key='sk-your-key-here')
response = client.chat.completions.create(
model='gpt-4o',
messages=[{
'role': 'user',
'content': (
'Generate exactly 8 onboarding email subject lines for a B2B SaaS product. '
'Requirements:\n'
'- Exactly 8 lines, no more, no fewer\n'
'- Each subject line between 40 and 60 characters\n'
'- 4 must emphasize value, 4 must create urgency\n'
'- Label each line: [VALUE] or [URGENCY]\n'
'- No emojis\n'
'- No duplicate words across all 8 lines'
)
}]
)
print(response.choices[0].message.content)期限と時間に基づく枠組み
時間的な文脈を伝えると、出力の深さと焦点が変わります。この内容をいつ使うのか、またそれによってどのような制約が生じるのかをモデルに伝えてください。
- 「このメールは2時間後に送信します。簡潔にしてください」
- 「これは月曜日の取締役会向けプレゼンテーション用です。経営層向けの表現にしてください」
- 「この説明は5分間のスタンドアップミーティングで使える必要があります」
- 「顧客との通話前に10分で確認するチーム向けに書いてください」
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-your-key-here')
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=256,
messages=[{
'role': 'user',
'content': (
'Write a project status update for our AI chatbot project. '
'This will be read aloud at a 5-minute Monday morning stand-up. '
'The audience has zero technical background. '
'Talking time: max 2 minutes (approximately 300 words). '
'Cover: what we shipped last week, one current blocker, one upcoming milestone. '
'Tone: confident and factual. No jargon.'
)
}]
)
print(response.content[0].text)プロンプト内の具体例
望むものや望まないものの具体例を含めることは、最も効果の高いテクニックの一つです。例によって、形式、語り口、スタイルを同時に伝えられます。
次のものを含められます:
- 理想的な出力の例(one-shot)
- ラベル付きの複数の例(few-shot)
- 以前うまくいかなかった例(ネガティブ例)
import openai
client = openai.OpenAI(api_key='sk-your-key-here')
prompt = '''
Write 3 feature announcement tweets for a new developer tool.
Here is an example of the style I want:
"We just shipped inline type errors in the editor. No more tab-switching to find
what broke. Your flow stays unbroken. Try it now: [link]"
Characteristics of this style:
- Opens with what shipped, not with excitement words
- Describes the user benefit in the second sentence
- Ends with a CTA
- No hashtags. No emojis. Under 200 characters.
New feature: autocomplete that learns from your codebase.
'''
response = client.chat.completions.create(
model='gpt-4o',
messages=[{'role': 'user', 'content': prompt}]
)
print(response.choices[0].message.content)ドメイン固有の語彙
ドメイン固有の用語を含めると、出力に求める専門知識のレベルがモデルに伝わります。
- 「キャッシュを説明してください」→ 一般的な回答
- 「MemcachedからRedis 7.xへ移行中のバックエンドエンジニア向けに、RedisのLRUエビクションポリシーを説明してください」→ 専門家レベルで、ドメインに根ざした回答
プロンプトで自分の分野の語彙を使うと、モデルも出力でそれに合わせます。
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-your-key-here')
# Generic prompt vs domain-vocabulary prompt
generic = 'Explain caching strategies.'
domain_anchored = (
'Compare write-through, write-behind, and cache-aside patterns '
'for a microservices architecture using Redis 7.x as the cache layer and '
'PostgreSQL 15 as the source of truth. '
'Focus on consistency guarantees, latency tradeoffs, and failure modes. '
'Audience: senior backend engineers familiar with CAP theorem.'
)
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=400,
messages=[{'role': 'user', 'content': domain_anchored}]
)
print(response.content[0].text)除外する内容の制約
具体的な否定制約(除外指定)によって、モデルがありがちな一般論に流れるのを防げます。
- 「有料APIキーが必要な解決策は提案しないでください」
- 「競合他社の名前には言及しないでください」
- 「leverageやsynergyという単語は使わないでください」
- 「理論的な内容は含めず、実践的な内容だけにしてください」
- 「実装に5分を超える時間が必要なアプローチは除外してください」
除外ルールを一つ追加するたびに、一般的な内容につながる選択肢が減り、出力がより具体的になります。
import openai
client = openai.OpenAI(api_key='sk-your-key-here')
response = client.chat.completions.create(
model='gpt-4o',
messages=[{
'role': 'user',
'content': (
'Suggest 5 ways to speed up a slow Python script. '
'EXCLUDE:\n'
'- Suggestions requiring third-party libraries (stdlib only)\n'
'- Suggestions about hardware upgrades\n'
'- Rewrites of the entire script\n'
'- Suggestions that take more than 30 minutes to implement\n'
'Each suggestion: one sentence describing what to do, one sentence on expected speedup.'
)
}]
)
print(response.choices[0].message.content)すべてを組み合わせる
完全に具体的なプロンプトを、段階を追って組み立ててみましょう。出発点は次のとおりです:「求人票を書いてください。」
- 役割を追加する:「シニアMLエンジニア向けに」
- 固有名詞を追加する:「ロンドンのシリーズBのAIスタートアップで」
- 文字数を追加する:「350~400語で」
- 対象読者を追加する:「5年以上の経験を持つ候補者向けに」
- 構成を追加する:「形式:導入、職務内容(箇条書き8項目)、応募要件(箇条書き5項目)、歓迎条件(箇条書き3項目)」
- 除外指定を追加する:「fast-pacedやpassionateのような決まり文句は使わない」
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-your-key-here')
concrete_prompt = (
'Write a job description for a Senior ML Engineer position '
'at a Series B AI startup in London. '
'Target candidate: 5+ years ML experience, strong Python, familiar with LLMs. '
'Length: 350-400 words. '
'Structure:\n'
'1. 3-sentence company intro (no fluff — focus on product and mission)\n'
'2. Responsibilities: exactly 8 bullet points\n'
'3. Requirements: exactly 5 bullet points\n'
'4. Nice-to-haves: exactly 3 bullet points\n'
'EXCLUDE: phrases like "fast-paced", "passionate", "ninja", "rockstar", "self-starter".'
)
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=600,
messages=[{'role': 'user', 'content': concrete_prompt}]
)
print(response.content[0].text)プロンプトを充実させる習慣
すべてのプロンプトを送信する前に、内容を充実させる習慣を身につけてください。次の簡単な確認を頭の中で行います:
- 曖昧な言葉を数字に置き換えられますか?
- 具体的なツール、技術、人物の名前を挙げられますか?
- 対象読者をより正確に説明できますか?
- 望むものの例を追加できますか?
- 「含めないもの」の制約を少なくとも一つ追加できますか?
- 出力形式をより正確に指定できますか?
2、3個の改善を加えるだけでも、出力の品質は大幅に向上します。
# Prompt enrichment in code form: before/after comparison
before = 'Give me ideas for my presentation.'
after = (
'Generate 6 opening hook ideas for a 15-minute conference talk '
'titled "Why Your AI Prompts Are Failing You" at PyCon 2025. '
'Audience: Python developers, mostly backend, some ML experience. '
'Each hook: 2 sentences max. '
'Mix: 2 provocative statistics, 2 counterintuitive questions, 2 short stories. '
'EXCLUDE: "Did you know..." openers and rhetorical questions about the future of AI.'
)
print('BEFORE:', before)
print()
print('AFTER:', after)理解度チェック
あるスタートアップの創業者が、次のプロンプトを送信しました:「マーケティングコピーの作成を手伝ってください。」具体的な情報を最も効果的に使っている書き直し後のプロンプトはどれでしょうか?
具体的な情報の追加 — まとめ
具体的な情報によって、曖昧なプロンプトを正確な指示に変えられます。次のアンカー技法を使ってください:
- 文字数:「短い/長い」を正確な数字に置き換える
- 固有名詞:具体的な製品、ツール、企業、人名
- 対象読者:役割、経験レベル、すでに知っていること
- 数量制約:項目数を正確にN個にする、各種類をN%ずつにする
- ドメイン語彙:その分野固有の用語を使い、求める深さを示す
- 例:良い出力がどのようなものかを示す
- 除外指定:モデルが避けるべきものを明示する
よくある質問
「具体的な詳細を加える」レッスンは無料ですか?
はい。「具体的な詳細を加える」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、AI Prompt Engineeringコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 AI Prompt Engineeringコースには全4レッスンが含まれています。
「具体的な詳細を加える」で何を学びますか?
AI の出力の方向性を定める数字、名前、形式、例について学びます。 ブラウザで直接実行するハンズオンコードでAI Prompt Engineeringを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
AI Prompt Engineeringを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのAI Prompt Engineeringは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「具体的な詳細を加える」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このAI Prompt Engineeringレッスンでコードを書いて実行できますか?
はい。すべてのAI Prompt Engineeringレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。