Utility Function

Utility Function

A utility function is a computational rule that assigns a number to every possible outcome, thereby indicating how good that outcome is. Machines and programs use it to decide between courses of action, because it allows them to directly compare different outcomes.

A utility function is a computational rule that assigns a number to every possible outcome. This number expresses how desirable the outcome is: the higher, the better. The term originates from economics, but today it is used above all in computer programs that make decisions themselves. An example: a delivery service rates every possible route with a number derived from driving time, fuel costs, and punctuality. The program then chooses the route with the highest number. The point of this is that completely different things — minutes, euros, satisfaction — can be compared on a single scale.

Why machines need a number in order to choose

A computer cannot weigh things up the way a human does. It can only calculate and compare. For a program to make a choice, all options must lie on the same scale. That is exactly what the utility function achieves: it translates goals into numbers.

This forces an uncomfortable honesty. Whoever writes a utility function must specify how much a minute of time saved is worth compared to a euro of cost. Humans like to avoid making such determinations. A program cannot — some ratio always ends up in the formula in the end.

That is why the utility function is often the most important design decision of a system. It determines what the system actually works toward. Whoever formulates it poorly ends up with a program that fulfills its specification perfectly and yet does something nonsensical. Experts call this misaligned incentives or specification gaming.

From the formula to the decision

In the simplest case, a utility function is a weighted sum. You take several measured values, multiply each by a weight, and add everything up. A streaming service might calculate: utility equals two times expected viewing time minus one times loading time. The weights determine what matters more to the operator.

Usually, however, the outcome of an action is uncertain. In that case one calculates with the expected value: you multiply the utility of each possible outcome by its probability and add up the results. A lottery ticket for two euros has a positive payout only in a very unlikely case. Averaged over all cases, its expected utility is negative. That is why a purely calculating system would not play.

In AI, the same principle appears under other names. In reinforcement learning, where a program improves through trial and error, the evaluation rule is called a reward function. It gives a point value after each action, and the program searches for the strategy with the highest total points. Also related is the loss function used in training neural networks — except it measures error instead of utility, so it is minimized rather than maximized.

Utility functions in products and in the debate on AI safety

Every recommendation that an online shop or a video platform shows you is, in the end, the result of such an evaluation. The system estimates a value for many candidates and shows the best ones. Trading systems on the stock exchange, route planners, and ad auctions also work this way. When business news reports that a platform has changed its algorithm, this usually refers to the weights in this formula.

Much of the criticism hinges on exactly this. If a platform optimizes primarily for dwell time, the formula rewards exciting and polarizing content. That was not the goal, but it is the consequence of the chosen number. A utility function always measures only what is measurable — not necessarily what matters.

In the discussion about safe AI, the term plays a central role. The question of whether human values can even be fully translated into a utility function at all is unresolved. A common misconception, by the way, is that large language models have such a function built in. They initially only predict probable words. Only post-training procedures with human feedback bring an explicit evaluation into play.

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.