AI Prompt Engineering · レッスン

ルーブリックベースの採点プロンプト

正確性、流暢性、関連性、安全性を構造化した評価基準(1~5段階)で採点します。

レッスン 2/413 ステップ

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

ルーブリックベースの採点とは

ルーブリックベースの採点では、各スコアレベルの明確な定義を含む、構造化された評価基準をLLM評価モデルに与えます。「どのくらい良いか」と尋ねるのではなく、「この特定の各評価軸で何点に相当するか」と尋ねます。

ルーブリックによってバイアスが減り、一貫性が高まり、評価結果を解釈して具体的な対応につなげやすくなります。

採点ルーブリックの構成

適切に設計されたルーブリックには、次の3つの要素があります。

  1. 評価基準名:何を評価するかを示す評価軸(正確性、完全性、明瞭性)
  2. スコアアンカー:その評価基準において各スコアが何を意味するかを明確に定義したもの
  3. 重みまたは優先度:この用途でどの評価基準を最も重視するか

各要素によって、評価モデルの作業に制約が加わり、再現性が高まります。

3つの評価基準を使うルーブリックプロンプト

ここでは、正確性、完全性、明瞭性についてAIの回答を評価するための、具体的なルーブリックプロンプトのテンプレートを示します。評価モデルは、評価基準ごとのスコアを含む構造化されたJSONを返します。

import anthropic
import json

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

RUBRIC_PROMPT = (
    'Score this response on a scale of 1-5 for each criterion:\n\n'
    'ACCURACY: Is the response factually correct?\n'
    '  1=Contains significant factual errors\n'
    '  3=Mostly correct with minor inaccuracies\n'
    '  5=Completely accurate with no errors\n\n'
    'COMPLETENESS: Did it answer everything asked?\n'
    '  1=Missed most of the question\n'
    '  3=Answered the main question but missed sub-parts\n'
    '  5=Addressed every part of the question\n\n'
    'CLARITY: Is it easy to understand?\n'
    '  1=Confusing, hard to follow\n'
    '  3=Understandable but could be clearer\n'
    '  5=Exceptionally clear and well-organized\n\n'
    'Question: {question}\n'
    'Response: {response}\n\n'
    'Return JSON: {{"accuracy": N, "completeness": N, "clarity": N, '
    '"overall": N, "notes": "one sentence"}}'
)

def rubric_judge(question, response):
    prompt = RUBRIC_PROMPT.format(question=question, response=response)
    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=200,
        messages=[{'role': 'user', 'content': prompt}]
    )
    return json.loads(r.content[0].text)

result = rubric_judge(
    question='What is a REST API?',
    response='A REST API is a way for applications to communicate over HTTP.'
)
print(result)

重み付きスコアリング

すべての評価基準が同じ重要度を持つわけではありません。カスタマーサポートボットでは、文学的な文体よりも役立つことのほうが重要です。重み付きスコアリングを使うと、最終スコアの計算にこうした優先順位を反映できます。

import anthropic
import json

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

def weighted_rubric_judge(question, response, weights):
    """
    weights: dict of criterion -> weight (should sum to 1.0)
    Example: {'accuracy': 0.5, 'completeness': 0.3, 'clarity': 0.2}
    """
    RUBRIC = (
        'Score this response 1-5 on:\n'
        'Accuracy: Is it factually correct?\n'
        'Completeness: Does it cover the full question?\n'
        'Clarity: Is it easy to understand?\n\n'
        'Q: {q}\nA: {a}\n\n'
        'Return JSON: {{"accuracy":N,"completeness":N,"clarity":N}}'
    )
    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=100,
        messages=[{'role': 'user', 'content': RUBRIC.format(q=question, a=response)}]
    )
    scores = json.loads(r.content[0].text)

    # Calculate weighted average
    weighted_score = sum(
        scores[criterion] * weight
        for criterion, weight in weights.items()
        if criterion in scores
    )
    print(f'Individual scores: {scores}')
    print(f'Weighted score: {weighted_score:.2f}/5')
    return weighted_score

weighted_rubric_judge(
    'How do I reverse a string in Python?',
    'Use slicing: s[::-1]',
    weights={'accuracy': 0.5, 'completeness': 0.3, 'clarity': 0.2}
)

評価基準:事実の正確性

事実の正確性は、知識集約型タスクで最も重要な評価基準です。正確性に特化したルーブリックでは、誤った事実、古い情報、裏付けのない主張がないかを重点的に確認するよう評価モデルに指示します。

ACCURACY_RUBRIC = (
    'Evaluate FACTUAL ACCURACY of the following response.\n\n'
    'Score 1-5:\n'
    '1 = Multiple factual errors that fundamentally mislead the reader\n'
    '2 = At least one significant factual error (wrong date, number, or core fact)\n'
    '3 = Factually correct but includes minor imprecisions or over-generalizations\n'
    '4 = Factually correct with appropriate hedging of uncertain claims\n'
    '5 = Factually precise, no errors, and correctly acknowledges uncertainty where present\n\n'
    'Check specifically for:\n'
    '- Wrong dates, statistics, or numerical values\n'
    '- Misattributed quotes or inventions\n'
    '- Outdated information presented as current\n'
    '- Claims stated with false confidence (should be hedged)\n\n'
    'Q: {question}\nA: {response}\n\n'
    'Score and list any errors found:'
)
print(ACCURACY_RUBRIC[:400])

評価基準:完全性

完全性では、複数の部分からなる質問のすべてに回答しているかを確認します。この評価基準により、最初の質問には答えているものの追加の質問を無視している回答や、具体例を求められているのに大まかな回答しかしていない回答を検出できます。

COMPLETENESS_RUBRIC = (
    'Evaluate COMPLETENESS of this response.\n\n'
    'First, list every distinct question or requirement in the original query.\n'
    'Then, check whether the response addressed each one.\n\n'
    'Score 1-5:\n'
    '1 = Only addressed 0-20% of what was asked\n'
    '2 = Addressed 20-50% — missed major components\n'
    '3 = Addressed 50-80% — answered main question but missed sub-parts\n'
    '4 = Addressed 80-95% — minor omissions only\n'
    '5 = Addressed 100% — every requirement was met\n\n'
    'Q: {question}\nA: {response}\n\n'
    'Requirements checklist and completeness score:'
)

# This rubric forces the judge to decompose the question first,
# which is much more reliable than asking 'was it complete?'
print(COMPLETENESS_RUBRIC[:400])

評価基準:明瞭性

明瞭性の評価では、読みやすさ、構成、そして対象読者に実際に意味が伝わるかどうかを確認します。この評価基準により、技術的には正しいものの説明が不十分な回答を検出できます。

CLARITY_RUBRIC = (
    'Evaluate CLARITY of this response for a {audience} audience.\n\n'
    'Score 1-5:\n'
    '1 = Incomprehensible — cannot extract meaning\n'
    '2 = Very hard to follow — excessive jargon, poor structure\n'
    '3 = Understandable with effort — some confusing parts\n'
    '4 = Clear and well-organized — easy to read\n'
    '5 = Exceptionally clear — ideal structure, appropriate vocabulary, '
    'no unnecessary complexity\n\n'
    'Consider:\n'
    '- Is the vocabulary appropriate for the audience?\n'
    '- Is the response logically organized?\n'
    '- Are sentences a readable length?\n'
    '- Is the main point stated early and clearly?\n\n'
    'Q: {question}\nA: {response}\n\n'
    'Clarity score and key issues:'
)

# Parameterize the audience for context-aware clarity assessment
print(CLARITY_RUBRIC.format(
    audience='non-technical business stakeholder',
    question='What is an API?',
    response='REST APIs use HTTP to transfer data between client and server.'
)[:300])

タスク固有のルーブリック

正確性・完全性・明瞭性という汎用的なルーブリックは幅広く機能しますが、専門的な用途ではタスク固有のルーブリックのほうが優れた評価結果を出します。実際にアプリケーションで重要な要素に合わせて評価基準をカスタマイズしてください。

# Customer support response rubric
SUPPORT_RUBRIC = (
    'Evaluate this customer support response:\n\n'
    'EMPATHY (1-5): Does it acknowledge the customer emotion?\n'
    'RESOLUTION (1-5): Does it provide a clear solution or next step?\n'
    'TONE (1-5): Is it professional, warm, and not condescending?\n'
    'EFFICIENCY (1-5): Does it avoid unnecessary words or boilerplate?\n\n'
    'Customer message: {customer_message}\n'
    'Support response: {support_response}\n\n'
    'Scores and notes (JSON):'
)

# Code review rubric
CODE_REVIEW_RUBRIC = (
    'Evaluate this code explanation:\n\n'
    'CORRECTNESS (1-5): Is the code technically correct?\n'
    'EDGE_CASES (1-5): Does it handle edge cases (empty input, errors)?\n'
    'EFFICIENCY (1-5): Is it reasonably efficient (no obvious O(n^2) where O(n) is easy)?\n'
    'READABILITY (1-5): Is the code easy to read and understand?\n\n'
    'Task: {task}\n'
    'Code: {code}\n\n'
    'Scores and notes (JSON):'
)
print('Specialized rubrics produce better signal for your domain')

ルーブリックの一貫性テスト

同じ回答を、プロンプトの表現を少し変えて5回送信し、スコアが安定するかを確認して、ルーブリックの一貫性をテストしてください。ばらつきが大きい場合は、ルーブリックの仕様が不十分です。

import anthropic
import json
import statistics

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

def test_rubric_consistency(rubric_prompt, question, response, n_trials=5):
    scores = []
    for i in range(n_trials):
        r = client.messages.create(
            model='claude-opus-4-5',
            max_tokens=100,
            messages=[{'role': 'user', 'content': rubric_prompt.format(
                question=question, response=response
            )}]
        )
        try:
            data = json.loads(r.content[0].text)
            overall = data.get('overall', sum(data.values()) / len(data))
            scores.append(overall)
        except Exception:
            scores.append(None)

    valid = [s for s in scores if s is not None]
    if valid:
        print(f'Scores: {valid}')
        print(f'Mean: {statistics.mean(valid):.2f}')
        print(f'Std dev: {statistics.stdev(valid):.2f}')
        if statistics.stdev(valid) > 0.5:
            print('WARNING: High variance — rubric may be underspecified')

    return valid

評価モデルからJSONを返す

ルーブリックを使う評価モデルには、必ず構造化されたJSONを返すように指示してください。これによりスコアを機械的に読み取れるようになり、自動集計が可能になります。また、パイプラインが無視してしまう重要なニュアンスが、自由記述に埋もれるのを防げます。

import anthropic
import json

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

def structured_rubric_judge(question, response):
    prompt = (
        'Score this response 1-5 on three criteria and return JSON.\n\n'
        'Q: {q}\nA: {a}\n\n'
        'Return ONLY this JSON structure (no other text):\n'
        '{{\n'
        '  "accuracy": <1-5>,\n'
        '  "completeness": <1-5>,\n'
        '  "clarity": <1-5>,\n'
        '  "overall": <1-5>,\n'
        '  "primary_issue": "<what most needs improvement>",\n'
        '  "primary_strength": "<what the response does best>"\n'
        '}}'
    ).format(q=question, a=response)

    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=200,
        messages=[{'role': 'user', 'content': prompt}]
    )

    text = r.content[0].text.strip()
    # Strip markdown code fences if present
    if text.startswith('###'):
        text = text.split('###')[1]
        if text.startswith('json'):
            text = text[4:]
    return json.loads(text.strip())

result = structured_rubric_judge(
    'Explain big O notation.',
    'Big O describes algorithm time complexity.'
)
print(json.dumps(result, indent=2))

ルーブリック設計の反復改善

ルーブリックを適切に機能させるには、反復的な改善が必要です。まずは3つの評価基準によるシンプルなルーブリックから始め、20~30件のテストケースで実行して、人間による評価と比較してください。評価モデルと人間の意見が最も食い違う評価基準の定義を改善します。

よくある改善点としては、正確性の評価基準が広すぎるため事実の正確性と論理的一貫性に分割すること、明瞭性の評価基準が読みやすさと簡潔さを混同しているため分離すること、スコアレベル3の基準が不明確で多くの回答が曖昧なままそこに集中しているためアンカーを改善することなどがあります。

知識チェック:ルーブリックのアンカー

採点ルーブリックに、各スコアレベルの意味を明確に説明する記述(スコアアンカー)を含めるべきなのはなぜですか?

振り返り:ルーブリックベースの採点プロンプト

ルーブリックベースの採点では、複数の評価基準(正確性、完全性、明瞭性)に沿って回答を評価し、各スコアレベルの意味を定義する明確なスコアアンカーを使用します。アンカーによってスコアインフレーションが抑えられ、一貫性が高まります。用途で最も重要な評価基準を優先するには、重み付きスコアリングを使用してください。専門的なアプリケーションでは、タスク固有のルーブリック(サポート、コード、クリエイティブ)のほうが汎用的なルーブリックより優れた結果を出します。機械的に読み取れる結果を得るため、評価モデルからは必ずJSONを返してください。同じ評価を複数回実行してルーブリックの一貫性をテストします。標準偏差が大きい場合は、ルーブリックの仕様が不十分で、改善が必要であることを示します。

無料で開始

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

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

コース
53
レッスン
199

よくある質問

「ルーブリックベースの採点プロンプト」レッスンは無料ですか?

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

「ルーブリックベースの採点プロンプト」で何を学びますか?

正確性、流暢性、関連性、安全性を構造化した評価基準(1~5段階)で採点します。 ブラウザで直接実行するハンズオンコードでAI Prompt Engineeringを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「ルーブリックベースの採点プロンプト」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. LLMによるLLM出力の評価
  2. ルーブリックベースの採点プロンプト
  3. 比較評価:A対B
  4. LLM評価者のキャリブレーションとバイアス
← AI Prompt Engineeringに戻る