Skip to main content
TrustifAI can log metric scores to MLflow as part of every evaluation. Offline metric scores (evidence coverage, epistemic consistency, semantic drift, source diversity) are logged under the offline/ prefix, and the online confidence score from Trustifai.generate() is logged under online/. Tracing is optional and disabled by default — your evaluation pipeline works identically with or without it.

Installation

MLflow tracing requires the trace optional extra:
This installs mlflow alongside the core TrustifAI package. Without it, the tracing code path is silently skipped even if enabled: true is set in your config.

Enabling tracing in config_file.yaml

Set enabled: true in the tracing section and point tracking_uri at your MLflow server:
If tracking_uri is null or omitted, MLflow defaults to a local ./mlruns directory in your working directory — useful for local development without a running server.

What gets logged

TrustifAI uses mlflow.set_tag to log metric data as run tags on the active MLflow run.

Offline metrics (get_trust_score)

When you call get_trust_score, TrustifAI logs each active metric score and the final decision as tags:

Online metrics (generate)

When you call Trustifai.generate(), the confidence score is logged as a tag:

Using tracing inside an MLflow run

TrustifAI logs to the currently active MLflow run. Start a run using the standard mlflow.start_run() context manager before calling get_trust_score or generate:
You can log additional parameters and artifacts alongside TrustifAI’s automatic logs:

Batch evaluation with tracing

When running evaluate_dataset, each evaluation is a separate Trustifai.get_trust_score call. To log each row to its own MLflow run, wrap the batch in a parent run and create child runs per item:
If no MLflow run is active when get_trust_score is called, TrustifAI skips logging silently. You must start a run explicitly with mlflow.start_run() for metrics to appear in the UI.

Starting a local MLflow server

For local development, start the MLflow tracking server with:
Then set tracking_uri: "http://localhost:5000" in your config. Open http://localhost:5000 in a browser to view experiments, compare runs, and inspect logged metrics.

Disabling tracing

Tracing is disabled by default. To disable it explicitly or to turn it off in an environment where MLflow is not available:
You can also omit the tracing section entirely — TrustifAI treats a missing section as disabled.
If enabled: true but trustifai[trace] is not installed, TrustifAI catches the ImportError and skips logging rather than raising an exception. Install trustifai[trace] to activate tracing.

Configuration

See the full config_file.yaml reference including the tracing section.

Batch evaluation

Run large-scale evaluations and log aggregate results to MLflow.