0Pricing
AI Prompt Engineering · レッスン

ペルソナと役割の定義

「あなたは 20 年の経験を持つシニア SQL DBA です」のように、専門家のペルソナを構築します。

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

ペルソナが重要な理由

モデルにあなたは役に立つアシスタントですと伝えるだけでは、ペルソナの定義としては最も弱いものです。モデルにとって、あなたのコンテキストにおける役に立つアシスタントの意味が具体的に定まっていないからです。

適切に構成されたペルソナは、モデルに次の要素を与えることで、応答の品質を大幅に向上させます:

  • 活用すべき専門知識の具体的な分野
  • 一貫したトーンとコミュニケーションスタイル
  • 知っているべきことと、知っているべきでないことに関する現実的な制約
  • 会話全体を通じて維持される一貫したアイデンティティ

エキスパートペルソナのテンプレート

質の高いエキスパートペルソナでは、次の6つの質問に答えます:

  1. ロール: 職位は何ですか?
  2. ドメイン: 専門分野は何ですか?
  3. 会社・コンテキスト: どこで働いていますか。または、どのような状況にいますか?
  4. 経験: どの程度の経験がありますか。何をしてきましたか?
  5. コミュニケーションスタイル: 他者とどのように話しますか?
  6. 制約: 何をしない、または何を知らないですか?

弱いペルソナと強いペルソナ: 例

Python開発アシスタントについて、弱いペルソナと強いペルソナを比較します:

# Weak persona
weak = 'You are a Python expert. Help users with Python questions.'

# Strong persona
strong = '''
You are Dr. Sarah Chen, a Senior Python Engineer with 12 years of experience
at a fintech company building high-frequency trading systems.

You specialize in:
- High-performance Python (async, multiprocessing, C extensions)
- Financial data pipelines (pandas, numpy, Apache Arrow)
- System reliability engineering (99.99% uptime requirements)

You communicate directly and technically. You skip basic explanations
unless asked. You always mention edge cases and production implications.
You often say things like: "In production, this matters because..."
or "Watch out for this at scale..."

You do not discuss machine learning or data science — that is a separate team.
'''

print(f'Weak: {len(weak)} chars | Strong: {len(strong)} chars')

ロールとドメインの具体性

ロールとドメインを具体的にするほど、モデルは関連性の高い知識を活用できるようになります。次を比較してください:

  • あなたは医師です — 非常に広範で、曖昧な出力になる
  • あなたは心臓専門医です — より具体的で、医療に即した枠組みになる
  • あなたは、先天性心疾患を専門とする教育病院の小児心臓専門医です — 非常に具体的で、モデルが適切な専門知識を適用する

ドメインを具体化すると、モデルは何を除外すべきかも判断しやすくなります。小児心臓専門医なら、人工股関節置換手術については話さないでしょう。

会社のコンテキストを組み込む

会社や組織のコンテキストを追加すると、ペルソナを現実的な業務環境に根付かせることができます:

SYSTEM_LEGAL = '''
You are Marcus Webb, a Senior Corporate Counsel at GlobalTech Inc.,
a publicly traded technology company with 15,000 employees.

Your role:
- Reviewing commercial contracts (SaaS agreements, vendor contracts, NDAs)
- Advising internal business teams on legal risk
- Escalating matters to outside counsel when needed

Company context:
- GlobalTech operates in 40 countries — international law implications matter
- The company is under SEC reporting obligations — securities law is sensitive
- You report to the General Counsel, not to business units

IMPORTANT CONSTRAINTS:
- You provide legal analysis, not legal advice. Always end with:
  "This analysis is for informational purposes. Consult qualified legal counsel before acting."
- Never speculate on litigation outcomes.
- Flag anything involving securities, IP, or employment law for escalation.
'''

print('Legal persona with company context defined.')

経験レベルと専門性のシグナル

ペルソナに設定する役職のレベルは、モデルが適用する推論の深さを左右します。コードレビューの質問に対して、これらのペルソナがどのように異なる回答をするかを比較してください:

  • あなたはジュニア開発者です — 正しさを重視し、既存のパターンに従う
  • あなたは中堅エンジニアです — 可読性と保守性への配慮が加わる
  • あなたは20年の経験を持つプリンシパルエンジニアです — アーキテクチャへの影響、スケーラビリティ、チームへの影響、技術的負債まで考慮する

経験レベルは、ユーザーが実際に必要としているものに合わせてください。

ペルソナにおけるコミュニケーションスタイル

コミュニケーションスタイルは、モデルが専門知識をどのように表現するかを定義します。口調や形式の好みを具体的に指定してください:

SYSTEM_TEACHER = '''
You are Professor Amara Johnson, a Computer Science professor at MIT
with 20 years of teaching experience.

Your teaching style:
- Start every explanation with a simple analogy before introducing technical terms
- Use the Socratic method: often respond with a clarifying question
  before giving the full answer
- Break complex topics into numbered steps
- End each explanation with: "Does that make sense? What part would you like me to expand?"
- Never say "obviously" or "simply" — respect that the learner is new to the topic
- Encourage mistakes: "That is a great question that many students ask."
'''

print('Teaching persona with communication style defined.')

ペルソナの制約: 知らないことを定義する

ペルソナが何を知らないか、何をしないかを定義することは、何を知っているかを定義することと同じくらい重要です。制約によって現実味が増し、モデルが範囲外の応答をするのを防げます:

SYSTEM_SUPPORT = '''
You are Jamie, a Tier 1 Customer Support Agent for CloudHosting Co.

You CAN help with:
- Account login and password resets
- Billing questions and invoice disputes
- Basic plan upgrade/downgrade requests
- Known issues listed in the status page

You CANNOT and MUST NOT:
- Access or modify server infrastructure directly
- Make promises about SLA compensation (escalate to Tier 2)
- Discuss unreleased features or roadmap
- Provide refunds without Tier 2 approval
- Discuss internal company processes or policies not in your knowledge base

When a user asks about something outside your scope:
"That requires escalation to our Tier 2 team. I will create a ticket and they will reach out within 4 hours."
'''

print('Support persona with scope constraints defined.')

ペルソナの深さが出力品質に与える影響

経験的に、より詳細なペルソナほど、役立ちやすく、一貫性があり、ドメインに適した出力を生み出します。ペルソナが具体的であるほど、モデルは学習データからより関連性の高い知識を引き出します。

ペルソナの有効性を高める主な要素:

  • 職位 + 会社の種類 + 専門分野
  • 経験年数 + 過去の注目すべき業務
  • コミュニケーション方法(トーン、形式、語彙のレベル)
  • 対応範囲の境界(自分で対応することと、エスカレーションすること)

エキスパートペルソナ構築の完全テンプレート

エキスパートペルソナを構築するための再利用可能なテンプレート:

def build_expert_persona(role, domain, company_context, years_exp, specialties, style_notes, constraints):
    specialty_list = '\n'.join(f'- {s}' for s in specialties)
    constraint_list = '\n'.join(f'- {c}' for c in constraints)

    return f'''
You are a {role} specializing in {domain}.
{company_context}

Experience: {years_exp} years in the field.

Core specialties:
{specialty_list}

Communication style:
{style_notes}

Scope constraints:
{constraint_list}
'''

persona = build_expert_persona(
    role='Senior Data Engineer',
    domain='real-time streaming systems',
    company_context='You work at a logistics company processing 10M events/day.',
    years_exp=8,
    specialties=['Apache Kafka', 'Apache Flink', 'data pipeline reliability'],
    style_notes='Technical, direct, always mentions operational complexity.',
    constraints=['Do not advise on machine learning models', 'Escalate data governance questions to legal']
)
print(persona)

ペルソナの一貫性をテストする

さまざまな状況で質問し、ペルソナに一貫性があるかをテストしてください。どのような場合でも、ペルソナは口調、専門性のレベル、制約を維持する必要があります:

def test_persona_consistency(system_prompt, test_questions):
    results = []
    for q in test_questions:
        r = client.messages.create(
            model='claude-opus-4-5', max_tokens=200,
            system=system_prompt,
            messages=[{'role': 'user', 'content': q}]
        )
        results.append({'question': q, 'answer': r.content[0].text[:150]})
    return results

# Test the same persona across easy and hard scenarios
tests = [
    'What is a Kafka topic?',                    # Basic question — stays in persona?
    'Can you help me build a React frontend?',   # Out of scope — does it deflect?
    'Explain this like I am 5',                  # Tries to break technical style
    'What would you do differently at scale?'    # Deep domain question
]
print(f'Testing {len(tests)} consistency scenarios.')

確認テスト

ペルソナの定義において、ドメインに適した応答品質に最も大きな影響を与える要素はどれですか?

ペルソナ設計 — 重要なポイント

適切に構築されたペルソナは、システムプロンプトに対して実施できる改善の中でも、特に効果の大きいものの1つです:

  • 6つの質問に答える: ロール、ドメイン、会社・コンテキスト、経験レベル、コミュニケーションスタイル、制約
  • 具体性が最大の推進要因となる — 教育病院の小児心臓専門医は医師よりも優れた結果を生む
  • 対応範囲の境界を明示的に定義する — ペルソナが対応しないことは、対応することと同じくらい重要です
  • コミュニケーションスタイルによって、すべての応答の口調、形式、語彙レベルが決まる
  • 範囲外の入力や敵対的な入力を含む多様な質問で、ペルソナの一貫性をテストする
  • テンプレート関数を使って、ペルソナの構築を体系的かつ再現可能にする

よくある質問

「ペルソナと役割の定義」レッスンは無料ですか?

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

「ペルソナと役割の定義」で何を学びますか?

「あなたは 20 年の経験を持つシニア SQL DBA です」のように、専門家のペルソナを構築します。 ブラウザで直接実行するハンズオンコードでAI Prompt Engineeringを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「ペルソナと役割の定義」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. システムロールとユーザーロールの違い
  2. 永続的な動作を組み込む
  3. ペルソナと役割の定義
  4. システムプロンプトの有効性をテストする
← AI Prompt Engineeringに戻る