Regression Aware Inference with LLMs

Michal Lukasik, Harikrishna Narasimhan, Aditya Krishna Menon, Felix Yu, Sanjiv Kumar

Abstract

Large language models (LLMs) have shown strong results on a range of applications, including regression and scoring tasks. Typically, one obtains outputs from an LLM via autoregressive sampling from the model’s output distribution. We show that this inference strategy can be sub-optimal for common regression and scoring evaluation metrics. As a remedy, we build on prior work on Minimum Bayes Risk decoding, and propose alternate inference strategies that estimate the Bayes-optimal solution for regression and scoring metrics in closed-form from sampled responses. We show that our proposal significantly improves over baselines across datasets and models.

Introduction

When interacting with Large Language Models (LLMs), the standard approach for generating an answer is autoregressive sampling or greedy decoding. Mathematically, these methods aim to find the mode—the single most probable output—of the model's predictive distribution. While this "Exact Match" philosophy is highly effective for classification tasks or multiple-choice questions where an answer is either correct or incorrect, it often fails to capture the nuances of regression and scoring tasks.

In regression, the magnitude of error matters. For example, if a model is asked to predict a product rating on a scale of 1 to 5, a prediction of 4.1 is significantly better than a prediction of 1.0 if the true rating is 4.0. Standard greedy decoding is "metric-agnostic"; it selects the highest peak in the probability distribution regardless of how far that peak is from other high-probability regions. This can lead to sub-optimal performance on metrics like Mean Squared Error (MSE) or Mean Absolute Error (MAE), where being "close" is rewarded.

RAIL: Regression-Aware Inference

To bridge this gap, we introduce RAIL (Regression-aware Inference with LLMs). This method is built upon the decision-theoretic framework of Minimum Bayes Risk (MBR) decoding. Instead of simply picking the most likely candidate, MBR seeks the output that minimizes the expected risk (or maximizes expected utility) under the model's distribution for a specific evaluation metric.

The RAIL inference pipeline: from LLM forward pass to sampling and applying a decision rule.

The RAIL process, as illustrated above, consists of three primary stages:

  1. Sampling: Instead of a single greedy pass, the model generates a set of $K$ samples (typically 16 or more) from the output distribution.
  2. Closed-Form Decision Rules: For standard regression metrics, the optimal MBR solution can be calculated efficiently from these samples without complex optimization.
  3. Post-hoc Temperature Scaling: The authors introduce a weighting parameter ($\alpha$) to adjust the influence of sample probabilities. This allows for fine-tuning the "sharpness" of the distribution post-generation, avoiding the need for additional expensive LLM inference.

Optimal Rules for Different Metrics

A core contribution of RAIL is the derivation of simple, closed-form solutions for various problem types. By using samples to approximate the underlying distribution, we can identify the Bayes-optimal prediction for specific metrics.

Optimal decision rules for various problem types and metrics.

As detailed in the table above:

  • Regression (MSE): The optimal prediction is the mean of the samples.
  • Ordinal Regression (MAE): The optimal prediction is the median of the samples.
  • Ranking (AUC): The optimal score is the expected label under the distribution.

Key Insights and Experimental Results

The researchers evaluated RAIL across several benchmarks, including the Semantic Textual Similarity Benchmark (STSB) and US Amazon Reviews, using the PaLM-2 and FLAN-T5 model families.

The "Mode" is a Trap

In many regression scenarios, the most likely value (the mode) can actually be an outlier. For instance, if a model assigns a 40% probability to a rating of "5" but 30% each to "1" and "2", greedy decoding will select "5". However, the mean of this distribution (the RAIL solution for MSE) would be closer to "3", which represents a much safer and more accurate prediction given the model's overall uncertainty.

Sampling vs. Enumeration

One might assume that "scoring" every possible numerical value (e.g., 0.1, 0.2, ... 5.0) would yield better results. However, the authors found that sampling is superior. Sampling naturally concentrates computational effort on high-density regions where the model has actual "belief," whereas enumeration wastes resources on low-probability areas that do not contribute meaningfully to the final expectation.

Performance and Efficiency

RAIL consistently outperformed greedy decoding and "Self-Consistency" (taking the most frequent sample) across all tested tasks. For the PaLM-2 XXS model on STSB, RAIL reduced the Root Mean Squared Error (RMSE) from 1.078 to 1.028.

Crucially, this performance boost comes with minimal overhead. Because the input prompt (the "prefix") is typically much longer than the short numerical output, generating multiple samples is computationally inexpensive if the prefix activations are cached.

Conclusion

RAIL demonstrates that by simply changing how we interpret LLM outputs—moving from mode-seeking to metric-aware decoding—we can significantly improve performance on regression and scoring tasks. This approach is model-agnostic and requires no additional training, making it a powerful tool for deploying LLMs in real-world scoring applications. Future research may explore extending RAIL to more complex text-based metrics like BLEU or ROUGE.

Summary updated

BibTeX
@inproceedings{lukasik2024regression,
  author = {Michal Lukasik and Harikrishna Narasimhan and Aditya Krishna Menon and Felix Yu and Sanjiv Kumar},
  title = {{Regression Aware Inference with LLMs}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  url = {https://openreview.net/forum?id=MsFz2loDnr},
}
Figure