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

Abstract

Autoregressive models have become the de facto choice for sequence generation tasks, but standard approaches treat digits as independent tokens and apply cross-entropy loss, overlooking the coherent structure of numerical sequences. This paper introduces Numerical Token Integrity Loss (NTIL) to address this gap. NTIL operates at two levels: (1) token-level, where it extends the Earth Mover's Distance (EMD) to preserve ordinal relationships between numerical values, and (2) sequence-level, where it penalizes the overall discrepancy between the predicted and actual sequences. This dual approach improves numerical prediction and integrates effectively with LLMs/MLLMs. Extensive experiments show significant performance improvements with NTIL.

Introduction

Standard Large Language Models (LLMs) and Multimodal Large Language Models (MLLMs) typically generate text token-by-token. When processing numbers, these models treat digits as arbitrary categorical labels using Cross-Entropy (CE) loss. This approach suffers from two major flaws. First, it ignores ordinality: to a standard model, predicting a "9" instead of a "3" is penalized just as heavily as predicting a "2," despite "2" being numerically much closer. Second, it neglects holistic errors; because numbers are often split across multiple tokens (e.g., "1", ".", "0", "1"), CE loss evaluates each in isolation, failing to capture the mathematical magnitude of the entire sequence.

Comparison of Cross-Entropy and EMD loss functions, illustrating how EMD accounts for numerical distance.

Methodology: Numerical Token Integrity Loss (NTIL)

To resolve these issues, we propose Numerical Token Integrity Loss (NTIL), which introduces a structured approach to numerical training at both the token and sequence levels.

Token-Level Optimization

Instead of treating digits as independent categories, NTIL utilizes a modified Earth Mover’s Distance (EMD). EMD measures the cost of transforming one probability distribution into another based on the numerical distance between digits. This ensures the model is penalized less for "near misses" in the digit space. Furthermore, we implement Exponential Position-Based Weighting, which applies higher weights to leading digits (e.g., the hundreds place vs. the units place) to reflect their greater impact on the total numerical value.

Sequence-Level Optimization

To capture the "whole value" of a multi-token number, NTIL employs a differentiable sequence-level optimization. By using a Gumbel-Softmax trick, the discrete digit selection process becomes differentiable, allowing the model to reconstruct the entire numerical value during training. The loss function can then calculate a Relative Deviation Metric and a Magnitude Deviation Metric for the complete string, backpropagating errors based on the total mathematical discrepancy rather than individual digit mismatches.

Experimental Results

We evaluated NTIL across a diverse suite of tasks, including image grounding (RefCOCO), scene text detection, clock time recognition, and general arithmetic reasoning.

Heatmap showing the absolute error between prediction and label across various models and loss functions.

As shown in the comparative analysis, NTIL consistently reduces absolute error across multiple model architectures, including Qwen2-VL, LLaVA-1.5, and PaliGemma. In the Clock Time Recognition task using LLaVA-1.5 (7b), accuracy improved from 95.1% (CE) to 98.3% (NTIL), while the average time gap error was reduced by over 50%. Qualitative analysis further reveals that NTIL helps models produce probability distributions that are more accurately centered and tightly concentrated around the ground truth.

Conclusion and Future Work

NTIL demonstrates that treating numerical tokens as part of a coherent mathematical structure significantly improves the precision of autoregressive models. While the method introduces some computational overhead and requires specific handling for multi-digit tokenizers, the gains in accuracy for spatial and mathematical tasks are substantial. Future research will focus on adaptively learning position weights and extending NTIL to handle complex, non-digit-based tokenization schemes.

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