メインコンテンツまでスキップ

LLMジャッジとスコアラー

スコアラーは、出力を分析し、構造化されたフィードバックを生成することで、生成AI アプリの品質を評価します。同じスコアラーを開発時の評価に使用したり、本番運用時のモニタリングに再利用したりできます。

MLflow は 2 種類のスコアラーを提供します。

  • LLM ジャッジ - 大規模言語モデルを活用して、関連性、安全性、正確性などの微妙な品質基準を評価するスコアラー。これらには次のものが含まれます。

  • コードベースのスコアラー - レイテンシー、一瞬の使用法、完全一致など、メトリクスのプログラム ロジックを使用する決定論的スコアラー:

以下の MLflow UI スクリーンショットは、組み込みの LLM ジャッジSafetyとカスタム スコアラーexact_matchからの出力を示しています。

スコアラーからのメトリクスの例

以下のコード スニペットは、 mlflow.genai.evaluate()を使用してこれらのメトリクスをコンピュートし、本番運用モニタリング用に同じスコアラーを登録します。

Python
import mlflow
from mlflow.genai.scorers import Safety, ScorerSamplingConfig, scorer
from typing import Any

@scorer
def exact_match(outputs: str, expectations: dict[str, Any]) -> bool:
# Example of a custom code-based scorer
return outputs == expectations["expected_response"]

# Evaluation during development
eval_results = mlflow.genai.evaluate(
data=eval_dataset,
predict_fn=my_app,
scorers=[Safety(), exact_match]
)

# Production monitoring - same scorers!
registered_scorers = [
Safety().register(),
exact_match.register(),
]
registered_scorers = [
reg_scorer.start(
sampling_config=ScorerSamplingConfig(sample_rate=0.1)
)
for reg_scorer in registered_scorers
]

次のステップ