PrimitivesInterval

Interval

Rate the context along an ordinal or continuous rubric, and get back a conformalized interval with a coverage guarantee, alongside a point estimate — instead of a single probability-weighted score with no stated error bound.

Request

from cli_sdk import AzureOpenAIBackend, CLIClient, Interval
 
with CLIClient() as client:
    result = client.evaluate(
        context={"ticket": "This is the third time this has happened. Fix it."},
        backend=AzureOpenAIBackend(model="gpt-4.1", deployment="support-gpt41"),
        queries={
            "frustration": Interval(
                instructions="How frustrated is the customer?",
                levels=["Calm", "Frustrated", "Very angry"],
                calibration_profile="frustration-rubric-v1",
                alpha=0.10,
                method="CQR",
            ),
        },
    )
 
frustration = result.answers["frustration"]
print(frustration.interval)                 # (1, 2)
print(frustration.point_estimate)           # 1.6
print(frustration.contains(2))              # True
print(frustration.legend[str(int(frustration.interval[1]))])   # 'Very angry'

Response

{
  "frustration": {
    "type": "interval",
    "point_estimate": 1.6,
    "interval": [1, 2],
    "levels": ["Frustrated", "Very angry"],
    "legend": { "0": "Calm", "1": "Frustrated", "2": "Very angry" },
    "guarantee": {
      "type": "coverage",
      "alpha": 0.10,
      "method": "CQR",
      "statement": "The interval contains the true level with probability at least 90% (conformalized quantile regression over levels, n=640).",
      "calibration_profile": "frustration-rubric-v1",
      "calibration_n": 640,
      "coverage_ci": [0.874, 0.924],
      "profile_version": 1,
      "stats_version": "cci-sdk/0.1.1+hosted.1"
    }
  }
}

Levels are indexed from 0 in the order you list them; legend maps each index back to its name, and levels names the two ends of the interval.

How it differs from a plain probability-weighted score

A probability-weighted average across rubric levels can land between levels with no stated error bound on where the true rating falls. Interval instead conformalizes the model’s probabilities over the levels, so intervals produced this way contain the true rating at least 1−α1-\alpha of the time over exchangeable inputs, calibrated on your own labelled examples. Two methods:

methodHow the interval is builtWhere
ordinal-aps (default)An adaptive-prediction-set score over the ordered levels, grown into a contiguous rangeHosted service and local mode
CQRConformalized quantile regression on the model’s distribution over level indices: take its α/2\alpha/2 and 1−α/21-\alpha/2 quantiles qloq_{lo} and qhiq_{hi}, score each calibration example with true level yy by max⁡(qlo−y, y−qhi)\max(q_{lo} - y,\ y - q_{hi}), and widen the quantile range by the conformal quantile q^\hat{q} of those scores: [qlo−q^, qhi+q^][q_{lo} - \hat{q},\ q_{hi} + \hat{q}], clipped to the levelsHosted service

CQR adapts the width to how spread out the model’s own distribution is, so confident ratings get narrow intervals and ambiguous ones wide intervals; ordinal-aps is the default because it needs no assumption about the shape of that distribution. Both carry the same coverage guarantee. The offline engine’s cli_sdk.stats.conformal.cqr is CQR for continuous predictions.

Answer attributes

AttributeTypeMeaning
intervaltupleThe conformalized interval, in level indices
point_estimatefloatThe point estimate
legenddict[str, str]Level index (as a string) to level name
widthfloatinterval[1] - interval[0]
contains(value)boolWhether value lies in the closed interval
guarantee, is_heuristicThe guarantee card, and whether it is heuristic

Parameters

ParameterTypeDescription
instructionsstr | dict | listRequired. What to rate.
levelslist[str]Required. Ordered rubric levels, 2 to 10 entries.
calibration_profilestrRequired.
alphafloat, optionalTarget miscoverage rate.
method"CQR" | "ordinal-aps", optionalDefault "ordinal-aps". CQR is available on the hosted service.