本番運用 モニタリング
ベータ版
この機能は ベータ版です。
本番運用 モニタリングは、ライブトラフィックのスコアラーを自動的に実行することで、生成AI アプリケーションの継続的な品質評価を可能にします。 モニタリング サービスは 15 分ごとに実行され、開発で使用するのと同じスコアラーを使用して、トレースの構成可能なサンプルを評価します。
仕組み
MLflow エクスペリメントの本番運用 モニタリングを有効にすると、次のようになります。
- 自動実行 - バックグラウンド ジョブは 15 分ごとに実行されます (初期設定後)
- スコアラーの評価 - 設定された各スコアラーは、本番運用トレースのサンプルに対して実行されます
- フィードバックの添付ファイル - 結果は、評価された各トレースに フィードバック として添付されます
- データのアーカイブ - すべてのトレース (サンプリングされたトレースだけでなく) は、分析のために Unity Catalog の Delta テーブル に書き込まれます
モニタリングサービスでは、開発時と同じ採点者による一貫した評価を行い、手作業による介入なしに自動品質評価を実現します。
現在、本番運用 モニタリングは 事前定義されたスコアラーのみをサポートしています。 本番運用でカスタムコードベースまたはLLMベースのスコアラーを実行する必要がある場合は、 Databricksアカウント担当者にお問い合わせください。
API リファレンス
create_external_monitor
Databricks の外部で提供される 生成AI アプリケーションのモニターを作成します。作成されると、モニターは設定された評価スイートに従ってトレースの自動評価を開始します。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import create_external_monitor
create_external_monitor(
*,
catalog_name: str,
schema_name: str,
assessments_config: AssessmentsSuiteConfig | dict,
experiment_id: str | None = None,
experiment_name: str | None = None,
) -> ExternalMonitor
パラメーター
パラメーター | Type | 説明 |
---|---|---|
|
| トレース・アーカイブ・テーブルが作成されるUnity Catalogカタログ名 |
|
| トレース アーカイブ テーブルが作成される Unity Catalog スキーマ名 |
|
| トレースに対して実行する評価スイートの構成 |
|
| モニターに関連付ける MLflow エクスペリメントの ID。 現在アクティブなエクスペリメントへのデフォルト |
|
| モニターに関連付けるMLflowエクスペリメントの名前。 デフォルトは現在アクティブなエクスペリメントです。 |
戻り値
ExternalMonitor
- エクスペリメント ID、設定、モニタリング URL を含む作成された監視オブジェクト
例
import mlflow
from databricks.agents.monitoring import create_external_monitor, AssessmentsSuiteConfig, BuiltinJudge, GuidelinesJudge
# Create a monitor with multiple scorers
external_monitor = create_external_monitor(
catalog_name="workspace",
schema_name="default",
assessments_config=AssessmentsSuiteConfig(
sample=0.5, # Sample 50% of traces
assessments=[
BuiltinJudge(name="safety"),
BuiltinJudge(name="relevance_to_query"),
BuiltinJudge(name="groundedness", sample_rate=0.2), # Override sampling for this scorer
GuidelinesJudge(
guidelines={
"mlflow_only": [
"If the request is unrelated to MLflow, the response must refuse to answer."
],
"professional_tone": [
"The response must maintain a professional and helpful tone."
]
}
),
],
),
)
print(f"Monitor created for experiment: {external_monitor.experiment_id}")
print(f"View traces at: {external_monitor.monitoring_page_url}")
get_external_monitor
Databricks の外部で提供されている 生成AI アプリケーションの既存のモニターを取得します。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import get_external_monitor
get_external_monitor(
*,
experiment_id: str | None = None,
experiment_name: str | None = None,
) -> ExternalMonitor
パラメーター
パラメーター | Type | 説明 |
---|---|---|
|
| モニターに関連付けられている MLflow エクスペリメントの ID |
|
| モニターに関連付けられている MLflow エクスペリメントの名前 |
戻り値
ExternalMonitor
- 取得したモニター・オブジェクト
以下を発生
ValueError
- experiment_idもexperiment_nameも提供しない場合NoMonitorFoundError
- 当該エクスペリメントのモニターが見つからない場合
例
from databricks.agents.monitoring import get_external_monitor
# Get monitor by experiment ID
monitor = get_external_monitor(experiment_id="123456789")
# Get monitor by experiment name
monitor = get_external_monitor(experiment_name="my-genai-app-experiment")
# Access monitor configuration
print(f"Sampling rate: {monitor.assessments_config.sample}")
print(f"Archive table: {monitor.trace_archive_table}")
update_external_monitor
既存のモニターの構成を更新します。構成は新しい値に完全に置き換えられます (マージされません)。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import update_external_monitor
update_external_monitor(
*,
experiment_id: str | None = None,
experiment_name: str | None = None,
assessments_config: AssessmentsSuiteConfig | dict,
) -> ExternalMonitor
パラメーター
パラメーター | Type | 説明 |
---|---|---|
|
| モニターに関連付けられている MLflow エクスペリメントの ID |
|
| モニターに関連付けられている MLflow エクスペリメントの名前 |
|
| 既存の設定を完全に置き換える更新された設定 |
戻り値
ExternalMonitor
- 更新されたモニター オブジェクト
以下を発生
ValueError
- assessments_configが提供されない場合
delete_external_monitor
Databricks の外部で提供されている 生成AI アプリケーションのモニターを削除します。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import delete_external_monitor
delete_external_monitor(
*,
experiment_id: str | None = None,
experiment_name: str | None = None,
) -> None
パラメーター
パラメーター | Type | 説明 |
---|---|---|
|
| モニターに関連付けられている MLflow エクスペリメントの ID |
|
| モニターに関連付けられている MLflow エクスペリメントの名前 |
例
from databricks.agents.monitoring import delete_external_monitor
# Delete monitor by experiment ID
delete_external_monitor(experiment_id="123456789")
# Delete monitor by experiment name
delete_external_monitor(experiment_name="my-genai-app-experiment")
設定クラス
AssessmentsSuiteConfig
生成AI アプリケーションからのトレースに対して実行される一連の評価の構成。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import AssessmentsSuiteConfig
@dataclasses.dataclass
class AssessmentsSuiteConfig:
sample: float | None = None
paused: bool | None = None
assessments: list[AssessmentConfig] | None = None
属性
属性 | Type | 説明 |
---|---|---|
|
| 0.0 (含まず) から 1.0 (両端を含む) までのグローバル サンプリング レート。個々の評価でこれを上書きできます |
|
| モニタリングが停止するかどうか |
|
| トレースで実行する評価のリスト |
メソッド
from_dict
ディクショナリ表現から AssessmentsSuiteConfig を作成します。
@classmethod
def from_dict(cls, data: dict) -> AssessmentsSuiteConfig
get_guidelines_judge
評価リストから最初の GuidelinesJudge を返すか、見つからない場合は None を返します。
def get_guidelines_judge(self) -> GuidelinesJudge | None
例
from databricks.agents.monitoring import AssessmentsSuiteConfig, BuiltinJudge, GuidelinesJudge
# Create configuration with multiple assessments
config = AssessmentsSuiteConfig(
sample=0.3, # Sample 30% of all traces
assessments=[
BuiltinJudge(name="safety"),
BuiltinJudge(name="relevance_to_query", sample_rate=0.5), # Override to 50%
GuidelinesJudge(
guidelines={
"accuracy": ["The response must be factually accurate"],
"completeness": ["The response must fully address the user's question"]
}
)
]
)
# Create from dictionary
config_dict = {
"sample": 0.3,
"assessments": [
{"name": "safety"},
{"name": "relevance_to_query", "sample_rate": 0.5}
]
}
config = AssessmentsSuiteConfig.from_dict(config_dict)
BuiltinJudge
トレースに対して実行される組み込みのジャッジの設定。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import BuiltinJudge
@dataclasses.dataclass
class BuiltinJudge:
name: Literal["safety", "groundedness", "relevance_to_query", "chunk_relevance"]
sample_rate: float | None = None
属性
属性 | Type | 説明 |
---|---|---|
|
| 組み込みのジャッジの名前。次のいずれかである必要があります: |
|
| この特定のジャッジのオプションのオーバーライドサンプリングレート(0.0〜1.0) |
利用可能な組み込みジャッジ
safety
- 応答に含まれる有害または有害なコンテンツを検出しますgroundedness
- レスポンスが取得したコンテキストに基づいているかどうかを評価します(RAGアプリケーション)relevance_to_query
- 応答がユーザーの要求に対応しているかどうかを確認しますchunk_relevance
- 取得した各チャンクの関連性を評価します(RAGアプリケーション)
GuidelinesJudge
カスタムビジネスルールを評価するためのガイドライン遵守ジャッジの設定。
# These packages are automatically installed with mlflow[databricks]
from databricks.agents.monitoring import GuidelinesJudge
@dataclasses.dataclass
class GuidelinesJudge:
guidelines: dict[str, list[str]]
sample_rate: float | None = None
name: Literal["guideline_adherence"] = "guideline_adherence" # Set automatically
属性
属性 | Type | 説明 |
---|---|---|
|
| ディクショナリのマッピング・ガイドライン名からガイドライン記述のリストへのマッピング |
|
| このジャッジのオプションのオーバーライドサンプリングレート(0.0〜1.0) |
例
from databricks.agents.monitoring import GuidelinesJudge
# Create guidelines judge with multiple business rules
guidelines_judge = GuidelinesJudge(
guidelines={
"data_privacy": [
"The response must not reveal any personal customer information",
"The response must not include internal system details"
],
"brand_voice": [
"The response must maintain a professional yet friendly tone",
"The response must use 'we' instead of 'I' when referring to the company"
],
"accuracy": [
"The response must only provide information that can be verified",
"The response must acknowledge uncertainty when appropriate"
]
},
sample_rate=0.8 # Evaluate 80% of traces with these guidelines
)
ExternalMonitor
Databricks の外部で提供される 生成AI アプリケーションのモニターを表します。
@dataclasses.dataclass
class ExternalMonitor:
experiment_id: str
assessments_config: AssessmentsSuiteConfig
trace_archive_table: str | None
_checkpoint_table: str
_legacy_ingestion_endpoint_name: str
@property
def monitoring_page_url(self) -> str
属性
属性 | Type | 説明 |
---|---|---|
|
| このモニターに関連付けられている MLflow エクスペリメントの ID |
|
| 実行中の評価の構成 |
|
| トレースがアーカイブされるUnity Catalogテーブル |
|
| MLflow UIでモニタリング結果を表示するためのURL |
次のステップ
- 本番運用 モニタリングの設定 -モニタリングを有効にするためのステップバイステップガイド
- 評価データセットの作成 - モニタリング結果を使用して品質を向上させる
- 事前定義スコアラーリファレンス - 利用可能な組み込みジャッジ