Objective function

An objective function is the quantity a model or algorithm is set up to optimise, minimised when it measures error and maximised when it measures something desirable such as reward.

Every optimisation problem needs a definition of better, and the objective function supplies it. Google's machine learning glossary defines it as the formula or metric a model aims to optimise. When training a linear regression model, the objective is usually mean squared error, and training tries to minimise it. When the objective is something good, such as accuracy, the goal is to maximise it instead.

That makes a loss function one kind of objective function. Wikipedia puts the relationship neatly: an objective function is either a loss function or its opposite, which in different fields goes by names such as reward function, profit function, utility function or fitness function. Reinforcement learning maximises reward; evolutionary algorithms maximise fitness; supervised learning minimises loss.

In machine learning the objective is often more than the raw error. A common training objective is the loss plus a regularisation term, weighted by a setting usually written as lambda, which penalises complexity to stop the model fitting its training data too closely. Labs also experiment with the objective itself. Language models are normally pre-trained to predict the next token, but DeepSeek's V3 report from December 2024 describes adding a multi-token prediction objective, in which the model is also trained to predict tokens further ahead.

Choosing the objective is where people's goals get turned into maths, and that translation is rarely perfect. Wikipedia notes that the economist Ragnar Frisch highlighted the difficulty of capturing a decision maker's preferences as a single number suitable for optimisation. Machine learning faces the same problem: a model gets very good at whatever its objective measures, which is not always what its designers meant. Reward hacking and specification gaming are names for exactly this gap between the objective and the intended goal.

Common questions

What is the difference between an objective function and a loss function?

A loss function measures error and is always minimised. An objective function is the general term for whatever is being optimised, which can be a loss to minimise or a reward, profit or accuracy to maximise. In machine learning the training objective is often a loss plus extra terms such as a regularisation penalty.

Is the objective function always minimised?

No. Whether it is minimised or maximised depends on what it measures. Errors and costs are minimised, while rewards, likelihoods and fitness scores are maximised. Mathematically the two are interchangeable, since maximising a function is the same as minimising its negative.

What is the training objective of a large language model?

During pre-training it is usually next-token prediction: the model is scored on how much probability it gives to the actual next token in real text. Later stages can use other objectives, such as matching human-written examples during fine-tuning or maximising a reward signal during reinforcement learning.

What is the difference between an objective and a metric?

An objective is what training directly optimises. A metric is any measurement used to judge a model, and many metrics are never optimised directly. A model might be trained to minimise cross-entropy loss while being judged on accuracy or human ratings.

Finding more

Search for "objective function machine learning", "loss vs objective function" or "training objective language model" to see how objectives are defined. Reliable sources include Google's Machine Learning Glossary, textbooks on optimisation and statistical learning, and technical reports from labs that describe their training objectives. When a paper or announcement mentions a new training objective, look for evidence that it improves results on tasks beyond the one it was designed for.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.