Measuring Language Model Utility When Errors Have Different Costs
As language models are increasingly deployed in real-world scenarios with important outcomes, their mistakes can have consequences that correctness alone does not capture. A minor error in a low-stakes question and a dangerous error in medical advice should not carry the same practical significance. We therefore propose a utility-based evaluation paradigm that explicitly incorporates the varying consequences of errors, encouraging more responsible model behavior. As an early trial of this paradigm, we construct UtilityBench with continuous, sample-specific consequence annotations and introduce UtilityAUC.
This repository provides the response evaluator, UtilityAUC implementation, and an end-to-end demo.
Prepare two models accessible through OpenAI-compatible Chat Completions APIs:
- Model under evaluation: generates answers to the benchmark prompts.
- Enhanced judge: evaluates those answers alongside local rules and code tests.
Use Python 3.10+ and install dependencies from the repository root:
python -m pip install datasets sympyConfigure both models at the top of demo.py:
# Model under evaluation
MODEL_CONFIG = {
"provider": "openai",
"base_url": "https://YOUR_MODEL_API_HOST/v1",
"model": "YOUR_MODEL",
"api_key_env": "API_KEY",
"timeout_seconds": 180,
"request_params": {
# "thinking": {"type": "enabled"}, # Or "disabled", if supported.
},
}
# Enhanced judge
JUDGE_CONFIG = {
"provider": "openai",
"base_url": "https://YOUR_JUDGE_API_HOST/v1",
"model": "YOUR_JUDGE_MODEL",
"api_key_env": "JUDGE_API_KEY",
"timeout_seconds": 180,
"request_params": {
# "thinking": {"type": "enabled"}, # Configure the judge independently.
},
}Set the environment variables named by each api_key_env (API_KEY and JUDGE_API_KEY above). Use base URLs without /chat/completions. Set thinking mode and other provider-specific request options through request_params, use the format documented by your provider.
The dataset is loaded from leiqf/UtilityBench on Hugging Face by default.
Set LIMIT to the number of prompts to evaluate (50 by default, or None for the full benchmark), and adjust CONCURRENCY as needed. Then run:
python demo.pyUtilityBench/
├── demo.py # Model inference, evaluation, and metric computation
├── evaluator/ # Response evaluation: rules, code tests, and API judge
├── metric/utilityauc.py # UtilityAUC and summary metrics
└── asset/ # README figures
The dataset contains 15,000 records in a single test split.
| Field | Type | Description |
|---|---|---|
id |
int64 | Unique record identifier |
input |
string | Full prompt sent to the model |
answerability |
int8 | 1 = answerable; 0 = refusal required |
reference_answer |
string / null | Reference answer; null for refusal-required prompts |
source_id |
string | Source dataset and item identifier |
eta |
float64 | Relative error-consequence score; higher means greater consequences |
L |
float64 | Positive cost of an incorrect answer |
evaluator_id |
string | Evaluation rule or code-test identifier |
compute_utility_auc in metric/utilityauc.py returns:
| Field | Description |
|---|---|
utility_auc |
Normalized area under the utility–coverage curve; higher is better |
answer_rate |
Fraction of responses that attempt an answer |
answerable_accuracy |
Correct attempted answers divided by all answerable records |
refusal_required_accuracy |
Non-answer responses divided by all refusal-required records |
record_count |
Number of evaluated records |
The two accuracy fields return None when the evaluated records contain no prompts of the corresponding type.
UtilityBench builds on 18 source datasets. We thank their authors for making these resources publicly available. Record-level provenance is preserved in source_id.
If you find this work useful, please consider citing our paper:
@misc{lei2026utilitybench,
author = {Qifeng Lei and Zhiyong Yang and Zitai Wang and Shilong Bao and Linchao Zhang and Qianqian Xu and Qingming Huang},
title = {{UtilityBench}: Measuring Language Model Utility When Errors Have Different Costs},
year = {2026},
eprint = {2610.25924},
archiveprefix = {arXiv},
}If you encounter any problems using the code or evaluating your models, please open an issue in this repository.