Advancing Sequential Numerical Prediction in Autoregressive Models

Xiang Fei, Jinghui Lu, Qi Sun, Hao Feng, Yanjie Wang, Wei Shi, An-Lan Wang, Jingqun Tang, Can Huang · DOI

Introduction

Autoregressive models, such as GPT and LLaMA, serve as the foundation for modern artificial intelligence. However, these models often exhibit a significant "blind spot" when processing numerical data. By treating numbers as arbitrary tokens within a large vocabulary, standard training objectives fail to account for the inherent ordinal and holistic properties of digits. This paper introduces Numerical Token Integrity Loss (NTIL), a novel loss function designed to teach models that numbers exist within a metric space, thereby improving performance in tasks ranging from mathematical reasoning to precise object detection.

The Limitations of Cross-Entropy

Most current models rely on Cross-Entropy (CE) loss, which treats every token as an independent category. This approach leads to two primary failures in numerical contexts:

  1. Ordinal Ignorance: To a CE-based model, predicting "2" when the target is "3" is considered just as incorrect as predicting "9." The model does not understand that "2" and "3" are numerically adjacent.
  2. Holistic Failure: Numbers are predicted token-by-token. A model might predict "1.01" instead of "0.98"; while the numerical values are close, the CE loss is high because the leading digits differ. Conversely, a model might produce a sequence that is "digit-accurate" but numerically nonsensical.
Comparison of Cross-Entropy (CE) and Earth Mover's Distance (EMD). CE (a, b) produces identical loss regardless of numerical proximity, whereas EMD (c, d) captures the ordinal relationship between digits.

The NTIL Framework

To address these limitations, NTIL optimizes numerical prediction at both the token and sequence levels.

Token-Level Ordinality

Instead of standard classification loss, NTIL utilizes a simplified version of Earth Mover’s Distance (EMD). EMD penalizes the model based on the actual distance between the predicted distribution and the ground truth on the number line (0-9). To further refine this, the authors implement Exponential Position-Based Weighting, which prioritizes the accuracy of leading digits (e.g., the "hundreds" place) over trailing ones, mimicking how humans prioritize numerical magnitude.

Sequence-Level Holistic Value

NTIL introduces a Differentiable Numerical Value Construction method. By using a Gumbel-softmax trick, the model can "assemble" individual digit tokens into a single numerical value during training. This allows for the application of global metrics:

  • Relative Deviation Metric: Penalizes the total difference between the predicted and actual values.
  • Magnitude Deviation Metric: Specifically targets errors in the order of magnitude (e.g., confusing 10 with 100).
Visualization of multi-token numerical optimization. NTIL optimizes the sequence of tokens to align the predicted probability densities with ground truth values across multiple time steps.

Experimental Evaluation

The researchers integrated NTIL into several state-of-the-art models, including LLaVA, Qwen, and PaliGemma. The loss function demonstrated consistent improvements across diverse benchmarks:

  • Clock Time Recognition: On the TIME dataset, LLaVA-1.5's mean error dropped from 8.52 minutes to 4.14 minutes.
  • Image Grounding: In tasks like RefCOCO, NTIL-trained models achieved higher precision in predicting bounding box coordinates, effectively "tightening" the boxes around target objects compared to CE-trained baselines.
  • Math Reasoning: NTIL provided a steady accuracy boost on GSM8k across various model sizes (2B to 8B parameters), suggesting better internal handling of arithmetic logic.

Discussion and Future Work

While NTIL represents a significant step forward, it introduces some computational overhead due to the complexity of EMD and sequence-level assembly. Additionally, the method currently requires digit-by-digit tokenization, which can conflict with modern tokenizers that merge multi-digit strings into single tokens. Future research will focus on making the weighting schemes more adaptive and extending the framework to handle complex tokenization patterns.

Ultimately, NTIL proves that treating digits as a metric space rather than a set of labels is essential for building models that truly understand the language of numbers.

Summary updated

BibTeX
@inproceedings{fei2025advancing,
  author = {Xiang Fei and Jinghui Lu and Qi Sun and Hao Feng and Yanjie Wang and Wei Shi and An-Lan Wang and Jingqun Tang and Can Huang},
  title = {{Advancing Sequential Numerical Prediction in Autoregressive Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=ShacedUZdE},
}
Figure