Abstract
Large language models (LLMs) have demonstrated strong results on a range of NLP tasks. Typically, outputs are obtained via autoregressive sampling from the LLM's underlying distribution. Building on prior work on Minimum Bayes Risk Decoding, we show that this inference strategy can be suboptimal for a range of regression and scoring tasks, and associated evaluation metrics. As a remedy, we propose metric aware LLM inference: a decision theoretic approach optimizing for custom regression and scoring metrics at inference time. We report improvements over baselines on academic benchmarks and publicly available models.
Introduction
Standard Large Language Model (LLM) inference typically relies on "greedy decoding" or "argmax" sampling. These methods are designed to find the single most probable sequence of tokens—the mode of the distribution. While effective for tasks where Exact Match (EM) accuracy is the primary goal, this approach is often suboptimal for regression and scoring tasks. In applications such as predicting star ratings or sentence similarity, the distance between the prediction and the ground truth matters. For metrics like Mean Squared Error (MSE) or Mean Absolute Error (MAE), the mode is a poor estimator compared to the mean or median of the model's internal distribution.
Methodology: Regression-aware Inference with LLMs (RAIL)
We propose RAIL (Regression-aware Inference with LLMs), a framework that applies principles of Minimum Bayes Risk (MBR) decoding to regression tasks. Unlike traditional MBR, which can be computationally prohibitive for open-ended text, RAIL simplifies the process for scoring tasks using closed-form statistical rules.
The RAIL process involves four key stages:
- Sampling: Generating $K$ candidate responses (e.g., 8–16 samples) from the LLM.
- Probability Estimation: Extracting the likelihood scores the model assigned to each sample.
- Post-hoc Temperature Scaling: Applying a scaling factor to calibrate the model’s confidence levels.
- Closed-form Decision Rules: Applying a specific mathematical rule based on the target metric. For example, to minimize Root Mean Squared Error (RMSE), we use the weighted mean of the samples; to minimize Mean Absolute Error (MAE), we use the weighted median.
Experimental Results
RAIL was evaluated across several benchmarks, including the Semantic Textual Similarity Benchmark (STSB) and US Amazon Reviews. The results demonstrate that RAIL consistently outperforms greedy decoding and standard self-consistency (majority vote) across various model sizes.
As shown in the table above, the most significant improvements are observed in smaller models (e.g., PaLM-2 XXS), where the model's distribution is less concentrated. For instance, on the STSB dataset, using the RAIL mean reduced the RMSE for PaLM-2 XXS from 1.078 to 1.028. Most of the performance gains were realized with just 8 to 16 samples, indicating that RAIL is an efficient alternative to standard inference for scoring tasks.
Conclusion
RAIL provides a robust decision-theoretic approach to LLM inference for regression. By shifting focus from the most likely answer to the statistically optimal answer for a given metric, we can achieve better performance without changing the underlying model weights. Future work will investigate the application of RAIL to more complex, multi-variate scoring scenarios.
Summary updated