Skip to content

Metric

assistant_eval_en_single_turn

This is a configuration for evaluting the quality of responses generated by an AI assistant. Originally used to generate scores for MT-bench or Vicuna-bench.

Adapted from lm-sys/FastChat.

{
  class_path: 'ChatLLMScore',
  init_args: {
    language_model: { class_path: 'OpenAIChatAPI', init_args: { model: 'gpt-4-turbo-2024-04-09' } },
    valid_score_range: [1, 10],
    prompt_template: {
      class_path: 'Jinja2PromptTemplate',
      init_args: {
        template: std.stripChars(|||
          [Instruction]
          {% if references|length > 0 -%}
          Please act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question displayed below. Your evaluation should consider correctness and helpfulness. You will be given a reference answer and the assistant's answer. Begin your evaluation by comparing the assistant's answer with the reference answer. Identify and correct any mistakes. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 1 to 10 by strictly following this format: "[[rating]]", for example: "Rating: [[5]]".
          {%- else -%}
          Please act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question displayed below. Your evaluation should consider factors such as the helpfulness, relevance, accuracy, depth, creativity, and level of detail of the response. Begin your evaluation by providing a short explanation. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 1 to 10 by strictly following this format: "[[rating]]", for example: "Rating: [[5]]".
          {%- endif %}

          [Question]
          {{ messages[0]["content"] }}

          {% if references|length > 0 -%}
          [The Start of Reference Answer]
          {{ references[0] }}
          [The End of Reference Answer]
          {% endif -%}
          [The Start of Assistant's Answer]
          {% if messages|length == 1 %}{{ lm_output }}{% else %}{{ messages[1]["content"] }}{% endif %}
          [The End of Assistant's Answer]
        |||, '\n'),
      },
    },
  },
}

assistant_eval_ja_single_turn

This is a configuration for evaluting the quality of responses generated by an AI assistant. Originally used to generate scores for the Japanese versions of MT-bench or Vicuna-bench.

Translated and adapted from lm-sys/FastChat.

{
  class_path: 'ChatLLMScore',
  init_args: {
    language_model: { class_path: 'OpenAIChatAPI', init_args: { model: 'gpt-4-turbo-2024-04-09' } },
    valid_score_range: [1, 10],
    prompt_template: {
      class_path: 'Jinja2PromptTemplate',
      init_args: {
        template: std.stripChars(|||
          [指示]
          {% if references|length > 0 -%}
          以下に表示されるユーザの質問に対するアシスタントの応答の品質を評価してください。評価は正確さと有用性を考慮すべきです。アシスタントの回答の言語は、ユーザが使用している言語と一致しているべきで、そうでない場合は減点されるべきです。参照回答とアシスタントの回答が与えられます。あなたの評価は、アシスタントの回答と参照回答を比較することから始めてください。ミスを特定し、訂正してください。できるだけ客観的であること。評価の説明をした後、"[[rating]]"という形式で、1から10までの整数の評価値を出力してください(例 "rating:[[5]]")。
          {%- else -%}
          以下に表示されるユーザの質問に対するアシスタントの応答の品質を公平に評価してください。評価は、応答の有用性、関連性、正確性、深さ、創造性、詳細度などの要素を考慮すべきです。アシスタントの回答の言語は、ユーザが使用している言語と一致しているべきで、そうでない場合は減点されるべきです。評価は短い説明から始めてください。できるだけ客観的であること。評価の説明をした後、"[[rating]]"という形式で、1から10までの整数の評価値を出力してください(例 "rating:[[5]]")。
          {%- endif %}

          [ユーザの質問]
          {{ messages[0]["content"] }}

          {% if references|length > 0 -%}
          [参考回答の開始]
          {{ references[0] }}
          [参考回答の終了]
          {% endif -%}
          [アシスタントの回答開始]
          {% if messages|length == 1 %}{{ lm_output }}{% else %}{{ messages[1]["content"] }}{% endif %}
          [アシスタントの回答終了]
        |||, '\n'),
      },
    },
    system_message: 'あなたは優秀な助手です。',
  },
}

elyza_tasks_100_eval

This is a config of the ChatLLMScore class designed to evaluate chat assistants with ELYZA-tasks-100. The template is adapted from the blog post ELYZAが公開した日本語LLM「ELYZA-japanese-Llama-2-7b」についての解説 : (2) 評価編.

{
  class_path: 'ChatLLMScore',
  init_args: {
    language_model: { class_path: 'OpenAIChatAPI', init_args: { model: 'gpt-4-turbo-2024-04-09' } },
    valid_score_range: [1, 5],
    prompt_template: {
      class_path: 'Jinja2PromptTemplate',
      init_args: {
        template: std.stripChars(|||
          あなたは採点者です。

          問題, 正解例, 採点基準, 回答 が与えられます。

          採点基準と正解例を参考にして、回答を1,2,3,4,5の5段階で採点し、数字のみを出力してください。

          # 問題
          {{ messages[-1]["content"] }}

          # 正解例
          {{ references[0] }}

          # 採点基準
          基本的な採点基準
          - 1点: 誤っている、 指示に従えていない
          - 2点: 誤っているが、方向性は合っている
          - 3点: 部分的に誤っている、 部分的に合っている
          - 4点: 合っている
          - 5点: 役に立つ

          基本的な減点項目
          - 不自然な日本語: -1点
          - 部分的に事実と異なる内容を述べている: -1点
          - 「倫理的に答えられません」のように過度に安全性を気にしてしまっている: 2点にする

          問題固有の採点基準
          {{ eval_aspect }}

          # 回答
          {{ lm_output }}
        |||, '\n'),
      },
    },
  },
}