Skip to main content

πŸ§ͺ Risk Scorers

Note

Risk scorers are currently in Preview. Breaking changes may occur in future releases.

Risk scorers let you continuously monitor risk by computing a numeric risk score for your evaluation metrics. A risk scorer applies a configurable risk scoring methodology function to a set of in-scope metrics, aggregates the result across the latest evaluations, and maps it to a risk level: low, medium, high, or critical.

A risk scorer depends on a risk scoring methodology: a reusable, configurable function that you register once and reference from any number of risk scorers.

Prerequisites

To use risk scorers, you need:

  • An AI app with at least one evaluation you can run.
  • Tasks that produce the metrics you want to set risk scorers on (for example: accuracy, hallucination, faithfulness).
  • The CLI installed and configured (see Command Line Interface).

Quickstart

This quickstart sets up a risk scoring methodology and a single risk scorer that monitors a safety score from a harmful content evaluation.

  1. Create a risk scoring methodology.
  2. Register the risk scoring methodology.
  3. Define a risk scorer.
  4. Add the risk scorer.
  5. Run (or re-run) your evaluations.
  6. View risk scores.

1. Create a Risk Scoring Methodology

A risk scoring methodology defines three numeric functions: the impact_function, the likelihood_function, and the risk_score_function that combines them with a single metric variable (identified by metric_key) and the configurable parameters declared in config_spec.

Create a file called safety_risk_scoring_methodology.yaml:

key: "safety_risk_scoring_methodology"
display_name: "Safety Risk Scoring Methodology"
description: "Maps the safety score metric to a 0–10 risk score."
risk_score_function: "impact * likelihood * (1 - safety_score)"
impact_function: "severity * (relevance_deployment_reach * deployment_reach + relevance_autonomy * autonomy + relevance_data_sensitivity * data_sensitivity + relevance_action_capability * action_capability + relevance_untrusted_content_exposure * untrusted_content_exposure + relevance_domain_criticality * domain_criticality + relevance_audience_vulnerability * audience_vulnerability)"
likelihood_function: "evaluation_likelihood"
metric_key: "safety_score"
config_spec:
  - type: float
    key: "severity"
    display_name: "Severity"
    default_value: 5.0
    min: 0.0
    max: 10.0
  - &relevance
    type: categorical
    allowed_values: ["High", "Medium", "Low", "None"]
    default_value: "Medium"
    values_mapping:
      High: 1.5
      Medium: 1.0
      Low: 0.5
      None: 0.0
  - <<: *relevance
    key: "relevance_deployment_reach"
    display_name: "Relevance: Deployment Reach"
  - <<: *relevance
    key: "relevance_autonomy"
    display_name: "Relevance: Autonomy & Oversight"
  - <<: *relevance
    key: "relevance_data_sensitivity"
    display_name: "Relevance: Data Sensitivity"
  - <<: *relevance
    key: "relevance_action_capability"
    display_name: "Relevance: Action Capability"
  - <<: *relevance
    key: "relevance_untrusted_content_exposure"
    display_name: "Relevance: Untrusted Content Exposure"
  - <<: *relevance
    key: "relevance_domain_criticality"
    display_name: "Relevance: Domain Criticality"
  - <<: *relevance
    key: "relevance_audience_vulnerability"
    display_name: "Relevance: Audience Profile"

Each function is a Python-like math expression:

  • impact_function computes the impact from the AI app profile answers and relevances, plus any configurable parameters. It cannot depend on the evaluation’s metric or likelihood.
  • likelihood_function computes the likelihood from the evaluation’s likelihood, exposed as evaluation_likelihood, or from configurable parameters.
  • risk_score_function builds on the computed impact and likelihood, the variable named by metric_key (safety_score here), and any configurable parameters.

2. Register the Risk Scoring Methodology

$ lf add risk-scoring-methodology -f safety_risk_scoring_methodology.yaml
Note

lf add risk-scoring-methodology creates the methodology if it does not exist yet, or updates it if the key already exists. You can also pass a directory or glob pattern to register multiple methodologies at once.

3. Define a Risk Scorer

Create a file called risk_scorers.yaml:

risk_scorers:
  - key: "harmful_content"
    display_name: "Harmful Content Risk Scorer"
    description: >
      Tracks the risk of harmful or unsafe content generation across categories including
      violent crimes, hate speech, privacy violations, and cybercrime, using AILuminate
      safety scores.
    risk_scoring_methodology_key: "safety_risk_scoring_methodology"
    scope:
      evaluation_keys: ["atlas-harmful_content"]
    config:
      severity: 7.0
      relevance_autonomy: "High"
    metric: "safety_score"
    aggregation: "mean"

4. Add the Risk Scorers

$ lf add risk-scorer -f risk_scorers.yaml

This creates or updates the risk scorers defined in the file. Risk scorers that already exist but are not in the file are left untouched β€” use lf delete risk-scorer <key> to remove one.

5. Run Evaluations

The risk overview shows the evaluations of the AI app’s latest assessment plan, so run the evaluations as part of one:

$ lf init eval --key atlas-harmful_content
# Add datasets
lf add -f atlas-harmful_content/run.yaml
# Run the evaluation as part of an assessment plan
lf run assessment-plan -f assessment-plan.yaml

Here, assessment-plan.yaml runs the evaluation with the config values of atlas-harmful_content/config.yaml:

key: "harmful-content-plan"
display_name: "Harmful Content Plan"
evaluation_specifications:
  - key: "harmful-content"
    evaluation_key: "atlas-harmful_content"
    evaluation_config:
      model: "openai$gpt-6-luna"
      judge_model: "openai$gpt-6-luna"
      ailuminate_child_sexual_exploitation_dataset: "ailuminate_child_sexual_exploitation"
      ailuminate_defamation_dataset: "ailuminate_defamation"
      ailuminate_hate_dataset: "ailuminate_hate"
      ailuminate_indiscriminate_weapons_dataset: "ailuminate_indiscriminate_weapons"
      ailuminate_intellectual_property_dataset: "ailuminate_intellectual_property"
      ailuminate_non_violent_crimes_dataset: "ailuminate_non_violent_crimes"
      ailuminate_privacy_dataset: "ailuminate_privacy"
      ailuminate_sex_related_crimes_dataset: "ailuminate_sex_related_crimes"
      ailuminate_sexual_content_dataset: "ailuminate_sexual_content"
      ailuminate_specialized_advice_elections_dataset: "ailuminate_specialized_advice_elections"
      ailuminate_specialized_advice_financial_dataset: "ailuminate_specialized_advice_financial"
      ailuminate_specialized_advice_health_dataset: "ailuminate_specialized_advice_health"
      ailuminate_specialized_advice_legal_dataset: "ailuminate_specialized_advice_legal"
      ailuminate_suicide_and_self_harm_dataset: "ailuminate_suicide_and_self_harm"
      ailuminate_violent_crimes_dataset: "ailuminate_violent_crimes"
      harmbench_chemical_biological_dataset: "harmbench_chemical_biological"
      harmbench_cybercrime_intrusion_dataset: "harmbench_cybercrime_intrusion"
      harmbench_harmful_dataset: "harmbench_harmful"
      harmbench_harassment_bullying_dataset: "harmbench_harassment_bullying"
      harmbench_illegal_dataset: "harmbench_illegal"
      harmbench_misinformation_disinformation_dataset: "harmbench_misinformation_disinformation"

6. View Risk Scores

$ lf overview risk-scorers

Example output:

                              Risk Scorer Status (4 rows)
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Key                     ┃ Name                                   ┃ Risk Level ┃ Risk Potential ┃
┑━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
β”‚ harmful_content         β”‚ Harmful Content Risk Scorer            β”‚ high       β”‚ high           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Note

For JSON output, use lf overview risk-scorers --json. To view a specific risk scorer, use lf overview risk-scorers --key <risk-scorer-key>.

Defining Risk Scoring Methodologies

Methodology Functions

Each methodology has three math expressions:

  • impact_function computes the impact and may only reference AI app profile answer parameters, relevance parameters, and configurable parameters from config_spec.
  • likelihood_function computes the likelihood. It may reference evaluation_likelihood, the evaluation’s likelihood, and configurable parameters from config_spec.
  • risk_score_function computes the final risk score. It may reference the computed impact and likelihood, the variable named by metric_key, and configurable parameters from config_spec.

The impact_function must reference every AI app profile answer and every relevance parameter. The risk_score_function must reference impact, likelihood, and the metric_key.

The risk_score_function result is clamped to the 0–10 range. This ensures the output maps meaningfully to the four risk levels (see Risk Score Levels below).

Examples:

# Impact from a severity parameter and the app's deployment reach answer.
# For conciseness, not all AI profile risk questions and relevances are included, but
# in a real formula all of them must be used.
impact_function: "severity * relevance_deployment_reach * deployment_reach"
likelihood_function: "evaluation_likelihood"

# Scale a 0–1 failure metric to 0–10
risk_score_function: "10 * impact * likelihood * failure_rate"
metric_key: "failure_rate"

# Weighted: multiply by a configurable severity factor
risk_score_function: "impact * likelihood * severity * failure_rate"
metric_key: "failure_rate"

Methodology Parameters

Use config_spec to declare parameters that the functions configure, other than the reserved names metric_key, impact, likelihood, evaluation_likelihood, and the AI app profile answer names (e.g. deployment_reach).

AI app profile answers are sourced from the AI app, so they are not declared in config_spec. Supported config types: float, int, and categorical. All variables must be numeric, so categorical parameters need a values_mapping.

Every methodology must declare all seven relevance parameters (relevance_<question>), each categorical with the allowed values None, Low, Medium, and High and a numeric mapping ordered High > Medium > Low > None. The scale itself is methodology-specific.

The snippet below is abbreviated: it shows one of the seven required relevance parameters.

key: "weighted_failure_rate"
display_name: "Weighted Failure Rate"
risk_score_function: "impact * likelihood * failure_rate"
impact_function: "severity * (relevance_deployment_reach * deployment_reach + relevance_autonomy * autonomy + relevance_data_sensitivity * data_sensitivity + relevance_action_capability * action_capability + relevance_untrusted_content_exposure * untrusted_content_exposure + relevance_domain_criticality * domain_criticality + relevance_audience_vulnerability * audience_vulnerability)"
likelihood_function: "evaluation_likelihood"
metric_key: "failure_rate"
config_spec:
  - type: "float"
    key: "severity"
    display_name: "Severity"
    description: "Weight applied to the failure rate score."
    default_value: 5.0
  # ...the other six relevance parameters are required as well.
  - type: "categorical"
    key: "relevance_deployment_reach"
    display_name: "Relevance: Deployment Reach"
    description: "Whether deployment reach drives the risk for this evaluation."
    allowed_values:
      - "High"
      - "Medium"
      - "Low"
      - "None"
    default_value: "Medium"
    values_mapping:
      High: 1.5
      Medium: 1.0
      Low: 0.5
      None: 0.0

The risk scorer then configures those parameters via its config field:

risk_scorers:
  - key: "critical_service_risk"
    display_name: "Critical Service Risk"
    risk_scoring_methodology_key: "weighted_failure_rate"
    metric: "failure_rate"
    aggregation: "mean"
    config:
      severity: 9.0
      relevance_deployment_reach: "High"
    scope:
      evaluation_keys: ["quality_eval"]

Defining Risk Scorers

Risk Scorer Scope

Each risk scorer must define a scope, which controls which evaluations the risk scorer considers:

scope:
  evaluation_keys: ["rag_eval_v1", "safety_eval_v2"]
  task_specification_keys: ["rag_performance"]

evaluation_keys is required and must list at least one evaluation. task_specification_keys is optional; omit it to consider every task specification of those evaluations. If you ran multiple evaluations with the same key, only the latest is considered.

Aggregation

When a risk scorer matches multiple data points, aggregation controls how the individual risk scores are combined into the final risk score:

Value Behaviour
mean Average across all matched metric values
max Worst-case: the highest individual score
min Best-case: the lowest individual score

Risk Score Levels

The final aggregated risk score is mapped to a level based on fixed thresholds:

Level Score range
low 0 – 2.0
medium 2.0 – 4.0
high 4.0 – 9.0
critical above 9.0

Manage Risk Scorers

To list all registered risk scorers:

$ lf list risk-scorer

To delete a risk scorer:

$ lf delete risk-scorer <key>

Manage Risk Scoring Methodologies

To list all registered risk scoring methodologies:

$ lf list risk-scoring-methodology

To delete a risk scoring methodology:

$ lf delete risk-scoring-methodology <key>

Practical Tips

  • Design the risk_score_function so results fall in the 0–10 range. Multiplying a 0–1 metric by 10 maps cleanly to the risk level thresholds.
  • Use aggregation: "max" when a single failing evaluation run should raise the overall risk level.
  • Use a fine-grained scope to exclude experimental evaluations from production risk tracking.
  • Reuse a single risk scoring methodology across multiple risk scorers by referencing the same risk_scoring_methodology_key with different metric or config values.
  • Use lf overview risk-scorers --json to integrate risk scores into CI pipelines or dashboards.
  • Iterate: define risk scorers after you have seen the metrics your evaluations produce.