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,
            ),
        },
    )
 
frustration = result.answers["frustration"]
print(frustration.interval)                 # (1.0, 2.0)
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.0, 2.0],
    "legend": { "0": "Calm", "1": "Frustrated", "2": "Very angry" },
    "guarantee": {
      "type": "coverage",
      "alpha": 0.10,
      "method": "CQR",
      "calibration_profile": "frustration-rubric-v1",
      "calibration_n": 640
    }
  }
}

Levels are indexed from 0 in the order you list them; legend maps each index back to its name.

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 a regression or ordinal score (CQR, conformalized quantile regression, or an ordinal-APS variant for discrete rubrics), 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. The offline equivalent is cli_sdk.stats.conformal.cqr.

Answer attributes

AttributeTypeMeaning
intervaltuple[float, float]The 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 chosen from the profile’s data type.