
Objective Function
The objective function is the computational rule that tells a computer program how well or poorly it is currently solving its task. It produces a single number, and during learning the program changes itself so that this number improves.
A learning computer program needs a measure of success. That is exactly what the objective function is: a computational rule that translates the current state of the program into a single number. This number indicates how far the program’s outputs are from what is desired. During learning, the program constantly adjusts its internal settings so that the number moves in the desired direction. Usually it is formulated as an error measure that should become as small as possible. You can think of it as a game’s score, except here low scores are good.
The objective function determines what the model actually learns
A model does not do what you wish it would do. It does what its objective function rewards. Whoever chooses the computational rule carelessly ends up with a program that optimizes right past the intended goal. One example: a system is supposed to detect fraud in payments, and only one in a thousand payments is fraudulent. If the objective function only counts the proportion of correct answers, then “never fraud” already achieves 99.9 percent. By its own standard, the system would be nearly perfect and practically useless.
This is why choosing the objective function embeds a value judgment. You determine which kind of error weighs how heavily. In credit assessment, a customer wrongly rejected is something different from a loan wrongly approved. Both errors can be weighted differently. These weights are not mathematics but a decision made by the company.
Experts call this problem misalignment of incentives, or in English “reward hacking.” The model finds a way to improve the number without actually solving the intended task. A chatbot optimized only for user approval learns to flatter instead of to disagree. This is not a defect but the logical consequence of the chosen rule.
From error value to a better model
Modern AI models contain billions of adjustable numbers called parameters. At the start they are set randomly, and the outputs are nonsense. Training then proceeds in rounds. The model processes sample data, the objective function computes the error value, and afterward all parameters are adjusted by a tiny amount.
The direction of this adjustment is provided by the derivative of the objective function. For each parameter, it indicates whether an increase makes the error larger or smaller. This procedure is called gradient descent. A vivid image: you are standing in the mountains in fog and want to get to the valley. You feel with your foot where it slopes downward, and take a small step in that direction. Millions of such steps later, you find yourself far below.
For this feeling-around to be possible at all, the objective function must be mathematically smooth. Abrupt measures like “answer right or wrong” give no direction. That is why substitute measures are used that increase continuously the further the output is off the mark. In language models, this is usually the question of how probable the model considered the actual next word to be.
Where objective functions show up in products and headlines
Every recommendation system has an objective function. For video platforms, watch time — that is, the time users spend in the app — was long the target. This very choice has come under criticism because it favors exciting and polarizing content. Several providers have therefore restructured their target metrics, for example toward ratings given by users after watching.
The term also comes up in the world of finance, often under the name optimization target. A trading algorithm does not simply maximize profit but usually profit adjusted for risk. In news about language models, the objective function appears during fine-tuning: in so-called reinforcement learning from human feedback, humans rate responses, and a target measure is built from these ratings.
A common misconception is to equate the objective function with accuracy. Accuracy is a metric for humans, reported at the end. The objective function is what the program actually steers by during training. The two rarely coincide, and it is precisely in this gap that most unexpected behaviors of AI systems arise.