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

スコアラーで歴史的な痕跡を埋める

備考

ベータ版

この機能はベータ版です。ワークスペース管理者は、 プレビュー ページからこの機能へのアクセスを制御できます。Databricksのプレビューを管理するを参照してください。

過去のデータに、新しいスコアラーや更新されたスコアラーを遡って適用することができます。これは、新しいスコアラーを追加して過去の「本番運用」データを評価したい場合、または既存のスコアラーを更新して新しい設定で以前のトレースを再評価したい場合に便利です。

前提条件

  • スコアラーは、補充要員として使用する前に、登録と業務開始を完了していなければなりません。
  • 適用するスコアラーを指定するには、スコアラー名またはBackfillScorerConfigオブジェクトが必要です。

最近のデータをバックフィルする

最近のトレースのみをバックフィルするには、現在の日付を基準としてstart_timeを指定します。

Python
from datetime import datetime, timedelta

# Backfill last week's data with higher sample rates
one_week_ago = datetime.now() - timedelta(days=7)

job_id = backfill_scorers(
scorers=[
BackfillScorerConfig(scorer=safety_judge, sample_rate=0.8),
BackfillScorerConfig(scorer=response_length, sample_rate=0.9)
],
start_time=one_week_ago
)

カスタムサンプルレートと時間範囲でバックフィル

現在の設定とは異なるサンプリングレートでスコアラーを適用する場合、またはバックフィルを特定の時間範囲に制限する場合は、 BackfillScorerConfig使用します。

Python
from databricks.agents.scorers import backfill_scorers, BackfillScorerConfig
from datetime import datetime
from mlflow.genai.scorers import Safety, scorer, ScorerSamplingConfig

safety_judge = Safety()
safety_judge = safety_judge.register(name="safety_check")
safety_judge = safety_judge.start(sampling_config=ScorerSamplingConfig(sample_rate=0.5))

@scorer(aggregations=["mean", "min", "max"])
def response_length(outputs):
"""Measure response length in characters"""
return len(outputs)

response_length = response_length.register(name="response_length")
response_length = response_length.start(sampling_config=ScorerSamplingConfig(sample_rate=0.5))

# Define custom sample rates for backfill
custom_scorers = [
BackfillScorerConfig(scorer=safety_judge, sample_rate=0.8),
BackfillScorerConfig(scorer=response_length, sample_rate=0.9)
]

job_id = backfill_scorers(
experiment_id=YOUR_EXPERIMENT_ID,
scorers=custom_scorers,
start_time=datetime(2024, 6, 1),
end_time=datetime(2024, 6, 30)
)

現在のサンプリングレートを使用してバックフィルを行う

登録済みのスコアラーを、現在のサンプルレート設定を使用して過去のトレースに適用するには:

Python
from databricks.agents.scorers import backfill_scorers
from mlflow.genai.scorers import Safety, scorer, ScorerSamplingConfig

safety_judge = Safety()
safety_judge = safety_judge.register(name="safety_check")
safety_judge = safety_judge.start(sampling_config=ScorerSamplingConfig(sample_rate=0.5))

@scorer(aggregations=["mean", "min", "max"])
def response_length(outputs):
"""Measure response length in characters"""
return len(outputs)

response_length = response_length.register(name="response_length")
response_length = response_length.start(sampling_config=ScorerSamplingConfig(sample_rate=0.5))

# Use existing sample rates for specified scorers
job_id = backfill_scorers(
scorers=["safety_check", "response_length"]
)

ベストプラクティス

  • まずは小さなことから始めよう。ジョブの期間とリソースの使用量を見積もるために、より小さい時間範囲から始めます。
  • 適切なサンプルレートを使用してください。大規模な過去データセットに高いサンプリングレートを適用する場合のコストと時間への影響を考慮してください。

トラブルシューティング

「エクスペリメントに予定されたスコアラー 'X' が見つかりません」

  • スコアラーの名前がエクスペリメントに登録されているスコアラーと一致していることを確認してください。
  • list_scorers()メソッドを使用して、利用可能なスコアラーを確認してください。

次のステップ